Skip to content

Commit

Permalink
refactor: run rector
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 29, 2023
1 parent 5d99f3d commit 9f2785f
Show file tree
Hide file tree
Showing 27 changed files with 33 additions and 41 deletions.
2 changes: 1 addition & 1 deletion system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function run()
Services::routes()->loadRoutes();

$runner = Services::commands();
$params = array_merge(CLI::getSegments(), CLI::getOptions());
$params = [...CLI::getSegments(), ...CLI::getOptions()];
$params = $this->parseParamsForHelpOption($params);
$command = array_shift($params) ?? 'list';

Expand Down
2 changes: 1 addition & 1 deletion system/Cache/Handlers/MemcachedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(Cache $config)
{
$this->prefix = $config->prefix;

$this->config = array_merge($this->config, $config->memcached);
$this->config = [...$this->config, ...$config->memcached];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Cache/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(Cache $config)
$this->prefix = $config->prefix;

if (isset($config->redis)) {
$this->config = array_merge($this->config, $config->redis);
$this->config = [...$this->config, ...$config->redis];
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/Cache/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(Cache $config)
{
$this->prefix = $config->prefix;

$this->config = array_merge($this->config, $config->redis);
$this->config = [...$this->config, ...$config->redis];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Generators/CellGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function run(array $params)
$this->component = 'Cell';
$this->directory = 'Cells';

$params = array_merge($params, ['suffix' => null]);
$params = [...$params, 'suffix' => null];

$this->templatePath = config(Generators::class)->views[$this->name]['class'];
$this->template = 'cell.tpl.php';
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function prepare(string $class): string
}

$return = '\\' . trim($return, '\\') . '::class';
$this->call('make:entity', array_merge([$baseClass], $this->params));
$this->call('make:entity', [$baseClass, ...$this->params]);
} else {
$return = "'{$return}'";
}
Expand Down
4 changes: 2 additions & 2 deletions system/Commands/Translation/LocalizationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function process(string $currentDir, string $currentLocale): void
$countNewKeys += ArrayHelper::recursiveCount($languageDiff);

if ($this->showNew) {
$tableRows = array_merge($this->arrayToTableRows($langFileName, $languageDiff), $tableRows);
$tableRows = [...$this->arrayToTableRows($langFileName, $languageDiff), ...$tableRows];
} else {
$newLanguageKeys = array_replace_recursive($foundLanguageKeys[$langFileName], $languageStoredKeys);

Expand Down Expand Up @@ -303,7 +303,7 @@ private function arrayToTableRows(string $langFileName, array $array): array

foreach ($array as $value) {
if (is_array($value)) {
$rows = array_merge($rows, $this->arrayToTableRows($langFileName, $value));
$rows = [...$rows, ...$this->arrayToTableRows($langFileName, $value)];

continue;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected function registerProperties()

foreach ($properties as $property => $value) {
if (isset($this->{$property}) && is_array($this->{$property}) && is_array($value)) {
$this->{$property} = array_merge($this->{$property}, $value);
$this->{$property} = [...$this->{$property}, ...$value];
} else {
$this->{$property} = $value;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static function __callStatic(string $name, array $arguments)
public static function serviceExists(string $name): ?string
{
static::buildServicesCache();
$services = array_merge(self::$serviceNames, [Services::class]);
$services = [...self::$serviceNames, Services::class];
$name = strtolower($name);

foreach ($services as $service) {
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ public function processIndexes(string $table): bool
$this->fields = $fields;

if ($this->foreignKeys !== []) {
$sqls = array_merge($sqls, $this->_processForeignKeys($table, true));
$sqls = [...$sqls, ...$this->_processForeignKeys($table, true)];
}

foreach ($sqls as $sql) {
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Postgre/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ protected function _like_statement(?string $prefix, string $column, ?string $not
public function join(string $table, $cond, string $type = '', ?bool $escape = null)
{
if (! in_array('FULL OUTER', $this->joinTypes, true)) {
$this->joinTypes = array_merge($this->joinTypes, ['FULL OUTER']);
$this->joinTypes = [...$this->joinTypes, 'FULL OUTER'];
}

return parent::join($table, $cond, $type, $escape);
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLite3/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function addForeignKey(array $foreignKeys)
$fk[] = $obj;
}

$this->foreignKeys = array_merge($this->foreignKeys, $fk);
$this->foreignKeys = [...$this->foreignKeys, ...$fk];

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ protected function structureTimelineData(array $elements): array
}

// Make sure our younger siblings know their relatives, too
return array_merge([$element], $this->structureTimelineData($elements));
return [$element, ...$this->structureTimelineData($elements)];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ protected static function substr($str, $start, $length = null)
protected function setArchiveValues(): array
{
// Get property values and add anything prepped in tmpArchive
$this->archive = array_merge(get_object_vars($this), $this->tmpArchive);
$this->archive = [...get_object_vars($this), ...$this->tmpArchive];
unset($this->archive['archive']);

// Clear tmpArchive for next run
Expand Down
2 changes: 1 addition & 1 deletion system/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function initialize()
return false; // @codeCoverageIgnore
}, $files));

static::$files = array_unique(array_merge($files, [$events]));
static::$files = array_unique([...$files, $events]);

foreach (static::$files as $file) {
include $file;
Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/array_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function array_flatten_with_dots(iterable $array, string $id = ''): array
$newKey = $id . $key;

if (is_array($value) && $value !== []) {
$flattened = array_merge($flattened, array_flatten_with_dots($value, $newKey . '.'));
$flattened = [...$flattened, ...array_flatten_with_dots($value, $newKey . '.')];
} else {
$flattened[$newKey] = $value;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Images/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ abstract protected function _flip(string $direction);
*/
public function text(string $text, array $options = [])
{
$options = array_merge($this->textDefaults, $options);
$options = [...$this->textDefaults, ...$options];
$options['color'] = trim($options['color'], '# ');
$options['shadowColor'] = trim($options['shadowColor'], '# ');

Expand Down
6 changes: 3 additions & 3 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public function addPlaceholder($placeholder, ?string $pattern = null): RouteColl
$placeholder = [$placeholder => $pattern];
}

$this->placeholders = array_merge($this->placeholders, $placeholder);
$this->placeholders = [...$this->placeholders, ...$placeholder];

return $this;
}
Expand Down Expand Up @@ -783,7 +783,7 @@ public function group(string $name, ...$params)
if (isset($options['filter'])) {
// Merge filters.
$currentFilter = (array) ($this->currentOptions['filter'] ?? []);
$options['filter'] = array_merge($currentFilter, (array) $options['filter']);
$options['filter'] = [...$currentFilter, ...(array) $options['filter']];
}

// Merge options other than filters.
Expand Down Expand Up @@ -1147,7 +1147,7 @@ public function view(string $from, string $view, ?array $options = null): RouteC
->render($view, $options);

$routeOptions = $options ?? [];
$routeOptions = array_merge($routeOptions, ['view' => $view]);
$routeOptions = [...$routeOptions, 'view' => $view];

$this->create(Method::GET, $from, $to, $routeOptions);

Expand Down
4 changes: 2 additions & 2 deletions system/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public function get(?string $key = null)
}

$userdata = [];
$_exclude = array_merge(['__ci_vars'], $this->getFlashKeys(), $this->getTempKeys());
$_exclude = ['__ci_vars', ...$this->getFlashKeys(), ...$this->getTempKeys()];

$keys = array_keys($_SESSION);

Expand Down Expand Up @@ -537,7 +537,7 @@ public function has(string $key): bool
public function push(string $key, array $data)
{
if ($this->has($key) && is_array($value = $this->get($key))) {
$this->set($key, array_merge($value, $data));
$this->set($key, [...$value, ...$data]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/View/Cells/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final protected function view(?string $view, array $data = []): string
{
$properties = $this->getPublicProperties();
$properties = $this->includeComputedProperties($properties);
$properties = array_merge($properties, $data);
$properties = [...$properties, ...$data];

$view = (string) $view;

Expand Down
2 changes: 1 addition & 1 deletion system/View/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function addRow()
$tmpRow = array_filter($tmpRow, static fn ($k) => array_key_exists($k, $keyIndex), ARRAY_FILTER_USE_KEY);

// add missing keys to row, but use $this->emptyCells
$tmpRow = array_merge($tmpRow, array_map(fn ($v) => ['data' => $this->emptyCells], $missingKeys));
$tmpRow = [...$tmpRow, ...array_map(fn ($v) => ['data' => $this->emptyCells], $missingKeys)];

// order keys by $keyIndex values
uksort($tmpRow, static fn ($k1, $k2) => $keyIndex[$k1] <=> $keyIndex[$k2]);
Expand Down
2 changes: 1 addition & 1 deletion tests/system/API/ResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function makeController(array $userConfig = [], string $routePath = ''
$headers = [
'Accept' => 'text/html',
];
$headers = array_merge($headers, $userHeaders);
$headers = [...$headers, ...$userHeaders];

foreach ($headers as $key => $value) {
$this->request->setHeader($key, $value);
Expand Down
4 changes: 2 additions & 2 deletions tests/system/HTTP/IncomingRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,8 @@ public function testGetPostSecondStreams(): void
{
$_GET['get'] = '3';
$_POST['post'] = '5';
$this->assertSame(array_merge($_GET, $_POST), $this->request->getPostGet());
$this->assertSame(array_merge($_POST, $_GET), $this->request->getGetPost());
$this->assertSame([...$_GET, ...$_POST], $this->request->getPostGet());
$this->assertSame([...$_POST, ...$_GET], $this->request->getGetPost());
}

public function testGetBodyWithFalseBody(): void
Expand Down
12 changes: 2 additions & 10 deletions tests/system/Helpers/FilesystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,7 @@ public function testDeleteFilesHandlesRecursion(): void

public function testDeleteFilesLeavesHTFiles(): void
{
$structure = array_merge($this->structure, [
'.htaccess' => 'Deny All',
'index.html' => 'foo',
'index.php' => 'blah',
]);
$structure = [...$this->structure, '.htaccess' => 'Deny All', 'index.html' => 'foo', 'index.php' => 'blah'];

$vfs = vfsStream::setup('root', null, $structure);

Expand All @@ -265,11 +261,7 @@ public function testDeleteFilesLeavesHTFiles(): void

public function testDeleteFilesIncludingHidden(): void
{
$structure = array_merge($this->structure, [
'.htaccess' => 'Deny All',
'index.html' => 'foo',
'index.php' => 'blah',
]);
$structure = [...$this->structure, '.htaccess' => 'Deny All', 'index.html' => 'foo', 'index.php' => 'blah'];

$vfs = vfsStream::setup('root', null, $structure);

Expand Down
2 changes: 1 addition & 1 deletion tests/system/Router/DefinedRouteCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private function createRouteCollection(array $config = [], $moduleConfig = null)
'Config' => APPPATH . 'Config',
'App' => APPPATH,
];
$config = array_merge($config, $defaults);
$config = [...$config, ...$defaults];

Services::autoloader()->addNamespace($config);

Expand Down
2 changes: 1 addition & 1 deletion tests/system/Router/RouteCollectionReverseRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
'Config' => APPPATH . 'Config',
'App' => APPPATH,
];
$config = array_merge($config, $defaults);
$config = [...$config, ...$defaults];

Services::autoloader()->addNamespace($config);

Expand Down
2 changes: 1 addition & 1 deletion tests/system/Router/RouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
'Config' => APPPATH . 'Config',
'App' => APPPATH,
];
$config = array_merge($config, $defaults);
$config = [...$config, ...$defaults];

Services::autoloader()->addNamespace($config);

Expand Down

0 comments on commit 9f2785f

Please sign in to comment.