Skip to content

Commit

Permalink
fix(qa) apply PHP74Migration:risky rule
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Feb 6, 2024
1 parent bfd53f9 commit d75496e
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 32 deletions.
6 changes: 3 additions & 3 deletions lib/Doctrine/Adapter/Statement/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function bindParam($column, &$variable, $type = null, $length = null, $dr
break;
}

if (is_integer($column)) {
if (is_int($column)) {
$variable_name = ":oci_b_var_{$column}";
} else {
$variable_name = $column;
Expand Down Expand Up @@ -381,7 +381,7 @@ public function fetchAll($fetchStyle = Doctrine_Core::FETCH_BOTH, $colnum = 0)
*/
public function fetchColumn($columnIndex = 0)
{
if (!is_integer($columnIndex)) {
if (!is_int($columnIndex)) {
$this->handleError(['message' => 'columnIndex parameter should be numeric']);

return false;
Expand Down Expand Up @@ -452,7 +452,7 @@ public function fetchObject($className = 'stdClass', $args = [])
*/
public function getColumnMeta($column)
{
if (is_integer($column)) {
if (is_int($column)) {
$internal_column = $column + 1;
} else {
$internal_column = $column;
Expand Down
6 changes: 2 additions & 4 deletions lib/Doctrine/Connection/Mssql.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function parseOrderBy($orderby)
$tokens = preg_split('/,/', $parsed);

for ($i = 0, $iMax = count($tokens); $i < $iMax; ++$i) {
$tokens[$i] = trim(preg_replace_callback('/##(\d+)##/', function ($m) { return $chunks[$m[1]]; }, $tokens[$i]));
$tokens[$i] = trim(preg_replace_callback('/##(\d+)##/', fn ($m) => $chunks[$m[1]], $tokens[$i]));
}

return $tokens;
Expand Down Expand Up @@ -323,9 +323,7 @@ protected function replaceBoundParamsWithInlineValuesInQuery($query, array $para

$self = $this;

return preg_replace_callback('/##(\d+)##/', function ($m) use ($params, $self) {
return (null === $params[$m[1]]) ? 'NULL' : $self->quote($params[$m[1]]);
}, $query);
return preg_replace_callback('/##(\d+)##/', fn ($m) => (null === $params[$m[1]]) ? 'NULL' : $self->quote($params[$m[1]]), $query);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Expression/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public function concat()
{
$args = func_get_args();

return 'CONCAT('.join(', ', (array) $args).')';
return 'CONCAT('.implode(', ', (array) $args).')';
}

/**
Expand Down Expand Up @@ -635,7 +635,7 @@ public function coalesce()
{
$args = func_get_args();

return 'COALESCE('.join(', ', (array) $args).')';
return 'COALESCE('.implode(', ', (array) $args).')';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Expression/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function concat()
{
$args = func_get_args();

return join(' || ', $args);
return implode(' || ', $args);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Expression/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function concat()
{
$args = func_get_args();

return join(' || ', $args);
return implode(' || ', $args);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Expression/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function concatImpl()
{
$args = func_get_args();

return join('', $args);
return implode('', $args);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Import/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,12 @@ public function buildPhpDocs(array $definition)
if (isset($phpCommentMap[$column['type']])) {
$comment = $phpCommentMap[$column['type']];
if ('enum' == $column['type']) {
$comment = sprintf($comment, strtoupper(join(', ', $column['values'])));
$comment = sprintf($comment, strtoupper(implode(', ', $column['values'])));
}
$commentOptions[] = $comment;
}

$comment = join(', ', $commentOptions);
$comment = implode(', ', $commentOptions);

$fieldName = trim($fieldName);

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Parser/sfYaml/sfYamlInline.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected static function dumpArray($value)
$keys = array_keys($value);
if (
(1 == count($keys) && '0' == $keys[0])
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) ($v + $w); }, 0) == count($keys) * (count($keys) - 1) / 2)) {
|| (count($keys) > 1 && array_reduce($keys, fn ($v, $w) => (int) ($v + $w), 0) == count($keys) * (count($keys) - 1) / 2)) {
$output = [];
foreach ($value as $val) {
$output[] = self::dump($val);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Query/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ public function execute($params = [], $hydrationMode = null)
} else {
$stmt = $this->_execute($params);

if (is_integer($stmt)) {
if (is_int($stmt)) {
$result = $stmt;
} else {
$this->_hydrator->setQueryComponents($this->_queryComponents);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Query/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private function clauseExplodeCountBrackets($str, $regexp, $e1 = '(', $e2 = ')')
}

$terms = array_merge($terms, $subterms);
$i += sizeof($subterms);
$i += count($subterms);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ public function state($state = null)
}

$err = false;
if (is_integer($state)) {
if (is_int($state)) {
if ($state >= 1 && $state <= 7) {
$this->_state = $state;
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/ConnectionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testGetDbh()

public function testCount()
{
$this->assertTrue(is_integer(count($this->connection)));
$this->assertTrue(is_int(count($this->connection)));
}

public function testGetIterator()
Expand Down
4 changes: 2 additions & 2 deletions tests/ManagerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testGetIterator()

public function testCount()
{
$this->assertTrue(is_integer(count($this->manager)));
$this->assertTrue(is_int(count($this->manager)));
}

public function testGetCurrentConnection()
Expand All @@ -67,7 +67,7 @@ public function testGetCurrentConnection()

public function testGetConnections()
{
$this->assertTrue(is_integer(count($this->manager->getConnections())));
$this->assertTrue(is_int(count($this->manager->getConnections())));
}

public function testClassifyTableize()
Expand Down
2 changes: 1 addition & 1 deletion tests/RecordTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ public function testCount()
{
$user = $this->connection->getTable('User')->find(4);

$this->assertTrue(is_integer($user->count()));
$this->assertTrue(is_int($user->count()));
}

public function testGetReference()
Expand Down
4 changes: 2 additions & 2 deletions tests/Ticket/1195TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public function testRawSQLDistinct()
;

$res = $q->execute([], Doctrine_Core::HYDRATE_ARRAY);
$this->assertEqual(sizeof($res), 2);
$this->assertEqual(count($res), 2);

$q->distinct();
$res = $q->execute([], Doctrine_Core::HYDRATE_ARRAY);
$this->assertEqual(sizeof($res), 1);
$this->assertEqual(count($res), 1);
}

public function testRawSQLCount()
Expand Down
16 changes: 8 additions & 8 deletions tests/Ticket/2375TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function testTest()
$this->assertEqual(2, count($models1));

// make sure the right models were loaded
$this->assertTrue(key_exists('Ticket_2375_Model1', $models1));
$this->assertTrue(key_exists('Ticket_2375_Model2', $models1));
$this->assertTrue(array_key_exists('Ticket_2375_Model1', $models1));
$this->assertTrue(array_key_exists('Ticket_2375_Model2', $models1));

// get a list of all models that have been loaded
$loadedModels = Doctrine_Core::getLoadedModelFiles();
Expand All @@ -63,10 +63,10 @@ public function testTest()
$models2 = Doctrine_Core::loadModels($models2Dir);

// make sure the right models were loaded
$this->assertTrue(key_exists('Ticket_2375_Model3', $models2));
$this->assertTrue(key_exists('Ticket_2375_Model4', $models2));
$this->assertTrue(key_exists('Ticket_2375_Model5', $models2));
$this->assertTrue(key_exists('Ticket_2375_Model6', $models2));
$this->assertTrue(array_key_exists('Ticket_2375_Model3', $models2));
$this->assertTrue(array_key_exists('Ticket_2375_Model4', $models2));
$this->assertTrue(array_key_exists('Ticket_2375_Model5', $models2));
$this->assertTrue(array_key_exists('Ticket_2375_Model6', $models2));

// get a list of all models that have been loaded
$loadedModels = Doctrine_Core::getLoadedModelFiles();
Expand All @@ -84,8 +84,8 @@ public function testTest()
$models1 = Doctrine_Core::loadModels($models1Dir);

// make sure the right models were loaded
$this->assertTrue(key_exists('Ticket_2375_Model1', $models1));
$this->assertTrue(key_exists('Ticket_2375_Model2', $models1));
$this->assertTrue(array_key_exists('Ticket_2375_Model1', $models1));
$this->assertTrue(array_key_exists('Ticket_2375_Model2', $models1));

// get a list of all models that have been loaded
$loadedModels = Doctrine_Core::getLoadedModelFiles();
Expand Down

0 comments on commit d75496e

Please sign in to comment.