Skip to content

Commit

Permalink
Merge pull request #4560 from samsonasik/apply-rector-change-array-pu…
Browse files Browse the repository at this point in the history
…sh-to-array-assign

[Rector] Apply Rector: ChangeArrayPushToArrayAssignRector
  • Loading branch information
samsonasik committed Apr 12, 2021
2 parents 38e59e0 + 1bf2188 commit dd19b1e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
Expand Down Expand Up @@ -74,4 +75,5 @@
$services->set(UnusedForeachValueToArrayKeysRector::class);
$services->set(RemoveConcatAutocastRector::class);
$services->set(RemoveDefaultArgumentValueRector::class);
$services->set(ChangeArrayPushToArrayAssignRector::class);
};
9 changes: 6 additions & 3 deletions system/CLI/GeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,12 @@ protected function parseTemplate(string $class, array $search = [], array $repla
{
// Retrieves the namespace part from the fully qualified class name.
$namespace = trim(implode('\\', array_slice(explode('\\', $class), 0, -1)), '\\');

array_push($search, '<@php', '{namespace}', '{class}');
array_push($replace, '<?php', $namespace, str_replace($namespace . '\\', '', $class));
$search[] = '<@php';
$search[] = '{namespace}';
$search[] = '{class}';
$replace[] = '<?php';
$replace[] = $namespace;
$replace[] = str_replace($namespace . '\\', '', $class);

return str_replace($search, $replace, $this->renderTemplate($data));
}
Expand Down
2 changes: 1 addition & 1 deletion system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected static function getSharedInstance(string $key, ...$params)
if (! isset(static::$instances[$key]))
{
// Make sure $getShared is false
array_push($params, false);
$params[] = false;

static::$instances[$key] = static::$key(...$params);
}
Expand Down
2 changes: 1 addition & 1 deletion system/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getDestination(string $destination, string $delimiter = '_', int
{
$i = end($parts);
array_pop($parts);
array_push($parts, ++ $i);
$parts[] = ++ $i;
$destination = $info['dirname'] . '/' . implode($delimiter, $parts) . $extension;
}
else
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Negotiate.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function charset(array $supported): string
*/
public function encoding(array $supported = []): string
{
array_push($supported, 'identity');
$supported[] = 'identity';

return $this->getBestMatch($supported, $this->request->getHeaderLine('accept-encoding'));
}
Expand Down
4 changes: 2 additions & 2 deletions system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ protected function mergePaths(URI $base, URI $reference): string
}

array_pop($path);
array_push($path, $reference->getPath());
$path[] = $reference->getPath();

return implode('/', $path);
}
Expand Down Expand Up @@ -1181,7 +1181,7 @@ public function removeDotSegments(string $path): string
}
elseif ($segment !== '.' && $segment !== '')
{
array_push($output, $segment);
$output[] = $segment;
}
}

Expand Down

0 comments on commit dd19b1e

Please sign in to comment.