-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
array shapes are not taken into account to exclude incorrect combinations for false positives #6633
Comments
Changing it to functions also doesn't help: https://phpstan.org/r/fc02ccfe-c21d-4885-a38b-f1509f8ec1fa Also forgot to note that this may be related to either #6364 or #3616 |
@Kingdutch After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 – 8.1 (1 error)
==========
-68: Parameter #1 $data of callable (Closure(CreateServiceSolrData): ServiceSolr)|(Closure(CreateServiceRedisData): ServiceRedis) expects CreateServiceSolrData, CreateServiceRedisData|CreateServiceSolrData given.
+68: Parameter #1 $data of callable (Closure(CreateServiceRedisData): ServiceRedis)|(Closure(CreateServiceSolrData): ServiceSolr) expects CreateServiceRedisData, CreateServiceRedisData|CreateServiceSolrData given.
PHP 7.1 – 7.4 (3 errors)
==========
@@ @@
19: Promoted properties are supported only on PHP 8.0 and later.
31: Promoted properties are supported only on PHP 8.0 and later.
-68: Parameter #1 $data of callable (Closure(CreateServiceSolrData): ServiceSolr)|(Closure(CreateServiceRedisData): ServiceRedis) expects CreateServiceSolrData, CreateServiceRedisData|CreateServiceSolrData given.
+68: Parameter #1 $data of callable (Closure(CreateServiceRedisData): ServiceRedis)|(Closure(CreateServiceSolrData): ServiceSolr) expects CreateServiceRedisData, CreateServiceRedisData|CreateServiceSolrData given. Full reportPHP 8.0 – 8.1 (1 error)
PHP 7.1 – 7.4 (3 errors)
|
@Kingdutch After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 – 8.1 (1 error)
==========
-77: Parameter #1 $data of callable (Closure(CreateServiceRedisData): ServiceRedis)|(Closure(CreateServiceSolrData): ServiceSolr) expects CreateServiceRedisData, CreateServiceRedisData|CreateServiceSolrData given.
+77: Parameter #1 $data of callable (Closure(CreateServiceSolrData): ServiceSolr)|(Closure(CreateServiceRedisData): ServiceRedis) expects CreateServiceSolrData, CreateServiceRedisData|CreateServiceSolrData given.
PHP 7.1 – 7.4 (3 errors)
==========
@@ @@
19: Promoted properties are supported only on PHP 8.0 and later.
31: Promoted properties are supported only on PHP 8.0 and later.
-77: Parameter #1 $data of callable (Closure(CreateServiceRedisData): ServiceRedis)|(Closure(CreateServiceSolrData): ServiceSolr) expects CreateServiceRedisData, CreateServiceRedisData|CreateServiceSolrData given.
+77: Parameter #1 $data of callable (Closure(CreateServiceSolrData): ServiceSolr)|(Closure(CreateServiceRedisData): ServiceRedis) expects CreateServiceSolrData, CreateServiceRedisData|CreateServiceSolrData given. Full reportPHP 8.0 – 8.1 (1 error)
PHP 7.1 – 7.4 (3 errors)
|
@Kingdutch After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 – 8.1 (1 error)
==========
-97: Parameter #1 $ of callable (callable(CreateServiceSolrData): ServiceSolr)|(callable(CreateServiceRedisData): ServiceRedis) expects CreateServiceSolrData, CreateServiceRedisData|CreateServiceSolrData given.
+97: Parameter #1 $ of callable (callable(CreateServiceRedisData): ServiceRedis)|(callable(CreateServiceSolrData): ServiceSolr) expects CreateServiceRedisData, CreateServiceRedisData|CreateServiceSolrData given.
PHP 7.1 – 7.4 (3 errors)
==========
@@ @@
19: Promoted properties are supported only on PHP 8.0 and later.
31: Promoted properties are supported only on PHP 8.0 and later.
-97: Parameter #1 $ of callable (callable(CreateServiceSolrData): ServiceSolr)|(callable(CreateServiceRedisData): ServiceRedis) expects CreateServiceSolrData, CreateServiceRedisData|CreateServiceSolrData given.
+97: Parameter #1 $ of callable (callable(CreateServiceRedisData): ServiceRedis)|(callable(CreateServiceSolrData): ServiceSolr) expects CreateServiceRedisData, CreateServiceRedisData|CreateServiceSolrData given. Full reportPHP 8.0 – 8.1 (1 error)
PHP 7.1 – 7.4 (3 errors)
|
Fixed: phpstan/phpstan-src#2902 |
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
I was trying to do something a bit clever to re-use some boilerplate with different sets of values. The sets of values are stored in an array and they work together. However, PHPStan merges the array shapes and thus thinks the input argument is incorrect.
Code snippet that reproduces the problem
Here is the issue as array:
https://phpstan.org/r/7410fa9a-4b11-4926-acf7-0bf86200e3f3
I thought PHPStan may have been confused by the observability of the dynamic array access, so I moved to individual variables with a switch statement that could be validated as standalone objects/paths. However, it looks like PHPStan still merges the type-shapes under the hood causing issues.
https://phpstan.org/r/8429299b-505a-435d-a360-d3de75fcd66e
Expected output
Did PHPStan help you today? Did it make you happy in any way?
Running PHPStan at level 9 helps me figure out if these kinds of shenanigans actually work :D
The text was updated successfully, but these errors were encountered: