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

Wrong type detected for a variable assigned in a is_string function #4761

Closed
fancyweb opened this issue Mar 30, 2021 · 3 comments
Closed

Wrong type detected for a variable assigned in a is_string function #4761

fancyweb opened this issue Mar 30, 2021 · 3 comments
Labels
Milestone

Comments

@fancyweb
Copy link

Bug report

It looks like assigning a variable in a is_string function does not "set" the variable type for PHPStan.

Code snippet that reproduces the problem

https://phpstan.org/r/975081af-96ab-4ef5-b6b3-6cc5158db03f

Expected output

There should be no PHPStan issue. $path is a string.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Mar 30, 2021
@phpstan-bot
Copy link
Contributor

@fancyweb After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-PHP 8.0 (1 error)
-==========
-
-11: Parameter #1 $string of function rtrim expects string, string|false|null given.
-
-PHP 7.1 – 7.4 (1 error)
-==========
-
-11: Parameter #1 $str of function rtrim expects string, string|false|null given.
+No errors

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@b2bf703

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue May 11, 2021
@github-actions
Copy link

github-actions bot commented Jun 9, 2021

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 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants