Skip to content

Commit b96bb1c

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 1c093bd + c42ffa8 commit b96bb1c

144 files changed

Lines changed: 575 additions & 1082 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

admin/starter/tests/unit/HealthTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class HealthTest extends CIUnitTestCase
1111
{
1212
public function testIsDefinedAppPath(): void
1313
{
14-
$this->assertTrue(defined('APPPATH'));
14+
$this->assertDirectoryExists(APPPATH);
1515
}
1616

1717
public function testBaseUrlHasBeenSet(): void

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",
3131
"predis/predis": "^3.0",
32-
"rector/rector": "2.5.8",
32+
"rector/rector": "2.6.1",
3333
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3434
},
3535
"replace": {

phpstan.dist.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ parameters:
1818
- app/Views/errors/html/*
1919
- system/Commands/Generators/Views/*
2020
- system/Debug/Toolbar/Views/toolbar.tpl.php
21-
- system/Images/Handlers/GDHandler.php
2221
- system/Test/Mock/MockCommon.php
2322
- system/ThirdParty/*
2423
- system/Validation/Views/single.php

psalm.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
</projectFiles>
3131

3232
<issueHandlers>
33+
<!-- Psalm does not bring class-level template params into scope for static methods. -->
34+
<NoValue>
35+
<errorLevel type="suppress">
36+
<directory name="system/DataCaster/Cast" />
37+
<directory name="system/Entity/Cast" />
38+
</errorLevel>
39+
</NoValue>
40+
<UndefinedDocblockClass>
41+
<errorLevel type="suppress">
42+
<directory name="system/DataCaster/Cast" />
43+
<directory name="system/Entity/Cast" />
44+
</errorLevel>
45+
</UndefinedDocblockClass>
3346
<UndefinedGlobalVariable>
3447
<errorLevel type="suppress">
3548
<directory name="tests/_support/View/Cells" />

rector.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
2020
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
2121
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
22-
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
2322
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
2423
use Rector\Config\RectorConfig;
2524
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
@@ -33,8 +32,6 @@
3332
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
3433
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
3534
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
36-
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
37-
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
3835
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
3936
use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector;
4037
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
@@ -106,13 +103,6 @@
106103
// Keep property defaults for backward compatibility.
107104
RemoveDefaultValueFromAssignedPropertyRector::class,
108105

109-
ReadOnlyPropertyRector::class => [
110-
__DIR__ . '/system/Cache/ResponseCache.php',
111-
__DIR__ . '/system/HotReloader/IteratorFilter.php',
112-
__DIR__ . '/system/Router/RouteCollection.php',
113-
__DIR__ . '/system/Security/Security.php',
114-
],
115-
116106
// Exclude test file because `is_cli()` is mocked and Rector might remove needed parameters.
117107
RemoveExtraParametersRector::class => [
118108
__DIR__ . '/tests/system/Debug/ToolbarTest.php',
@@ -166,9 +156,6 @@
166156
__DIR__ . '/system/HTTP/SiteURI.php',
167157
],
168158

169-
// Unnecessary (string) is inserted
170-
NullToStrictStringFuncCallArgRector::class,
171-
172159
CompactToVariablesRector::class,
173160

174161
// possibly isset() on purpose, on updated Config classes property across versions
@@ -197,7 +184,6 @@
197184
SimplifyUselessVariableRector::class,
198185
RemoveAlwaysElseRector::class,
199186
PassStrictParameterToFunctionParameterRector::class,
200-
CountArrayToEmptyArrayComparisonRector::class,
201187
ChangeNestedForeachIfsToEarlyContinueRector::class,
202188
ChangeIfElseValueAssignToEarlyReturnRector::class,
203189
PreparedValueToEarlyReturnRector::class,

system/CLI/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public static function getWidth(int $default = 80): int
713713
static::generateDimensions();
714714
}
715715

716-
return static::$width ?: $default;
716+
return (static::$width === null || static::$width === 0) ? $default : static::$width;
717717
}
718718

719719
/**
@@ -725,7 +725,7 @@ public static function getHeight(int $default = 32): int
725725
static::generateDimensions();
726726
}
727727

728-
return static::$height ?: $default;
728+
return (static::$height === null || static::$height === 0) ? $default : static::$height;
729729
}
730730

731731
/**

system/Commands/Utilities/Namespaces.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ private function outputCINamespaces(array $params): array
147147
$pathOutput = $this->truncate(clean_path($path), $maxLength);
148148
}
149149

150-
$path = realpath($path) ?: $path;
150+
$realPath = realpath($path);
151+
$path = $realPath === false ? $path : $realPath;
151152

152153
$tbody[] = [
153154
$ns,

system/Common.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ function clean_path(string $path): string
9797
{
9898
// Resolve relative paths
9999
try {
100-
$path = realpath($path) ?: $path;
100+
$realPath = realpath($path);
101+
$path = $realPath === false ? $path : $realPath;
101102
} catch (ErrorException|ValueError) {
102103
$path = 'error file path: ' . urlencode($path);
103104
}
@@ -1342,7 +1343,11 @@ function class_uses_recursive($class)
13421343
*/
13431344
function trait_uses_recursive($trait)
13441345
{
1345-
$traits = class_uses($trait) ?: [];
1346+
$traits = class_uses($trait);
1347+
1348+
if ($traits === false) {
1349+
return [];
1350+
}
13461351

13471352
foreach ($traits as $trait) {
13481353
$traits += trait_uses_recursive($trait);

system/Config/BaseService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ protected static function getSharedInstance(string $key, ...$params)
273273
public static function autoloader(bool $getShared = true)
274274
{
275275
if ($getShared) {
276-
if (empty(static::$instances['autoloader'])) {
276+
if (! isset(static::$instances['autoloader'])) {
277277
static::$instances['autoloader'] = new Autoloader();
278278
}
279279

@@ -293,7 +293,7 @@ public static function autoloader(bool $getShared = true)
293293
public static function locator(bool $getShared = true)
294294
{
295295
if ($getShared) {
296-
if (empty(static::$instances['locator'])) {
296+
if (! isset(static::$instances['locator'])) {
297297
$cacheEnabled = class_exists(Optimize::class)
298298
&& (new Optimize())->locatorCacheEnabled;
299299

system/Config/DotEnv.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,24 @@ public function parse(): ?array
5959
return null;
6060
}
6161

62-
// Ensure the file is readable
63-
if (! is_readable($this->path)) {
64-
throw new InvalidArgumentException("The .env file is not readable: {$this->path}");
62+
$lines = @file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
63+
64+
// The .env file may have been removed or replaced by a concurrent
65+
// process between the is_file() check above and this read attempt
66+
// (e.g. another test process renaming `.env`). A vanished file is
67+
// treated as absent, so re-check with a fresh stat cache.
68+
if ($lines === false) {
69+
clearstatcache(true, $this->path);
70+
71+
if (is_file($this->path)) {
72+
throw new InvalidArgumentException("The .env file is not readable: {$this->path}");
73+
}
74+
75+
return null;
6576
}
6677

6778
$vars = [];
6879

69-
$lines = file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
70-
7180
foreach ($lines as $line) {
7281
// Is it a comment?
7382
if (str_starts_with(trim($line), '#')) {
@@ -98,11 +107,11 @@ protected function setVariable(string $name, string $value = '')
98107
putenv("{$name}={$value}");
99108
}
100109

101-
if (empty($_ENV[$name])) {
110+
if (! isset($_ENV[$name]) || in_array($_ENV[$name], ['', '0'], true)) {
102111
$_ENV[$name] = $value;
103112
}
104113

105-
if (empty($_SERVER[$name])) {
114+
if (! isset($_SERVER[$name]) || in_array($_SERVER[$name], ['', '0'], true)) {
106115
$_SERVER[$name] = $value;
107116
}
108117
}

0 commit comments

Comments
 (0)