-
Notifications
You must be signed in to change notification settings - Fork 504
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
More precise RecursiveIteratorIterator::__construct()
types
#2835
Conversation
This pull request has been marked as ready for review. |
stubs/iterable.stub
Outdated
|
||
/** | ||
* @param T $iterator | ||
* @param int $mode | ||
* @param int $flags | ||
* @param self::LEAVES_ONLY|self::SELF_FIRST|self::CHILD_FIRST $mode |
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'd put this in resources/functionMap_bleedingEdge.php
.
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.
initially I tried that, too. turns out I need a mix of both, as the constants were missing on the stub.
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 don't understand.
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.
in the first iteration of this PR I tried adding it to resources/functionMap_bleedingEdge.php
and did not succeed (without the additional change in iterable stub). now with the PR as is it works
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'm interested in why you didn't succeeed. It should be fine.
b0676ac
to
ff4faed
Compare
phpstan-symfony errors are fixed with phpstan/phpstan-symfony#375 |
* @param int $mode | ||
* @param int $flags |
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.
it seems as soon as I keep these phpdocs here, the signature from resources/functionMap_bleedingEdge.php
does not work, as it starts failling
There was 1 failure:
1) PHPStan\Rules\Classes\InstantiationRuleTest::testBug10324
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'23: Parameter #3 $flags of class RecursiveIteratorIterator constructor expects 0|16, 2 given.
+'
'
/Users/staabm/workspace/phpstan-src/src/Testing/RuleTestCase.php:159
/Users/staabm/workspace/phpstan-src/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php:466
Makes sense now, thank you. |
I had initially implemented it with a separate
StubFilesExtension
to load this more precise signature only in bleedingEdge.later on I realized most iterator implemetations already use pretty narrow $flags/$mode types, therefore I went just with this more precise types.
closes phpstan/phpstan#10324