Skip to content

Conversation

janedbal
Copy link
Contributor

@janedbal janedbal commented Aug 6, 2024

@janedbal janedbal changed the title is_resource: remove type specification is_resource: adjust type specification for truthy context only Aug 7, 2024
@thg2k
Copy link
Contributor

thg2k commented Aug 7, 2024

I don't think you need a dedicated class for this, just replace the stub assertion with:

@phpstan-assert-if-true =resource $value

The (undocumented?) equal sign indicates that if false the opposite should not be asserted.

@janedbal
Copy link
Contributor Author

janedbal commented Aug 7, 2024

Oh god, the whole psalm-originated @phpstan-assert-if-true is so un-intuitive!

Thank you!

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.

Since we're trying to fix "Call to function is_resource() with resource will always evaluate to true.", we need a test for ImpossibleCheckTypeFunctionCallRule. Thanks.

@ondrejmirtes ondrejmirtes merged commit ce28abd into phpstan:1.11.x Aug 8, 2024
99 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

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.

3 participants