Skip to content

Commit dc9adb1

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
Conflicts: system/Filters/Filters.php
2 parents 3dffbc9 + 1638990 commit dc9adb1

File tree

30 files changed

+192
-112
lines changed

30 files changed

+192
-112
lines changed

app/Config/Events.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Events::on('create', [$myInstance, 'myMethod']);
2424
*/
2525

26-
Events::on('pre_system', static function () {
26+
Events::on('pre_system', static function (): void {
2727
if (ENVIRONMENT !== 'testing') {
2828
if (ini_get('zlib.output_compression')) {
2929
throw FrameworkException::forEnabledZlibOutputCompression();
@@ -47,7 +47,7 @@
4747
Services::toolbar()->respond();
4848
// Hot Reload route - for framework use on the hot reloader.
4949
if (ENVIRONMENT === 'development') {
50-
Services::routes()->get('__hot-reload', static function () {
50+
Services::routes()->get('__hot-reload', static function (): void {
5151
(new HotReloader())->run();
5252
});
5353
}

rector.php

Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -53,49 +53,44 @@
5353
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
5454
use Rector\PHPUnit\Set\PHPUnitSetList;
5555
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
56-
use Rector\Set\ValueObject\LevelSetList;
57-
use Rector\Set\ValueObject\SetList;
5856
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
5957
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
6058
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
59+
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
6160
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
6261
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
6362
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
6463
use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector;
6564
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
6665

67-
return static function (RectorConfig $rectorConfig): void {
68-
$rectorConfig->sets([
69-
SetList::DEAD_CODE,
70-
LevelSetList::UP_TO_PHP_81,
66+
return RectorConfig::configure()
67+
->withPhpSets(php81: true)
68+
->withPreparedSets(deadCode: true)
69+
->withSets([
7170
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
7271
PHPUnitSetList::PHPUNIT_100,
73-
]);
74-
75-
$rectorConfig->parallel(120, 8, 10);
76-
77-
// Github action cache
78-
$rectorConfig->cacheClass(FileCacheStorage::class);
79-
if (is_dir('/tmp')) {
80-
$rectorConfig->cacheDirectory('/tmp/rector');
81-
}
82-
72+
])
73+
->withParallel(120, 8, 10)
74+
->withCache(
75+
// Github action cache or local
76+
is_dir('/tmp') ? '/tmp/rector' : null,
77+
FileCacheStorage::class
78+
)
8379
// paths to refactor; solid alternative to CLI arguments
84-
$rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']);
85-
80+
->withPaths(
81+
[__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']
82+
)
8683
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
87-
$rectorConfig->bootstrapFiles([
84+
->withBootstrapFiles([
8885
__DIR__ . '/system/Test/bootstrap.php',
89-
]);
90-
91-
$rectorConfig->phpstanConfigs([
86+
])
87+
->withPHPStanConfigs([
9288
__DIR__ . '/phpstan.neon.dist',
9389
__DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon',
9490
__DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
95-
]);
96-
91+
])
9792
// is there a file you need to skip?
98-
$rectorConfig->skip([
93+
->withSkip([
9994
__DIR__ . '/system/Debug/Toolbar/Views/toolbar.tpl.php',
10095
__DIR__ . '/system/ThirdParty',
10196
__DIR__ . '/tests/system/Config/fixtures',
@@ -187,48 +182,45 @@
187182
AnnotationWithValueToAttributeRector::class,
188183
AnnotationToAttributeRector::class,
189184
CoversAnnotationWithValueToAttributeRector::class,
190-
]);
191-
185+
])
192186
// auto import fully qualified class names
193-
$rectorConfig->importNames();
194-
$rectorConfig->removeUnusedImports();
195-
196-
$rectorConfig->rule(DeclareStrictTypesRector::class);
197-
$rectorConfig->rule(UnderscoreToCamelCaseVariableNameRector::class);
198-
$rectorConfig->rule(SimplifyUselessVariableRector::class);
199-
$rectorConfig->rule(RemoveAlwaysElseRector::class);
200-
$rectorConfig->rule(PassStrictParameterToFunctionParameterRector::class);
201-
$rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
202-
$rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class);
203-
$rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class);
204-
$rectorConfig->rule(SimplifyStrposLowerRector::class);
205-
$rectorConfig->rule(CombineIfRector::class);
206-
$rectorConfig->rule(SimplifyIfReturnBoolRector::class);
207-
$rectorConfig->rule(InlineIfToExplicitIfRector::class);
208-
$rectorConfig->rule(PreparedValueToEarlyReturnRector::class);
209-
$rectorConfig->rule(ShortenElseIfRector::class);
210-
$rectorConfig->rule(SimplifyIfElseToTernaryRector::class);
211-
$rectorConfig->rule(UnusedForeachValueToArrayKeysRector::class);
212-
$rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class);
213-
$rectorConfig->rule(UnnecessaryTernaryExpressionRector::class);
214-
$rectorConfig->rule(RemoveErrorSuppressInTryCatchStmtsRector::class);
215-
$rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
216-
$rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
217-
$rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
218-
$rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class);
219-
$rectorConfig->rule(TernaryEmptyArrayArrayDimFetchToCoalesceRector::class);
220-
$rectorConfig->rule(EmptyOnNullableObjectToInstanceOfRector::class);
221-
$rectorConfig->rule(DisallowedEmptyRuleFixerRector::class);
222-
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
223-
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
224-
$rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class);
225-
$rectorConfig->rule(SingleInArrayToCompareRector::class);
226-
$rectorConfig->rule(VersionCompareFuncCallToConstantRector::class);
227-
$rectorConfig->rule(ExplicitBoolCompareRector::class);
228-
229-
$rectorConfig
230-
->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [
231-
// keep '\\' prefix string on string '\Foo\Bar'
232-
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
233-
]);
234-
};
187+
->withImportNames(removeUnusedImports: true)
188+
->withRules([
189+
DeclareStrictTypesRector::class,
190+
UnderscoreToCamelCaseVariableNameRector::class,
191+
SimplifyUselessVariableRector::class,
192+
RemoveAlwaysElseRector::class,
193+
PassStrictParameterToFunctionParameterRector::class,
194+
CountArrayToEmptyArrayComparisonRector::class,
195+
ChangeNestedForeachIfsToEarlyContinueRector::class,
196+
ChangeIfElseValueAssignToEarlyReturnRector::class,
197+
SimplifyStrposLowerRector::class,
198+
CombineIfRector::class,
199+
SimplifyIfReturnBoolRector::class,
200+
InlineIfToExplicitIfRector::class,
201+
PreparedValueToEarlyReturnRector::class,
202+
ShortenElseIfRector::class,
203+
SimplifyIfElseToTernaryRector::class,
204+
UnusedForeachValueToArrayKeysRector::class,
205+
ChangeArrayPushToArrayAssignRector::class,
206+
UnnecessaryTernaryExpressionRector::class,
207+
RemoveErrorSuppressInTryCatchStmtsRector::class,
208+
FuncGetArgsToVariadicParamRector::class,
209+
MakeInheritedMethodVisibilitySameAsParentRector::class,
210+
SimplifyEmptyArrayCheckRector::class,
211+
SimplifyEmptyCheckOnEmptyArrayRector::class,
212+
TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
213+
EmptyOnNullableObjectToInstanceOfRector::class,
214+
DisallowedEmptyRuleFixerRector::class,
215+
PrivatizeFinalClassPropertyRector::class,
216+
CompleteDynamicPropertiesRector::class,
217+
BooleanInIfConditionRuleFixerRector::class,
218+
SingleInArrayToCompareRector::class,
219+
VersionCompareFuncCallToConstantRector::class,
220+
ExplicitBoolCompareRector::class,
221+
AddClosureVoidReturnTypeWhereNoReturnRector::class,
222+
])
223+
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
224+
// keep '\\' prefix string on string '\Foo\Bar'
225+
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
226+
]);

system/Autoloader/Autoloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ private function autoloadKint(): void
507507
{
508508
// If we have KINT_DIR it means it's already loaded via composer
509509
if (! defined('KINT_DIR')) {
510-
spl_autoload_register(function ($class) {
510+
spl_autoload_register(function ($class): void {
511511
$class = explode('\\', $class);
512512

513513
if (array_shift($class) !== 'Kint') {

system/CLI/BaseCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function showHelp()
163163
if ($this->arguments !== []) {
164164
CLI::newLine();
165165
CLI::write(lang('CLI.helpArguments'), 'yellow');
166-
$length = max(array_map('strlen', array_keys($this->arguments)));
166+
$length = max(array_map(strlen(...), array_keys($this->arguments)));
167167

168168
foreach ($this->arguments as $argument => $description) {
169169
CLI::write(CLI::color($this->setPad($argument, $length, 2, 2), 'green') . $description);
@@ -173,7 +173,7 @@ public function showHelp()
173173
if ($this->options !== []) {
174174
CLI::newLine();
175175
CLI::write(lang('CLI.helpOptions'), 'yellow');
176-
$length = max(array_map('strlen', array_keys($this->options)));
176+
$length = max(array_map(strlen(...), array_keys($this->options)));
177177

178178
foreach ($this->options as $option => $description) {
179179
CLI::write(CLI::color($this->setPad($option, $length, 2, 2), 'green') . $description);

system/CLI/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ private static function isZeroOptions(array $options): void
393393
private static function printKeysAndValues(array $options): void
394394
{
395395
// +2 for the square brackets around the key
396-
$keyMaxLength = max(array_map('mb_strwidth', array_keys($options))) + 2;
396+
$keyMaxLength = max(array_map(mb_strwidth(...), array_keys($options))) + 2;
397397

398398
foreach ($options as $key => $description) {
399399
$name = str_pad(' [' . $key . '] ', $keyMaxLength + 4, ' ');
@@ -857,7 +857,7 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft =
857857

858858
$first = true;
859859

860-
array_walk($lines, static function (&$line) use ($padLeft, &$first) {
860+
array_walk($lines, static function (&$line) use ($padLeft, &$first): void {
861861
if (! $first) {
862862
$line = str_repeat(' ', $padLeft) . $line;
863863
} else {

system/CLI/GeneratorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private function normalizeInputClassName(): string
325325
implode(
326326
'\\',
327327
array_map(
328-
'pascalize',
328+
pascalize(...),
329329
explode('\\', str_replace('/', '\\', trim($class)))
330330
)
331331
),

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private function autoloadKint(): void
253253
{
254254
// If we have KINT_DIR it means it's already loaded via composer
255255
if (! defined('KINT_DIR')) {
256-
spl_autoload_register(function ($class) {
256+
spl_autoload_register(function ($class): void {
257257
$class = explode('\\', $class);
258258

259259
if (array_shift($class) !== 'Kint') {

system/Commands/ListCommands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function listFull(array $commands)
101101
$groups[$command['group']][$title] = $command;
102102
}
103103

104-
$length = max(array_map('strlen', array_keys($commands)));
104+
$length = max(array_map(strlen(...), array_keys($commands)));
105105

106106
ksort($groups);
107107

system/Commands/Utilities/Routes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public function run(array $params)
119119
$route['route'],
120120
$routeName,
121121
$route['handler'],
122-
implode(' ', array_map('class_basename', $filters['before'])),
123-
implode(' ', array_map('class_basename', $filters['after'])),
122+
implode(' ', array_map(class_basename(...), $filters['before'])),
123+
implode(' ', array_map(class_basename(...), $filters['after'])),
124124
];
125125
}
126126

@@ -166,8 +166,8 @@ public function run(array $params)
166166
// There is no `AUTO` method, but it is intentional not to get route filters.
167167
$filters = $filterCollector->get('AUTO', $uriGenerator->get($routes[1]));
168168

169-
$routes[] = implode(' ', array_map('class_basename', $filters['before']));
170-
$routes[] = implode(' ', array_map('class_basename', $filters['after']));
169+
$routes[] = implode(' ', array_map(class_basename(...), $filters['before']));
170+
$routes[] = implode(' ', array_map(class_basename(...), $filters['after']));
171171
}
172172
}
173173

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ private function addFilters($routes)
125125
$filters['before'] = array_intersect($filtersLongest['before'], $filtersShortest['before']);
126126
$filters['after'] = array_intersect($filtersLongest['after'], $filtersShortest['after']);
127127

128-
$route['before'] = implode(' ', array_map('class_basename', $filters['before']));
129-
$route['after'] = implode(' ', array_map('class_basename', $filters['after']));
128+
$route['before'] = implode(' ', array_map(class_basename(...), $filters['before']));
129+
$route['after'] = implode(' ', array_map(class_basename(...), $filters['after']));
130130
}
131131

132132
return $routes;

system/Cookie/Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function getPrefixedName(): string
283283
$name .= $this->getName();
284284
} else {
285285
$search = str_split(self::$reservedCharsList);
286-
$replace = array_map('rawurlencode', $search);
286+
$replace = array_map(rawurlencode(...), $search);
287287

288288
$name .= str_replace($search, $replace, $this->getName());
289289
}

system/DataCaster/DataCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function castAs(mixed $value, string $field, string $method = 'get'): mix
156156
// type[param, param2,param3]
157157
if (preg_match('/\A(.+)\[(.+)\]\z/', $type, $matches)) {
158158
$type = $matches[1];
159-
$params = array_map('trim', explode(',', $matches[2]));
159+
$params = array_map(trim(...), explode(',', $matches[2]));
160160
}
161161

162162
if ($isNullable && ! $this->strict) {

system/DataConverter/DataConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function reconstruct(string $classname, array $row): object
140140
return $classObj;
141141
}
142142

143-
$classSet = Closure::bind(function ($key, $value) {
143+
$classSet = Closure::bind(function ($key, $value): void {
144144
$this->{$key} = $value;
145145
}, $classObj, $classname);
146146

system/Database/BaseConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ public function tableExists(string $tableName, bool $cached = true): bool
15291529
if (! empty($this->dataCache['table_names'])) {
15301530
$key = array_search(
15311531
strtolower($tableName),
1532-
array_map('strtolower', $this->dataCache['table_names']),
1532+
array_map(strtolower(...), $this->dataCache['table_names']),
15331533
true
15341534
);
15351535

system/Database/Forge.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public function dropDatabase(string $dbName): bool
306306
if (! empty($this->db->dataCache['db_names'])) {
307307
$key = array_search(
308308
strtolower($dbName),
309-
array_map('strtolower', $this->db->dataCache['db_names']),
309+
array_map(strtolower(...), $this->db->dataCache['db_names']),
310310
true
311311
);
312312
if ($key !== false) {
@@ -667,7 +667,7 @@ public function dropTable(string $tableName, bool $ifExists = false, bool $casca
667667
if ($query && ! empty($this->db->dataCache['table_names'])) {
668668
$key = array_search(
669669
strtolower($this->db->DBPrefix . $tableName),
670-
array_map('strtolower', $this->db->dataCache['table_names']),
670+
array_map(strtolower(...), $this->db->dataCache['table_names']),
671671
true
672672
);
673673

@@ -729,7 +729,7 @@ public function renameTable(string $tableName, string $newTableName)
729729
if ($result && ! empty($this->db->dataCache['table_names'])) {
730730
$key = array_search(
731731
strtolower($this->db->DBPrefix . $tableName),
732-
array_map('strtolower', $this->db->dataCache['table_names']),
732+
array_map(strtolower(...), $this->db->dataCache['table_names']),
733733
true
734734
);
735735

system/Database/MigrationRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ public function getBatches(): array
686686
->get()
687687
->getResultArray();
688688

689-
return array_map('intval', array_column($batches, 'batch'));
689+
return array_map(intval(...), array_column($batches, 'batch'));
690690
}
691691

692692
/**

system/Database/OCI8/Connection.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,24 @@ class Connection extends BaseConnection
5353
];
5454

5555
protected $validDSNs = [
56-
'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS
57-
// Easy Connect string (Oracle 10g+)
58-
'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i',
59-
'in' => '/^[a-z0-9$_]+$/i', // Instance name (defined in tnsnames.ora)
56+
// TNS
57+
'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/',
58+
// Easy Connect string (Oracle 10g+).
59+
// https://docs.oracle.com/en/database/oracle/oracle-database/23/netag/configuring-naming-methods.html#GUID-36F3A17D-843C-490A-8A23-FB0FE005F8E8
60+
// [//]host[:port][/[service_name][:server_type][/instance_name]]
61+
'ec' => '/^
62+
(\/\/)?
63+
(\[)?[a-z0-9.:_-]+(\])? # Host or IP address
64+
(:[1-9][0-9]{0,4})? # Port
65+
(
66+
(\/)
67+
([a-z0-9.$_]+)? # Service name
68+
(:[a-z]+)? # Server type
69+
(\/[a-z0-9$_]+)? # Instance name
70+
)?
71+
$/ix',
72+
// Instance name (defined in tnsnames.ora)
73+
'in' => '/^[a-z0-9$_]+$/i',
6074
];
6175

6276
/**

system/Database/OCI8/Forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected function _processColumn(array $processedField): string
202202
$constraint = ' CHECK(' . $this->db->escapeIdentifiers($processedField['name'])
203203
. ' IN ' . $processedField['length'] . ')';
204204

205-
$processedField['length'] = '(' . max(array_map('mb_strlen', explode("','", mb_substr($processedField['length'], 2, -2)))) . ')' . $constraint;
205+
$processedField['length'] = '(' . max(array_map(mb_strlen(...), explode("','", mb_substr($processedField['length'], 2, -2)))) . ')' . $constraint;
206206
} elseif (isset($this->primaryKeys['fields']) && count($this->primaryKeys['fields']) === 1 && $processedField['name'] === $this->primaryKeys['fields'][0]) {
207207
$processedField['unique'] = '';
208208
}

0 commit comments

Comments
 (0)