Skip to content
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

Extract ConstructorsHelper #1328

Merged
merged 2 commits into from
May 20, 2022

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented May 18, 2022

... and make use of it also in ReadOnlyByPhpDocPropertyAssignRule and ReadOnlyPropertyAssignRule.

Closes phpstan/phpstan#6612

@herndlm herndlm force-pushed the extract-constructors-helper branch from d79d843 to 098c178 Compare May 18, 2022 20:39
@herndlm herndlm marked this pull request as ready for review May 18, 2022 20:46
@ondrejmirtes
Copy link
Member

Does it solve phpstan/phpstan#6612 ? :)

@herndlm
Copy link
Contributor Author

herndlm commented May 18, 2022

Does it solve phpstan/phpstan#6612 ? :)

not yet, I thought of another PR. but can do that here too for sure :)

@ondrejmirtes
Copy link
Member

Yeah, sure, this makes sense as a logical first step, you can add a 2nd commit that uses the new helper in a new place :)

@herndlm herndlm marked this pull request as draft May 18, 2022 21:32
@herndlm herndlm force-pushed the extract-constructors-helper branch from 822138d to 5870e1c Compare May 18, 2022 21:33
@herndlm herndlm marked this pull request as ready for review May 18, 2022 21:39
@herndlm herndlm force-pushed the extract-constructors-helper branch from 5870e1c to a6bb5e1 Compare May 20, 2022 13:27
@ondrejmirtes ondrejmirtes merged commit 57695e1 into phpstan:1.7.x May 20, 2022
@ondrejmirtes
Copy link
Member

Perfect, thank you!

BTW About the @readonly PHPDoc feature - I realized we should do one more thing - if there's @immutable, @phpstan-immutable, or @psalm-immutable above the class, isReadOnlyByPhpDoc for a property should also return true.

@herndlm herndlm deleted the extract-constructors-helper branch May 20, 2022 14:45
@herndlm
Copy link
Contributor Author

herndlm commented May 20, 2022

BTW About the @readonly PHPDoc feature - I realized we should do one more thing - if there's @immutable, @phpstan-immutable, or @psalm-immutable above the class, isReadOnlyByPhpDoc for a property should also return true.

That was basically my follow-up idea! (I think I hinted it in the original PR description) ;) Then I found https://wiki.php.net/rfc/readonly_classes though and wanted to ask if this (@readonly on the class) should be supported too in the same way maybe? I need to read that in detail again, but I guess more rule adaptions or new rules are needed for that native readonly feature later for PHP 8.2. But different thing now, I guess.

@ondrejmirtes
Copy link
Member

That RFC is unrelated to what we need to do here.

I'll work on 8.2 support after feature freeze. And my guess is that not a single line of code will need to be changed in PHPStan, only in BetterReflection 😊

@herndlm
Copy link
Contributor Author

herndlm commented May 20, 2022

OK, I'll add immutable support later, should be super-easy now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReadOnlyPropertyAssignRule does not respect additionalConstructors setting
2 participants