We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
See https://getrector.com/demo/2dc71679-38db-4a2b-be63-51889497e171
<?php use DateTime; final class DemoFile { private DateTime $dateTime; public function __construct(?DateTime $dateTime = null) { $this->dateTime = $dateTime ?? new DateTime(); } } $demo = new DemoFile(null);
NewInInitializerRector
Don't create compilation errors: the constructor cannot be called with a null parameter anymore.
The text was updated successfully, but these errors were encountered:
I think you can simply skip the rule :)
possible improvement is we need to improve the rule to add New_ node to remove null arg when param is new initializer based on target class.
Sorry, something went wrong.
for note, make nullable doesn't make it work since the fallback is if it not have arg at all, ref
Successfully merging a pull request may close this issue.
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/2dc71679-38db-4a2b-be63-51889497e171
Responsible rules
NewInInitializerRector
Expected Behavior
Don't create compilation errors: the constructor cannot be called with a null parameter anymore.
The text was updated successfully, but these errors were encountered: