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
Failing test for #4650 #476
Conversation
You can verify that locally with |
I was trying to test it locally but a lot of the tests failed for some reason. Will try |
That also shouldn't happen :) It's all green on my machine. |
Interesting, doing another |
I feel that this needs more tests to make sure it works as expected. I want to add them, but don't know where. |
That would be sufficient from my perspective :) |
* @phpstan-param non-empty-array<string|int> $idx | ||
*/ | ||
function (array $idx): void { | ||
assertType('bool', $idx === []); |
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.
This should be false obviously
function (array $idx): void { | ||
assertType('bool', $idx === []); | ||
assertNativeType('bool', $idx === []); | ||
assertType('bool', $idx !== []); |
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.
This should be true
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.
Then it fails
1) PHPStan\Analyser\NodeScopeResolverTest::testFileAsserts with data set "/Users/Ruud/opensource/phpstan-src/tests/PHPStan/Analyser/data/bug-4650.php:12" ('type', '/Users/Ruud/opensource/phpsta...50.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\BooleanType Object (), 12)
Expected type false, got type bool in /Users/Ruud/opensource/phpstan-src/tests/PHPStan/Analyser/data/bug-4650.php on line 12.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'false'
+'bool'
/Users/Ruud/opensource/phpstan-src/tests/PHPStan/Analyser/NodeScopeResolverTest.php:11333
2) PHPStan\Analyser\NodeScopeResolverTest::testFileAsserts with data set "/Users/Ruud/opensource/phpstan-src/tests/PHPStan/Analyser/data/bug-4650.php:14" ('type', '/Users/Ruud/opensource/phpsta...50.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\BooleanType Object (), 14)
Expected type true, got type bool in /Users/Ruud/opensource/phpstan-src/tests/PHPStan/Analyser/data/bug-4650.php on line 14.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'true'
+'bool'
It's also why I think that the test is not good enough. Shouldn't it be tested with treatPhpDocTypesAsCertain: false
?
@ondrejmirtes Any advice for this PR? |
I see it now - the problem is that the tested function is an anonymous function, not a named one. It works as expected in a function: https://phpstan.org/r/29929e67-5641-4a4b-8c3d-d58d65bb58d8 PHPDocs above closures are not yet supported. It's best to structure the test in a class + method rather than function as classes can be autoloaded and you don't have to |
Hi @ruudk I'm really interested by this PR, do you have some time to finish it ? :) |
I'll try to have another look at it this week. |
@VincentLanglet Sorry, I won't be fixing this anytime soon. |
Will take a look |
I've modernized the test so that it looks how tests are currently written, but it still fails. |
ca73dcb
to
c0b6593
Compare
Alright, the fix is correct, but the test is failing of unrelated reasons. |
Now it works :) Thanks everyone. |
Thanks 🙌 |
Trying to fix phpstan/phpstan#4650
Let's see if this one test fails, and then try to fix it.