Skip to content

Commit 9f2785f

Browse files
committed
refactor: run rector
1 parent 5d99f3d commit 9f2785f

27 files changed

+33
-41
lines changed

system/CLI/Console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function run()
3939
Services::routes()->loadRoutes();
4040

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

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(Cache $config)
5151
{
5252
$this->prefix = $config->prefix;
5353

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

5757
/**

system/Cache/Handlers/PredisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(Cache $config)
5353
$this->prefix = $config->prefix;
5454

5555
if (isset($config->redis)) {
56-
$this->config = array_merge($this->config, $config->redis);
56+
$this->config = [...$this->config, ...$config->redis];
5757
}
5858
}
5959

system/Cache/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(Cache $config)
5151
{
5252
$this->prefix = $config->prefix;
5353

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

5757
/**

system/Commands/Generators/CellGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function run(array $params)
7777
$this->component = 'Cell';
7878
$this->directory = 'Cells';
7979

80-
$params = array_merge($params, ['suffix' => null]);
80+
$params = [...$params, 'suffix' => null];
8181

8282
$this->templatePath = config(Generators::class)->views[$this->name]['class'];
8383
$this->template = 'cell.tpl.php';

system/Commands/Generators/ModelGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function prepare(string $class): string
123123
}
124124

125125
$return = '\\' . trim($return, '\\') . '::class';
126-
$this->call('make:entity', array_merge([$baseClass], $this->params));
126+
$this->call('make:entity', [$baseClass, ...$this->params]);
127127
} else {
128128
$return = "'{$return}'";
129129
}

system/Commands/Translation/LocalizationFinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private function process(string $currentDir, string $currentLocale): void
130130
$countNewKeys += ArrayHelper::recursiveCount($languageDiff);
131131

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

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

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

308308
continue;
309309
}

system/Config/BaseConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected function registerProperties()
261261

262262
foreach ($properties as $property => $value) {
263263
if (isset($this->{$property}) && is_array($this->{$property}) && is_array($value)) {
264-
$this->{$property} = array_merge($this->{$property}, $value);
264+
$this->{$property} = [...$this->{$property}, ...$value];
265265
} else {
266266
$this->{$property} = $value;
267267
}

system/Config/BaseService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static function __callStatic(string $name, array $arguments)
266266
public static function serviceExists(string $name): ?string
267267
{
268268
static::buildServicesCache();
269-
$services = array_merge(self::$serviceNames, [Services::class]);
269+
$services = [...self::$serviceNames, Services::class];
270270
$name = strtolower($name);
271271

272272
foreach ($services as $service) {

system/Database/Forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ public function processIndexes(string $table): bool
10941094
$this->fields = $fields;
10951095

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

11001100
foreach ($sqls as $sql) {

system/Database/Postgre/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected function _like_statement(?string $prefix, string $column, ?string $not
306306
public function join(string $table, $cond, string $type = '', ?bool $escape = null)
307307
{
308308
if (! in_array('FULL OUTER', $this->joinTypes, true)) {
309-
$this->joinTypes = array_merge($this->joinTypes, ['FULL OUTER']);
309+
$this->joinTypes = [...$this->joinTypes, 'FULL OUTER'];
310310
}
311311

312312
return parent::join($table, $cond, $type, $escape);

system/Database/SQLite3/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function addForeignKey(array $foreignKeys)
271271
$fk[] = $obj;
272272
}
273273

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

276276
return $this;
277277
}

system/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ protected function structureTimelineData(array $elements): array
326326
}
327327

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

332332
/**

system/Email/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ protected static function substr($str, $start, $length = null)
22492249
protected function setArchiveValues(): array
22502250
{
22512251
// Get property values and add anything prepped in tmpArchive
2252-
$this->archive = array_merge(get_object_vars($this), $this->tmpArchive);
2252+
$this->archive = [...get_object_vars($this), ...$this->tmpArchive];
22532253
unset($this->archive['archive']);
22542254

22552255
// Clear tmpArchive for next run

system/Events/Events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function initialize()
9191
return false; // @codeCoverageIgnore
9292
}, $files));
9393

94-
static::$files = array_unique(array_merge($files, [$events]));
94+
static::$files = array_unique([...$files, $events]);
9595

9696
foreach (static::$files as $file) {
9797
include $file;

system/Helpers/array_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function array_flatten_with_dots(iterable $array, string $id = ''): array
136136
$newKey = $id . $key;
137137

138138
if (is_array($value) && $value !== []) {
139-
$flattened = array_merge($flattened, array_flatten_with_dots($value, $newKey . '.'));
139+
$flattened = [...$flattened, ...array_flatten_with_dots($value, $newKey . '.')];
140140
} else {
141141
$flattened[$newKey] = $value;
142142
}

system/Images/Handlers/BaseHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ abstract protected function _flip(string $direction);
413413
*/
414414
public function text(string $text, array $options = [])
415415
{
416-
$options = array_merge($this->textDefaults, $options);
416+
$options = [...$this->textDefaults, ...$options];
417417
$options['color'] = trim($options['color'], '# ');
418418
$options['shadowColor'] = trim($options['shadowColor'], '# ');
419419

system/Router/RouteCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public function addPlaceholder($placeholder, ?string $pattern = null): RouteColl
390390
$placeholder = [$placeholder => $pattern];
391391
}
392392

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

395395
return $this;
396396
}
@@ -783,7 +783,7 @@ public function group(string $name, ...$params)
783783
if (isset($options['filter'])) {
784784
// Merge filters.
785785
$currentFilter = (array) ($this->currentOptions['filter'] ?? []);
786-
$options['filter'] = array_merge($currentFilter, (array) $options['filter']);
786+
$options['filter'] = [...$currentFilter, ...(array) $options['filter']];
787787
}
788788

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

