diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 0dbab372484..320f5959f49 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -25,6 +25,7 @@ Yii Framework 2 Change Log - Chg #20465: Remove `PHP_VERSION_ID` checks from web `Session` class (terabytesoftw) - Chg #20464: Remove `PHP_VERSION_ID` checks from web `Response` class (terabytesoftw) - Enh #20511: Allow `jQuery` usage in `View` class while maintaining backward compatibility (terabytesoftw) +- Bug #20518: `PHP` 8.4 fixes for implicit nullability deprecation (terabytesoftw) 2.0.54 under development ------------------------ diff --git a/tests/framework/base/ControllerTest.php b/tests/framework/base/ControllerTest.php index c1ba6023a64..cd5ab33dfad 100644 --- a/tests/framework/base/ControllerTest.php +++ b/tests/framework/base/ControllerTest.php @@ -56,7 +56,7 @@ public function testRunAction(): void public function testCreateInlineAction( string $controllerClass, string $actionId, - string $expectedActionMethod = null + string|null $expectedActionMethod = null ): void { $this->mockApplication(); /** @var Controller $controller */ diff --git a/tests/framework/behaviors/AttributeBehaviorTest.php b/tests/framework/behaviors/AttributeBehaviorTest.php index ae5a32ab5fe..4ef7406dab5 100644 --- a/tests/framework/behaviors/AttributeBehaviorTest.php +++ b/tests/framework/behaviors/AttributeBehaviorTest.php @@ -105,7 +105,7 @@ public function testPreserveNonEmptyValues( string $aliasExpected, bool $preserveNonEmptyValues, string $name, - string $alias = null + string|null $alias = null ): void { $model = new ActiveRecordWithAttributeBehavior(); $model->attributeBehavior->preserveNonEmptyValues = $preserveNonEmptyValues; diff --git a/tests/framework/console/RequestTest.php b/tests/framework/console/RequestTest.php index 343a7eaa281..f1bea0c9a80 100644 --- a/tests/framework/console/RequestTest.php +++ b/tests/framework/console/RequestTest.php @@ -185,7 +185,7 @@ public static function provider(): array * @param array $expected The expected result. * @param array|null $expectedException The expected exception. */ - public function testResolve(array $params, array $expected, array $expectedException = null): void + public function testResolve(array $params, array $expected, array|null $expectedException = null): void { if (isset($expectedException)) { $this->expectException($expectedException[0]); diff --git a/tests/framework/di/ContainerTest.php b/tests/framework/di/ContainerTest.php index f31594034f7..8fea7be062d 100644 --- a/tests/framework/di/ContainerTest.php +++ b/tests/framework/di/ContainerTest.php @@ -236,7 +236,7 @@ public function testOptionalDependencies(): void { $container = new Container(); // Test optional unresolvable dependency. - $closure = fn(QuxInterface $test = null) => $test; + $closure = fn(QuxInterface|null $test = null): QuxInterface|null => $test; $this->assertNull($container->invoke($closure)); } diff --git a/tests/framework/filters/AccessRuleTest.php b/tests/framework/filters/AccessRuleTest.php index ab1e1070f75..aa5e1a098dc 100644 --- a/tests/framework/filters/AccessRuleTest.php +++ b/tests/framework/filters/AccessRuleTest.php @@ -44,7 +44,7 @@ protected function mockRequest(string $method = 'GET'): Request return $request; } - protected function mockUser(string $userid = null): User + protected function mockUser(string|null $userid = null): User { $user = new User([ 'identityClass' => UserIdentity::class, diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 8b6201282fb..93124cbcda5 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -1652,8 +1652,12 @@ function (DynamicModel $model) { /** * @dataProvider errorSummaryDataProvider */ - public function testErrorSummary(string $value, array $options, string $expectedHtml, \Closure $beforeValidate = null): void - { + public function testErrorSummary( + string $value, + array $options, + string $expectedHtml, + \Closure|null $beforeValidate = null + ): void { $model = new HtmlTestModel(); $model->name = $value; if ($beforeValidate !== null) { diff --git a/tests/framework/i18n/FormatterDateTest.php b/tests/framework/i18n/FormatterDateTest.php index 6ee89da5fe8..63546093d50 100644 --- a/tests/framework/i18n/FormatterDateTest.php +++ b/tests/framework/i18n/FormatterDateTest.php @@ -554,7 +554,7 @@ public static function dateInputs() * @param mixed $value * @param mixed|null $expectedException */ - public function testIntlDateInput(string|bool $expected, string $value, string $expectedException = null): void + public function testIntlDateInput(string|bool $expected, string $value, string|null $expectedException = null): void { $this->testDateInput($expected, $value, $expectedException); } @@ -565,7 +565,7 @@ public function testIntlDateInput(string|bool $expected, string $value, string $ * @param mixed $value * @param mixed|null $expectedException */ - public function testDateInput(string|bool $expected, string $value, string $expectedException = null): void + public function testDateInput(string|bool $expected, string $value, string|null $expectedException = null): void { if ($expectedException !== null) { $this->expectException($expectedException); diff --git a/tests/framework/rest/IndexActionTest.php b/tests/framework/rest/IndexActionTest.php index 8056d851dc4..ea0313c97e1 100644 --- a/tests/framework/rest/IndexActionTest.php +++ b/tests/framework/rest/IndexActionTest.php @@ -75,12 +75,12 @@ public function testPrepareSearchQueryAttribute(): void * @param string $expectedRawSql */ public function testPrepareDataProviderWithPaginationAndSorting( - \yii\data\Pagination|bool|array $pagination, - \yii\data\Sort|bool|array $sort, - int $expectedPaginationPageSize = null, - int $expectedPaginationDefaultPageSize = null, + Pagination|bool|array $pagination, + Sort|bool|array $sort, + int|null $expectedPaginationPageSize = null, + int|null $expectedPaginationDefaultPageSize = null, array $expectedSortOrders = [], - ?array $expectedSortDefaultOrder = null + array|null $expectedSortDefaultOrder = null ): void { Yii::$app->getRequest()->setBodyParams([ 'per-page' => 11, diff --git a/tests/framework/web/AssetBundleTest.php b/tests/framework/web/AssetBundleTest.php index 85d5362f142..f0ad8948ac9 100644 --- a/tests/framework/web/AssetBundleTest.php +++ b/tests/framework/web/AssetBundleTest.php @@ -509,8 +509,13 @@ public static function registerFileDataProvider() * @param string|bool $appendTimestamp * @param string|null $webAlias */ - public function testRegisterFileAppendTimestamp(string $type, string $path, bool $appendTimestamp, string $expected, string $webAlias = null): void - { + public function testRegisterFileAppendTimestamp( + string $type, + string $path, + bool $appendTimestamp, + string $expected, + string|null $webAlias = null, + ): void { $originalAlias = Yii::getAlias('@web'); if ($webAlias === null) { $webAlias = $originalAlias;