Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 12, 2022

@staabm staabm marked this pull request as ready for review August 12, 2022 07:26
Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test some more scenarios.

  1. Three equal signs: if (gettype($x) === 'int')
  2. Negative context:
// $x is int|string|bool
if (gettype($x) === 'integer') {
    // assert int
    return;
}

// assert string|bool
  1. BooleanOr:
if (gettype($x) === 'string' || gettype($x) === 'integer') {
    // assert int|string
}

@staabm
Copy link
Contributor Author

staabm commented Aug 12, 2022

great feedback thx. added tests and simplified the implementation based on it :)

@ondrejmirtes ondrejmirtes merged commit eb40029 into phpstan:1.8.x Aug 12, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the gettype-specifying branch August 12, 2022 13:55
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

Successfully merging this pull request may close these issues.

switch on gettype($var), then caseing on result, doesn't appear to take result into account
2 participants