Skip to content

Commit

Permalink
fix(qa) apply PHP70Migration rule
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Feb 6, 2024
1 parent 9c8e027 commit 36237d6
Show file tree
Hide file tree
Showing 45 changed files with 94 additions and 99 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/Adapter/Statement/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public function fetchColumn($columnIndex = 0)
}
$row = $this->fetch(Doctrine_Core::FETCH_NUM);

return isset($row[$columnIndex]) ? $row[$columnIndex] : false;
return $row[$columnIndex] ?? false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/AuditLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ public function getMaxVersion(Doctrine_Record $record)

$result = $q->execute($values, Doctrine_Core::HYDRATE_ARRAY);

return isset($result[0]['max_version']) ? $result[0]['max_version'] : 0;
return $result[0]['max_version'] ?? 0;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/Cache/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function deleteAll()
*/
protected function _getKey($id)
{
$prefix = isset($this->_options['prefix']) ? $this->_options['prefix'] : '';
$prefix = $this->_options['prefix'] ?? '';

if (!$prefix || 0 === strpos($id, $prefix)) {
return $id;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ protected function _run(array $args)
{
$this->_scriptName = $args[0];

$requestedTaskName = isset($args[1]) ? $args[1] : null;
$requestedTaskName = $args[1] ?? null;

if (!$requestedTaskName || 'help' == $requestedTaskName) {
$this->printTasks(null, 'help' == $requestedTaskName ? true : false);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function __unserialize($data)

$this->_table = $connection->getTable($this->_table);

$keyColumn = isset($array['keyColumn']) ? $array['keyColumn'] : null;
$keyColumn = $array['keyColumn'] ?? null;
if (null === $keyColumn) {
$keyColumn = $this->_table->getBoundQueryPart('indexBy');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function enumValue($index)
return false;
}

return isset($this->_definition['values'][$index]) ? $this->_definition['values'][$index] : false;
return $this->_definition['values'][$index] ?? false;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/Doctrine/Connection/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ public function getPortableMessage()
*/
public function errorMessage($value = null)
{
return isset(self::$errorMessages[$value]) ?
self::$errorMessages[$value] : self::$errorMessages[Doctrine_Core::ERR];
return self::$errorMessages[$value] ?? self::$errorMessages[Doctrine_Core::ERR];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/Connection/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public function getServerVersion($native = false)
];
} else {
$serverInfo = [
'major' => isset($tmp[0]) ? $tmp[0] : null,
'minor' => isset($tmp[1]) ? $tmp[1] : null,
'patch' => isset($tmp[2]) ? $tmp[2] : null,
'major' => $tmp[0] ?? null,
'minor' => $tmp[1] ?? null,
'patch' => $tmp[2] ?? null,
'extra' => null,
'native' => $serverInfo,
];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ public static function generateYamlFromDb($yamlPath, array $connections = [], ar
{
$directory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'tmp_doctrine_models';

$options['generateBaseClasses'] = isset($options['generateBaseClasses']) ? $options['generateBaseClasses'] : false;
$options['generateBaseClasses'] = $options['generateBaseClasses'] ?? false;
$result = Doctrine_Core::generateModelsFromDb($directory, $connections, $options);

if (empty($result) && !is_dir($directory)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Data/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected function _buildRows($className, $data)
protected function _buildNestedSetRows($className, $data)
{
foreach ($data as $rowKey => $row) {
$children = isset($row['children']) ? $row['children'] : [];
$children = $row['children'] ?? [];
unset($row['children']);
$this->_rows[$className][$rowKey] = $row;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DataDict/Mssql.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function getPortableDeclaration($field)
break;
default:
$type[] = $field['type'];
$length = isset($field['length']) ? $field['length'] : null;
$length = $field['length'] ?? null;
}

return ['type' => $type,
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DataDict/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public function getPortableDeclaration(array $field)
break;
default:
$type[] = $field['type'];
$length = isset($field['length']) ? $field['length'] : null;
$length = $field['length'] ?? null;
}

$length = (0 == (int) $length) ? null : (int) $length;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DataDict/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function getPortableDeclaration(array $field)
case 'urowid':
default:
$type[] = $field['type'];
$length = isset($field['length']) ? $field['length'] : null;
$length = $field['length'] ?? null;
}

return ['type' => $type,
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DataDict/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public function getPortableDeclaration(array $field)
$dbType = strtolower($field['type']);

// Default from field for enum support
$default = isset($field['default']) ? $field['default'] : null;
$default = $field['default'] ?? null;
$enumName = null;
if (false !== strpos($dbType, 'enum')) {
$enumName = $dbType;
Expand Down Expand Up @@ -598,7 +598,7 @@ public function getPortableDeclaration(array $field)
break;
default:
$type[] = $field['type'];
$length = isset($field['length']) ? $field['length'] : null;
$length = $field['length'] ?? null;
}

$ret = ['type' => $type,
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DataDict/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function getPortableDeclaration(array $field)
break;
default:
$type[] = $field['type'];
$length = isset($field['length']) ? $field['length'] : null;
$length = $field['length'] ?? null;
}

return ['type' => $type,
Expand Down
3 changes: 1 addition & 2 deletions lib/Doctrine/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function errorMessage($value = null)
return self::$_errorMessages;
}

return isset(self::$_errorMessages[$value]) ?
self::$_errorMessages[$value] : self::$_errorMessages[Doctrine_Core::ERR];
return self::$_errorMessages[$value] ?? self::$_errorMessages[Doctrine_Core::ERR];
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/Hydrator/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class Doctrine_Hydrator_Graph extends Doctrine_Hydrator_Abstract
*/
protected function _getCustomIndexField($alias)
{
return isset($this->_queryComponents[$alias]['map']) ? $this->_queryComponents[$alias]['map'] : null;
return $this->_queryComponents[$alias]['map'] ?? null;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions lib/Doctrine/Import/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function buildSetUp(array $definition)

if (isset($definition['relations']) && is_array($definition['relations']) && !empty($definition['relations'])) {
foreach ($definition['relations'] as $name => $relation) {
$class = isset($relation['class']) ? $relation['class'] : $name;
$class = $relation['class'] ?? $name;
$alias = (isset($relation['alias']) && $relation['alias'] !== $this->_classPrefix.$relation['class']) ? ' as '.$relation['alias'] : '';

if (!isset($relation['type'])) {
Expand Down Expand Up @@ -541,10 +541,10 @@ public function buildColumns(array $columns)
$column['name'] = $name.' as '.$column['alias'];
}

$columnName = isset($column['name']) ? $column['name'] : $name;
$columnName = $column['name'] ?? $name;
if ($manager->getAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE)) {
$e = explode(' as ', $columnName);
$fieldName = isset($e[1]) ? $e[1] : $e[0];
$fieldName = $e[1] ?? $e[0];
$classified = Doctrine_Inflector::classify($fieldName);
$getter = 'get'.$classified;
$setter = 'set'.$classified;
Expand Down Expand Up @@ -649,7 +649,7 @@ public function buildPhpDocs(array $definition)

if ((isset($definition['is_base_class']) && $definition['is_base_class']) || !$this->generateBaseClasses()) {
foreach ($definition['columns'] as $name => $column) {
$name = isset($column['name']) ? $column['name'] : $name;
$name = $column['name'] ?? $name;
// extract column name & field name
if (stripos($name, ' as ')) {
if (strpos($name, ' as')) {
Expand Down Expand Up @@ -756,7 +756,7 @@ public function buildPhpDocs(array $definition)
if (isset($definition['relations']) && !empty($definition['relations'])) {
foreach ($definition['relations'] as $relation) {
$type = (isset($relation['type']) && Doctrine_Relation::MANY == $relation['type']) ? 'Doctrine_Collection' : $this->_classPrefix.$relation['class'];
if ((isset($relation['type']) ? $relation['type'] : null) == Doctrine_Relation::ONE) {
if (($relation['type'] ?? null) == Doctrine_Relation::ONE) {
$properties[] = [$relation['class'], $relation['alias'], ''];
$getters[] = [$relation['class'], $relation['alias'], ''];
$setters[] = [$definition['topLevelClassName'], $relation['alias'], $relation['class'], ''];
Expand Down Expand Up @@ -1032,10 +1032,10 @@ private function mergeDefinitionAndActAsColumns(array $definitionColumns, array
$result = $definitionColumns;

foreach ($actAsColumns as $actAsOptionName => $actAsColumn) {
$actAsColumnName = isset($actAsColumn['name']) ? $actAsColumn['name'] : $actAsOptionName;
$actAsColumnName = $actAsColumn['name'] ?? $actAsOptionName;

foreach ($result as $optionName => $column) {
$name = isset($column['name']) ? $column['name'] : $optionName;
$name = $column['name'] ?? $optionName;
if ($name === $actAsColumnName) {
continue 2;
}
Expand Down Expand Up @@ -1165,7 +1165,7 @@ public function buildDefinition(array $definition)
}
$abstract = isset($definition['abstract']) && true === $definition['abstract'] ? 'abstract ' : null;
$className = $definition['className'];
$extends = isset($definition['inheritance']['extends']) ? $definition['inheritance']['extends'] : $this->_baseClassName;
$extends = $definition['inheritance']['extends'] ?? $this->_baseClassName;

// Clear actAsColumns
$this->actAsColumns = [];
Expand Down Expand Up @@ -1278,7 +1278,7 @@ protected function _getBaseClassName($className)

public function buildTableClassDefinition($className, $definition, $options = [])
{
$extends = isset($options['extends']) ? $options['extends'] : $this->_baseTableClassName;
$extends = $options['extends'] ?? $this->_baseTableClassName;
if ($extends !== $this->_baseTableClassName) {
$extends = $this->_classPrefix.$extends;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Import/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function listTableColumns($table)

$decl = $this->conn->dataDict->getPortableDeclaration($val);

$values = isset($decl['values']) ? $decl['values'] : [];
$values = $decl['values'] ?? [];
$val['default'] = 'CURRENT_TIMESTAMP' == $val['default'] ? null : $val['default'];

$description = [
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Import/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function listTableColumns($table)
'default' => $val['data_default'],
'length' => $val['data_length'],
'primary' => (bool) $val['primary'],
'scale' => isset($val['scale']) ? $val['scale'] : null,
'scale' => $val['scale'] ?? null,
];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Import/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function listTableColumns($table)

// If postgres enum type
if ('e' == $val['type']) {
$description['default'] = isset($decl['default']) ? $decl['default'] : null;
$description['default'] = $decl['default'] ?? null;
$t_result = $this->conn->fetchAssoc(sprintf('select enum_range(null::%s) as range ', $decl['enum_name']));
if (isset($t_result[0])) {
$range = $t_result[0]['range'];
Expand Down
32 changes: 16 additions & 16 deletions lib/Doctrine/Import/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ public function parseSchema($schema, $type)
}
}

$connection = isset($table['connection']) ? $table['connection'] : 'current';
$connection = $table['connection'] ?? 'current';

$columns = isset($table['columns']) ? $table['columns'] : [];
$columns = $table['columns'] ?? [];

if (!empty($columns)) {
foreach ($columns as $columnName => $field) {
Expand Down Expand Up @@ -383,7 +383,7 @@ public function parseSchema($schema, $type)

$colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed'] : null;
$colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']) : null;
$colDesc['default'] = isset($field['default']) ? $field['default'] : null;
$colDesc['default'] = $field['default'] ?? null;
$colDesc['autoincrement'] = isset($field['autoincrement']) ? (bool) (isset($field['autoincrement']) && $field['autoincrement']) : null;

if (isset($field['sequence'])) {
Expand Down Expand Up @@ -416,7 +416,7 @@ public function parseSchema($schema, $type)
if (isset($table[$key]) && !isset($build[$className][$key])) {
$build[$className][$key] = $table[$key];
} else {
$build[$className][$key] = isset($build[$className][$key]) ? $build[$className][$key] : $defaultValue;
$build[$className][$key] = $build[$className][$key] ?? $defaultValue;
}
}

Expand Down Expand Up @@ -563,8 +563,8 @@ protected function _buildRelationships($array)

// Set the detected foreign key type and length to the same as the primary key
// of the related table
$type = isset($array[$columnClassName]['columns']['id']['type']) ? $array[$columnClassName]['columns']['id']['type'] : 'integer';
$length = isset($array[$columnClassName]['columns']['id']['length']) ? $array[$columnClassName]['columns']['id']['length'] : 8;
$type = $array[$columnClassName]['columns']['id']['type'] ?? 'integer';
$length = $array[$columnClassName]['columns']['id']['length'] ?? 8;
$array[$className]['columns'][$column['name']]['type'] = $type;
$array[$className]['columns'][$column['name']]['length'] = $length;
}
Expand All @@ -582,20 +582,20 @@ protected function _buildRelationships($array)
$relations = $properties['relations'];

foreach ($relations as $alias => $relation) {
$class = isset($relation['class']) ? $relation['class'] : $alias;
$class = $relation['class'] ?? $alias;
if (!isset($array[$class])) {
continue;
}
$relation['class'] = $class;
$relation['alias'] = isset($relation['alias']) ? $relation['alias'] : $alias;
$relation['alias'] = $relation['alias'] ?? $alias;

// Attempt to guess the local and foreign
if (isset($relation['refClass'])) {
$relation['local'] = isset($relation['local']) ? $relation['local'] : Doctrine_Inflector::tableize($name).'_id';
$relation['foreign'] = isset($relation['foreign']) ? $relation['foreign'] : Doctrine_Inflector::tableize($class).'_id';
$relation['local'] = $relation['local'] ?? Doctrine_Inflector::tableize($name).'_id';
$relation['foreign'] = $relation['foreign'] ?? Doctrine_Inflector::tableize($class).'_id';
} else {
$relation['local'] = isset($relation['local']) ? $relation['local'] : Doctrine_Inflector::tableize($relation['class']).'_id';
$relation['foreign'] = isset($relation['foreign']) ? $relation['foreign'] : 'id';
$relation['local'] = $relation['local'] ?? Doctrine_Inflector::tableize($relation['class']).'_id';
$relation['foreign'] = $relation['foreign'] ?? 'id';
}

if (isset($relation['refClass'])) {
Expand Down Expand Up @@ -651,8 +651,8 @@ protected function _autoCompleteOppositeRelations()
$newRelation = [];
$newRelation['foreign'] = $relation['local'];
$newRelation['local'] = $relation['foreign'];
$newRelation['class'] = isset($relation['foreignClass']) ? $relation['foreignClass'] : $className;
$newRelation['alias'] = isset($relation['foreignAlias']) ? $relation['foreignAlias'] : $className;
$newRelation['class'] = $relation['foreignClass'] ?? $className;
$newRelation['alias'] = $relation['foreignAlias'] ?? $className;
$newRelation['foreignAlias'] = $alias;

// this is so that we know that this relation was autogenerated and
Expand All @@ -661,7 +661,7 @@ protected function _autoCompleteOppositeRelations()

if (isset($relation['refClass'])) {
$newRelation['refClass'] = $relation['refClass'];
$newRelation['type'] = isset($relation['foreignType']) ? $relation['foreignType'] : $relation['type'];
$newRelation['type'] = $relation['foreignType'] ?? $relation['type'];
} else {
if (isset($relation['foreignType'])) {
$newRelation['type'] = $relation['foreignType'];
Expand Down Expand Up @@ -717,7 +717,7 @@ protected function _fixDuplicateRelations()
*/
protected function _buildUniqueRelationKey($relation)
{
return md5($relation['local'].$relation['foreign'].$relation['class'].(isset($relation['refClass']) ? $relation['refClass'] : null));
return md5($relation['local'].$relation['foreign'].$relation['class'].($relation['refClass'] ?? null));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function getCurrentVersion()

$result = $this->_connection->fetchColumn('SELECT version FROM '.$this->_migrationTableName);

return isset($result[0]) ? $result[0] : 0;
return $result[0] ?? 0;
}

/**
Expand All @@ -265,7 +265,7 @@ public function getLatestVersion()
$versions = array_keys($this->_migrationClasses);
rsort($versions);

return isset($versions[0]) ? $versions[0] : 0;
return $versions[0] ?? 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Migration/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public function createPrimaryKey($tableName, $columnNames)
// Add the columns
foreach ($columnNames as $columnName => $def) {
$type = $def['type'];
$length = isset($def['length']) ? $def['length'] : null;
$options = isset($def['options']) ? $def['options'] : [];
$length = $def['length'] ?? null;
$options = $def['options'] ?? [];

$this->addColumn($tableName, $columnName, $type, $length, $options);

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Migration/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public function generateMigrationClass($className, $options = [], $up = null, $d
*/
public function buildMigrationClass($className, $fileName = null, $options = [], $up = null, $down = null)
{
$extends = isset($options['extends']) ? $options['extends'] : 'Doctrine_Migration_Base';
$extends = $options['extends'] ?? 'Doctrine_Migration_Base';

$content = '<?php'.PHP_EOL;

Expand Down
Loading

0 comments on commit 36237d6

Please sign in to comment.