Roave / BetterReflection

:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
MIT License
1.18k stars 131 forks source link

ReflectionClass::IS_READONLY is a typed class constant in PHP 8.4 #1440

Closed kocsismate closed 1 month ago

kocsismate commented 1 month ago

PHP 8.4 made the ReflectionClass::IS_READONLY class constant typed in https://github.com/php/php-src/pull/12378. Since Roave\BetterReflection\Reflection\Adapter\ReflectionClass overrides it, the following exception is thrown when using PHP 8.4:

Type of Roave\BetterReflection\Reflection\Adapter\ReflectionClass::IS_READONLY must be compatible with ReflectionClass::IS_READONLY of type int
Ocramius commented 1 month ago

@kocsismate can we safely add int to these types, even for versions before 8.4?

kocsismate commented 1 month ago

@Ocramius No unfortunately, typed class constants were only added in PHP 8.3... So somehow the issue should be circumvented 🤔 Baiscally, PHPStan has the same BC problem with their forked version: https://github.com/phpstan/phpstan/issues/10182

Ocramius commented 1 month ago

I think we can safely rename the constant to something else then: https://github.com/Roave/BetterReflection/commit/a4e5618c5907c00e9315e8d3b3547d8c8679a4e9

We'd also mark it @internal