11491149
$routeOptions = $options ?? [];
1150-
$routeOptions = array_merge($routeOptions, ['view' => $view]);
1150+
$routeOptions = [...$routeOptions, 'view' => $view];
11511151

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

system/Session/Session.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public function get(?string $key = null)
505505
}
506506

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

510510
$keys = array_keys($_SESSION);
511511

@@ -537,7 +537,7 @@ public function has(string $key): bool
537537
public function push(string $key, array $data)
538538
{
539539
if ($this->has($key) && is_array($value = $this->get($key))) {
540-
$this->set($key, array_merge($value, $data));
540+
$this->set($key, [...$value, ...$data]);
541541
}
542542
}
543543

system/View/Cells/Cell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final protected function view(?string $view, array $data = []): string
7575
{
7676
$properties = $this->getPublicProperties();
7777
$properties = $this->includeComputedProperties($properties);
78-
$properties = array_merge($properties, $data);
78+
$properties = [...$properties, ...$data];
7979

8080
$view = (string) $view;
8181

system/View/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function addRow()
228228
$tmpRow = array_filter($tmpRow, static fn ($k) => array_key_exists($k, $keyIndex), ARRAY_FILTER_USE_KEY);
229229

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

233233
// order keys by $keyIndex values
234234
uksort($tmpRow, static fn ($k1, $k2) => $keyIndex[$k1] <=> $keyIndex[$k2]);

tests/system/API/ResponseTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function makeController(array $userConfig = [], string $routePath = ''
8181
$headers = [
8282
'Accept' => 'text/html',
8383
];
84-
$headers = array_merge($headers, $userHeaders);
84+
$headers = [...$headers, ...$userHeaders];
8585

8686
foreach ($headers as $key => $value) {
8787
$this->request->setHeader($key, $value);

tests/system/HTTP/IncomingRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,8 @@ public function testGetPostSecondStreams(): void
870870
{
871871
$_GET['get'] = '3';
872872
$_POST['post'] = '5';
873-
$this->assertSame(array_merge($_GET, $_POST), $this->request->getPostGet());
874-
$this->assertSame(array_merge($_POST, $_GET), $this->request->getGetPost());
873+
$this->assertSame([...$_GET, ...$_POST], $this->request->getPostGet());
874+
$this->assertSame([...$_POST, ...$_GET], $this->request->getGetPost());
875875
}
876876

877877
public function testGetBodyWithFalseBody(): void

tests/system/Helpers/FilesystemHelperTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,7 @@ public function testDeleteFilesHandlesRecursion(): void
243243

244244
public function testDeleteFilesLeavesHTFiles(): void
245245
{
246-
$structure = array_merge($this->structure, [
247-
'.htaccess' => 'Deny All',
248-
'index.html' => 'foo',
249-
'index.php' => 'blah',
250-
]);
246+
$structure = [...$this->structure, '.htaccess' => 'Deny All', 'index.html' => 'foo', 'index.php' => 'blah'];
251247

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

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

266262
public function testDeleteFilesIncludingHidden(): void
267263
{
268-
$structure = array_merge($this->structure, [
269-
'.htaccess' => 'Deny All',
270-
'index.html' => 'foo',
271-
'index.php' => 'blah',
272-
]);
264+
$structure = [...$this->structure, '.htaccess' => 'Deny All', 'index.html' => 'foo', 'index.php' => 'blah'];
273265

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

tests/system/Router/DefinedRouteCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private function createRouteCollection(array $config = [], $moduleConfig = null)
3030
'Config' => APPPATH . 'Config',
3131
'App' => APPPATH,
3232
];
33-
$config = array_merge($config, $defaults);
33+
$config = [...$config, ...$defaults];
3434

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

tests/system/Router/RouteCollectionReverseRouteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
3939
'Config' => APPPATH . 'Config',
4040
'App' => APPPATH,
4141
];
42-
$config = array_merge($config, $defaults);
42+
$config = [...$config, ...$defaults];
4343

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

tests/system/Router/RouteCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function getCollector(array $config = [], array $files = [], $moduleCo
4242
'Config' => APPPATH . 'Config',
4343
'App' => APPPATH,
4444
];
45-
$config = array_merge($config, $defaults);
45+
$config = [...$config, ...$defaults];
4646

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

0 commit comments

Comments
 (0)