PHP 8.4 polyfill for Deprecated attribute is not compatible with PHP 8.0
The PHP 8.4 polyfills have a minimum supported PHP version of PHP 7.2.
In the polyfill code for the Deprecated attribute uses readonly properties, which are only available in PHP 8.1+:
https://github.com/symfony/polyfill-php84/blob/1.x/Resources/stubs/Deprecated.php
I might be missing something, but I have a feeling that this means that using the (polyfilled) #[Deprecated] attribute in code which also needs to run on PHP 8.0 will lead to a parse error when the class is loaded via the Composer classmap: https://3v4l.org/f9oRo
I don't think the class using readonly and typed properties is a problem on PHP 7.2-7.4 as attributes are not supported, so the class will never be loaded anyway (unless manually requested, in which case I'd call that user-error).
Thanks for the report Juliette, we'll have a look at it! BTW, how important is support of PHP < 8.1 to you regarding polyfills? We're having discussions about whether we should bump them to 8.1 minimum. Of course previous versions would still be around for older projects, but if we go with this plan, new polyfills wouldn't run on PHP <= 8.1.
Thanks for the report Juliette, we'll have a look at it!
👍🏻
BTW, how important is support of PHP < 8.1 to you regarding polyfills?
@nicolas-grekas Not for me to say as I wasn't reporting this as a user of the polyfills 😉
I noticed it when I was creating the custom ruleset for PHPCompatibility to prevent false positives when projects use both this polyfill as well as run PHPCompatibility in their CI.
PHPCompatibility flagged this issue and after validating it by checking how the code is wired in, I figured I should report it.
To be honest, I was a bit surprised it wasn't caught by the tests/CI in this repo. Probably means there's room for some additional QA checks.... 😇
We probably need to define the class conditionally. Without readonly on PHP < 8.1 and with readyonly on higher versions. 😓