-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
ExplicitNullableParamTypeRector
can be applied from PHP 7.1
#5848
Conversation
@@ -75,6 +75,6 @@ public function refactor(Node $node): ?Param | |||
|
|||
public function provideMinPhpVersion(): int | |||
{ | |||
return PhpVersionFeature::DEPRECATE_IMPLICIT_NULLABLE_PARAM_TYPE; |
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.
This constant becomes unused, but is part of the API, I don't know if you want to keep it.
Here's how I used this rule to create this PR felixfbecker/php-language-server-protocol#22 Install rector: Setup the config with only one rule: <?php
return Rector\Config\RectorConfig::configure()
->withPaths([__DIR__ . '/src'])
->withRules([Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector::class]); And run Without change, nothing is fixed since the project requires |
I don't want to enforce something that not deprecated to begin with, so it needs to be php 8.4. Feel free to copy and modify as your own custom rule. Thank you for understanding. |
Please read my comment. The rule can't be applied to projects that support PHP 8.4. Maybe there is an other solution to allow using this rule without enforcing it. |
Php 8.4 is not yet released, however, you should can enforce via config: ->withPhpVersion(PhpVersion::PHP_84) |
Ok, thanks for that clarification. |
No worries, btw, the better way is to create new release and new compatible code once php 8.4 released, that's ensure nothing left behind, and not accidentally applied syntax that not yet supported. |
The "new" syntax is supported since PHP 7.1, which is 8 years old. Most of the actively supported libraries already dropped older PHP versions. |
I wrote a tutorial for those concerned: https://dev.to/gromnan/fix-php-84-deprecation-implicitly-marking-parameter-as-nullable-is-deprecated-the-explicit-nullable-type-must-be-used-instead-5gp3 |
PHP 8.4 deprecates implicit nullable parameters, but the transformation can be applied with PHP 7.1+ compatibility.
This change is necessary in order to use the
ExplicitNullableParamTypeRector
with projects that allows PHP < 8.3 (i.e. all projects that currently exist), to make them compatible with PHP 8.4.