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

Array indexing check false positive with explicit isset #149

Closed
quasilyte opened this issue Mar 4, 2021 · 0 comments
Closed

Array indexing check false positive with explicit isset #149

quasilyte opened this issue Mar 4, 2021 · 0 comments

Comments

@quasilyte
Copy link
Contributor

quasilyte commented Mar 4, 2021

Since getting a non-existing element in KPHP leads to different results ("empty value of array type element" instead of null), people sometimes tend to write code like this:

$v = isset($data['k']) ? $data['k'] : '';
if ($v !== '') { // <- warning here
}

It makes sure that for both KPHP and PHP this code could behave identically.

But it looks like KPHP does not recognize this idiom.

Do we have any hints for this case (for example, !empty($v), etc.)?
In that case, we could suggest a potential fix to the problem inside the warning message.

Is it practical to improve this particular diagnostic so it doesn't report such cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant