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
TypeSpecifier - support specifying variable types in Assign #3106
Comments
Until the bug will be fixed, additional type-hint can help: |
Very strange is, that when you want just echo the variable Unfortunately when you want to assign it somewhere, it still not work |
But when you move the check elsewhere, it is always array :))) |
@zeleznypa PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.0 (1 error)
+==========
+
+25: Parameter #2 $array of function array_key_exists expects array, array<int, string>|null given.
+
+PHP 7.1 – 7.4 (1 error)
+==========
+
25: Parameter #2 $search of function array_key_exists expects array, array<int, string>|null given. |
@zeleznypa PHPStan now reports different result with your code snippet: @@ @@
-No errors
+27: PHPDoc tag @var for variable $match has no value type specified in iterable type array. Full report
|
@zeleznypa PHPStan now reports different result with your code snippet: @@ @@
-30: Offset 1 does not exist on array<int, string>|null.
30: PHPDoc tag @var for variable $match has no value type specified in iterable type array. Full report
|
@zeleznypa PHPStan now reports different result with your code snippet: @@ @@
-25: Parameter #2 $search of function array_key_exists expects array, array<int, string>|null given.
+PHP 8.0 (3 errors)
+==========
+
+ 6: Property Foo::$expression has no typehint specified.
+11: Method Foo::match() return type has no value type specified in iterable type array.
+25: Parameter #2 $search of function array_key_exists expects array, array|null given.
+
+PHP 7.4 (3 errors)
+==========
+
+ 6: Property Foo::$expression has no typehint specified.
+11: Method Foo::match() return type has no value type specified in iterable type array.
+25: Parameter #2 $array of function array_key_exists expects array, array|null given.
+
+PHP 7.1 – 7.3 (3 errors)
+==========
+
+ 6: Property Foo::$expression has no typehint specified.
+11: Method Foo::match() return type has no value type specified in iterable type array.
+25: Parameter #2 $search of function array_key_exists expects array, array|null given. Full reportPHP 8.0 (3 errors)
PHP 7.4 (3 errors)
PHP 7.1 – 7.3 (3 errors)
|
@zeleznypa After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-25: Parameter #2 $search of function array_key_exists expects array, array<int, string>|null given.
+No errors |
Fixed: phpstan/phpstan-src@b2bf703 |
Closes phpstan/phpstan#4761 Closes phpstan/phpstan#3331 Closes phpstan/phpstan#3106 Closes phpstan/phpstan#2640 Closes phpstan/phpstan#2413 Closes phpstan/phpstan#3446
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. |
When the return type of method is
array|null
and I check it viais_array
, I want to use it asarray
.https://phpstan.org/r/c32ca1b7-b1e8-42c0-9bfd-56ba031b887c
The text was updated successfully, but these errors were encountered: