-
-
Notifications
You must be signed in to change notification settings - Fork 152
Fix PHP 7.2 compatibility for PHP 8.4 polyfill #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Conversation
| * @readonly | ||
| * @var ?string | ||
| */ | ||
| public $message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep using typed properties. Attribute classes should not be autoloaded on PHP 7.x anyway as attributes are not supported.
Regarding the readonly keyword, it might make sense to use conditional class definitions to keep them readonly in PHP 8.1+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the problem I had is that Composer's phar compiler is linting the files and that goes boom..
Edit: fixed in https://github.com/composer/composer/pull/12627/files#diff-df7082676f4891241241b23e47108e77b204ff234200bdc4203477d672e1554cR199
Maybe we can merge as is and undo it in #496 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I did some changes.. not a pro here with this conditional def mess, so please review carefully :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The composer compiler already have a list of files excluded from linting to account for the fact that Symfony polyfill packages contain some files loaded conditionally: https://github.com/composer/composer/blob/bfc0e3143841dd156d1099a9c6080e1870b470d2/src/Composer/Compiler.php#L192-L199
That's where the case of typed properties need to be handled IMO (the linter would stick complain about one of the files when using conditional definition files anyway, as the file targeting new PHP versions would still use the new syntaxes)
|
The conditional class using features not supported on PHP 8.0 must be extracted in a separate file that is loaded conditionally. Otherwise, you will still get a parse error on the file (the |
|
Ok I see.. Then I'm not sure I'll find time for this right now if it gets more complex sorry but got a whole lot of other stuff on my plate. |
Closes #551