-
-
Notifications
You must be signed in to change notification settings - Fork 687
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
[Downgrade PHP 7.4] Contravariant arguments #4164
Comments
To downgrade it, we only need to replicate the same argument types from the parent, without double-checking if these are contravariant (i.e. if the type in the child class is a parent to the type in the parent class). That's because it must be contravariant, or otherwise it will already fail for PHP 7.4. The rule will be similar to |
Actually, this is more complicated than I mentioned in my previous comment: the change would need to be done on the parent class, not on the child class! That's because the child class will have a more generic argument type, so it can't be reduced to the more specific one from the parent class, or invocations passing that more generic type will fail. A possible solution is to completely remove the parameter type from the child class, which is called Parameter type widening. However this works starting from PHP 7.2 only. To make it work with PHP 7.1 and below, we can directly remove the parameter types on both the parent and child methods, replacing them with phpdocs. |
Should make sure if there is a proper solution for #4754, and implement it, before tackling this issue |
Solution: remove the type completely, switching from covariant argument type, to parameter type widening. Then, this latter feature can be downgraded for PHP 7.2 through new rule |
rectorphp/rector-src@f7b43d4 Performance: Prevent sorting of files in PhpFilesFinder (#4164)
Feature Request
Downgrade new feature from PHP 7.4 to its equivalent PHP 7.3 code
Diff
The text was updated successfully, but these errors were encountered: