-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Support @immutable phpdoc in RestoreDefaultNullToNullableTypePropertyRector #5795
Conversation
|
||
/** | ||
* @immutable | ||
*/ |
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 never use Immutable attribute, but found in a project, is it possible to skip:
#[\JetBrains\PhpStorm\Immutable]
and is that correct to skip that as well?
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.
my motivation to skip the phpdoc attribute is related to it beeing supported by phpstan.
(the rector rule when applied on classes tagged with @immutable
will result in phpstan errors)
the jetbrains annotation is not supported by phpstan AFAIK, therefore not part of this PR.
I think it would be correct to support it in rector, if/when phpstan supports it
Thank you @staabm |
|
||
// @immutable annotation | ||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); | ||
$tags = $phpDocInfo->getTagsByName('@immutable'); |
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 am on mobile, hasByName()
should actually can be used
public function hasByName(string $name): bool |
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.
here you are: #5797
RestoreDefaultNullToNullableTypePropertyRector
already supports a@readonly
property-level phpdoc. therefore I figured it should also support the class level@immutable
which is equivalent to the nativereadonly
class-level keyword