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

Strict comparison using === between *NEVER* and 'TB' will always evaluate to false. #5062

Closed
danielmarschall opened this issue May 23, 2021 · 6 comments

Comments

@danielmarschall
Copy link

danielmarschall commented May 23, 2021

Bug report

I receive following errors:

  14     Strict comparison using === between *NEVER* and 'TB' will always evaluate to false.  
  15     Strict comparison using === between *NEVER* and 'c' will always evaluate to false.  

Running version 0.12.88 with Level 4+.

Reproduction URL: https://phpstan.org/r/bc0bf93c-2d11-40d9-b050-70dd3494b115

Code snippet that reproduces the problem

function isKnownUOM(string $uom) {
        return (
                ($uom === '') ||
                ($uom === 's') ||
                ($uom === 'ms') ||
                ($uom === 'us') ||
                ($uom === '%') ||
                ($uom === 'B') ||
                ($uom === 'KB') ||
                ($uom === 'MB') ||
                ($uom === 'GB') ||
                ($uom === 'TB') ||
                ($uom === 'c')
        );
}

Expected output

No errors

@mergeable
Copy link

mergeable bot commented May 23, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@danielmarschall
Copy link
Author

@ondrejmirtes
Copy link
Member

Duplicate of #3555

@ondrejmirtes ondrejmirtes marked this as a duplicate of #3555 May 24, 2021
@stof
Copy link
Contributor

stof commented May 29, 2021

@ondrejmirtes as this issue is about a case where phpstan infers the constant union, maybe it should keep it as string when reaching the CONSTANT_SCALAR_UNION_THRESHOLD instead of refining the type to a broken one. there is no phpdoc enum involved in that specific case.

@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 Jun 30, 2021
@ondrejmirtes
Copy link
Member

I managed to solve this.

Look forward to the next release (0.12.95) :)

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

No branches or pull requests

3 participants