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
Unset seems to reset the array types #5223
Comments
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<non-empty-string, array<string>> given. Full report
|
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<literal-string&non-empty-string, array<string>> given. Full report
|
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<literal-string&non-empty-string, array<string>> given. Full report
|
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+41: Method HelloWorld::test() is unused. Full report
|
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+19: Parameter #1 $filters of method HelloWorld::test() expects array{categoryKeys: array<string>, tagNames: array<string>}, array<literal-string&non-empty-string, array<string>> given. Full report
|
@alexander-schranz After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+19: Parameter #1 $filters of method HelloWorld::test() expects array{categoryKeys: array<string>, tagNames: array<string>}, array<literal-string&non-empty-string, array<string>> given.
+15: No error to ignore is reported on line 15. Full report
|
@alexander-schranz After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
-15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+17: Offset 'something' does not exist on array<'categoryKeys'|'tagNames', array<string>>.
+19: Parameter #1 $filters of method HelloWorld::test() expects array{categoryKeys: array<string>, tagNames: array<string>}, array<'categoryKeys'|'tagNames', array<string>> given. Full report
|
An unset of an unknown key seems now convert If a unset on an known key is done it is what I expected: Think an unset of unknown key should just do nothing. |
@alexander-schranz After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-15: No error to ignore is reported on line 15.
-19: Parameter #1 $filters of method HelloWorld::test() expects array('categoryKeys' => array<string>, 'tagNames' => array<string>), array<string, array<string>> given.
+17: Offset 'something' does not exist on array{categoryKeys: array<string>, tagNames: array<string>}. Full report
|
@alexander-schranz After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
15: Dumped type: array{categoryKeys: array<string>, tagNames: array<string>, helloWorld: array<string>}
17: Dumped type: array{categoryKeys: array<string>, tagNames: array<string>}
-19: Dumped type: array<'categoryKeys'|'tagNames', array<string>>
-23: Offset 'something' does not exist on array<'categoryKeys'|'tagNames', array<string>>.
-25: Parameter #1 $filters of method HelloWorld::test() expects array{categoryKeys: array<string>, tagNames: array<string>}, array<'categoryKeys'|'tagNames', array<string>> given.
+19: Dumped type: array{categoryKeys: array<string>, tagNames: array<string>}
+23: Offset 'something' does not exist on array{categoryKeys: array<string>, tagNames: array<string>}. Full report
|
/cc @herndlm This one deserves a regression test, it looks fixed by your I think NodescopeResolverTest file with as many assertType calls as possible would work fine. |
* Regression test Closes phpstan/phpstan#5223
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
When an
unset
is called on a typed array the types seems to get lost or replaced by other types.Code snippet that reproduces the problem
https://phpstan.org/r/7f6452ee-c77f-49b0-af7f-d5cca60acef3
Expected output
The example should output no errors.
Did PHPStan help you today? Did it make you happy in any way?
Yes! It does a great Job 👍, thank you.
The text was updated successfully, but these errors were encountered: