[Feature] Add 3 new rectors for fixing incorrect null type in @var, @param and @return #2049
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, here are 3 rectors which I wanted to share. I have added them to the
TypeDeclaration
directory but if there is a better place please let me know.null
type from@param
phpdoc typehint based on php parameter type declarationnull
type from@return
phpdoc typehint based on php return type declarationnull
type from@var
phpdoc typehint based on php property type declarationSome background info: Basically we had a lot of these problems in our project where the phpdocs were incorrect, ie the php type was nullable, for example
?array
but the php doc said it was simplySomeObject[]
, notSomeObject[]|null
as it should. Or vice versa, the phpdoc stated it wasSomeObject[]|null
but it was actually non nullablearray
type. Among other things, this was then confusing phpstan and leading to all sorts of problems. These 3 rector rules solved this problem for us.