thecodingmachine / safe

All PHP functions, rewritten to throw exceptions instead of returning false
MIT License
2.37k stars 149 forks source link

PHP 8.4 - Implicit nullability deprecation #442

Closed Ayesh closed 2 days ago

Ayesh commented 8 months ago

PHP 8.4 recently merged changes to emit a deprecation notice on function declared with an implicit nullable type.

All upstream functions in php-src already have the nullable types (?string $var = null and not string $var = null), so we will need to update our generator to account for this.

I submitted PR #441 to preview the expected changes.

sebastianbergmann commented 4 days ago

This library is used by @theofidry's php-scoper tool which is used in the release process of PHPUnit.

When I use php-scoper with PHP 8.4 then I get

PHP Fatal error:  Uncaught ErrorException: _HumbugBoxf238c5c0abfa\Safe\gmdate(): Implicitly marking parameter $timestamp as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/src/phpunit/tools/php-scoper/vendor/thecodingmachine/safe/deprecated/datetime.php:6

There must be an error handler, either in this library or in php-scoper, that escalates the deprecation to a fatal error.

TL;DR: As of right, I cannot release new versions of PHPUnit using PHP 8.4 due to this library not being compatible with PHP 8.4.

staabm commented 2 days ago

@sebastianbergmann @theofidry looking at thecodingmachine/safe repo I can't see a error handler.

since PHPUnit got new releases I guess this problem got somehow fixed for you?

staabm commented 2 days ago

the OPs problem got fixed by

sebastianbergmann commented 2 days ago

since PHPUnit got new releases I guess this problem got somehow fixed for you?

I downgraded PHP to roll the release of PHPUnit 11.4.4.