slimphp / Slim-Skeleton

Slim Framework 4 Skeleton Application
http://www.slimframework.com
MIT License
1.58k stars 477 forks source link

Compatibility with PHP 8.1 #253

Closed itsAnuga closed 2 years ago

itsAnuga commented 2 years ago

Fresh install on a brand new machine, with PHP 8.1 (8.1.11)

> phpunit
PHPUnit 8.5.22 by Sebastian Bergmann and contributors.

PHP Deprecated:  Return type of App\Application\Actions\ActionPayload::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Application/Actions/ActionPayload.php on line 68
R
Deprecated: Return type of App\Application\Actions\ActionPayload::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Application/Actions/ActionPayload.php on line 68
.PHP Deprecated:  Return type of App\Domain\User\User::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Domain/User/User.php on line 80
R
Deprecated: Return type of App\Domain\User\User::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Domain/User/User.php on line 80
.PHP Deprecated:  Return type of App\Application\Actions\ActionError::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Application/Actions/ActionError.php on line 80
R
Deprecated: Return type of App\Application\Actions\ActionError::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Application/Actions/ActionError.php on line 80
..............                                               19 / 19 (100%)

Time: 218 ms, Memory: 8.00 MB

There were 3 risky tests:

1) Tests\Application\Actions\ActionTest::testActionSetsHttpCodeInRespond
This test printed output: 
Deprecated: Return type of App\Application\Actions\ActionPayload::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Application/Actions/ActionPayload.php on line 68

2) Tests\Application\Actions\User\ListUserActionTest::testAction
This test printed output: 
Deprecated: Return type of App\Domain\User\User::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Domain/User/User.php on line 80

3) Tests\Application\Actions\User\ViewUserActionTest::testActionThrowsUserNotFoundException
This test printed output: 
Deprecated: Return type of App\Application\Actions\ActionError::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ./src/Application/Actions/ActionError.php on line 80

OK, but incomplete, skipped, or risky tests!
Tests: 19, Assertions: 37, Risky: 3.

Solved with pull request: https://github.com/slimphp/Slim-Skeleton/pull/252

More information about the suggested solution can be found at: https://php.watch/versions/8.1/ReturnTypeWillChange

itsAnuga commented 2 years ago

Probably the same issue as #250.