-
-
Notifications
You must be signed in to change notification settings - Fork 916
max()/min() should expect non-empty-array when called with a single arg #7239
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
Comments
Might be possible with a conditional parameter type 😂 |
if I understand ondrey correctly, we would aim for something like @rvanvelzen is this something on your roadmap? |
I don't think we need that. We can continue using extensions for situations that are more complicated. |
Just to get you right: do you still think this is possible with a conditional parameter? Or should I just implement a extension |
Oh sorry, I thought that was about another issue. You can't influence parameter types with an extension, so the conditional parameter type is an only option. But I don't know to solve this scenario right now, better to focus on something else probably :) |
Is this considered the same issue as
It's a bit misleading, since it suggests that the error might be mitigated by special handling of the return value, rather than the input. If there's simply no better solution at the moment, I can certainly understand that - I just wanted to make sure I shouldn't be reporting this as a separate issue. https://phpstan.org/r/9990fa9a-455b-412b-9995-9e5f5ec6fe77 Thanks for your time! |
@hemberger After the latest push in 1.9.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.0 – 8.2 (3 errors)
+==========
+
+4: Dumped type: int
+7: Dumped type: int
+9: Dumped type: *ERROR*
+
+PHP 7.1 – 7.4 (3 errors)
+==========
+
4: Dumped type: int
7: Dumped type: int|false
9: Dumped type: false Full reportPHP 8.0 – 8.2 (3 errors)
PHP 7.1 – 7.4 (3 errors)
|
Done with bleedingEdge already. |
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. |
Feature request
https://phpstan.org/r/c16b4e78-df26-405b-b0cb-3fe4043c477c
it should report a error when max() min() is invoked with a empty array
https://3v4l.org/OE4CD
https://3v4l.org/vhUXS
The text was updated successfully, but these errors were encountered: