Skip to content
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

Conditional param type should provide the same analysis as condition in code #7915

Closed
mvorisek opened this issue Sep 2, 2022 · 5 comments
Closed

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Sep 2, 2022

Feature request

demo: https://phpstan.org/r/db87d84e-9483-4a85-9506-39e25605ee7a

I would expect

@param ($name is array ? null : int) $value

to be strictly equal to

@param int $value

+

if (is_array($name)) {
    $value = null;
}
@Screenfeed
Copy link

I think I encountered the same issue.
demo: https://phpstan.org/r/4c7fc3fd-07c0-4256-b333-01afad2648e1

@mvorisek
Copy link
Contributor Author

mvorisek commented Jul 24, 2023

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpstan-src#2548

@thg2k
Copy link

thg2k commented Jul 25, 2023

But this is a regression.. You have no way to enforce the parameter value inside the function, so I do prefer phpstan to tell me that it can still be both.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants