Conversation
|
Type inference is best tested like this (the part with |
No, isn't necessary. |
This reverts commit 7e5a1e7
| { | ||
| public function withoutGenerics(): void | ||
| { | ||
| /** @var list $list */ |
There was a problem hiding this comment.
You should at least once typehint the type as method parameter and assert it right at the beginning of the body. If you assert the variable only after some changes (array appending), you have no guarantees about the state right after $list = [];.
There was a problem hiding this comment.
Ok, I added some test cases with direct assertions. It should be ok
|
Otherwise perfect! Thank you. |
|
Please get rid of the merge commits and rebase it onto master. I'm not able to wrap my head around this Git history. Thank you. |
|
It'd probably be easiest to start a new branch and just do all the changes in a single commit. |
Yeah, I'll probably do that. I'm not really an expert with git! |
As discussed in phpstan/phpstan/issues/2788, this PR implements the notations
listandlist<Foo>as aliases of respectivelyarray<int, mixed>andarray<int, Foo>I added some tests on ReturnTypeRuleTest.php but I'm not sure it was the best place to put them. Please tell me if it shoud be located elsewhere or if it's missing tests.
Also, should I try to add some tests in https://github.com/phpstan/phpdoc-parser to ensure those notations will stay stable?