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

Closure::bind must honor class-string<> #4949

Closed
mvorisek opened this issue May 2, 2021 · 4 comments · Fixed by phpstan/phpstan-src#706
Closed

Closure::bind must honor class-string<> #4949

mvorisek opened this issue May 2, 2021 · 4 comments · Fixed by phpstan/phpstan-src#706
Labels
Milestone

Comments

@mvorisek
Copy link
Contributor

mvorisek commented May 2, 2021

Bug report

Closure::bind must honor class-string<>

Code snippet that reproduces the problem

see https://phpstan.org/r/adaa989d-186d-4111-80df-b56afcf1fb0f
and https://phpstan.org/r/86a890d6-a041-4f1a-83ca-a5a777002971
https://3v4l.org/KQo6c works

Expected output

no error

@ondrejmirtes
Copy link
Member

Should be fixed here: https://github.com/phpstan/phpstan-src/blob/7b301a1850e7dcb2455c0f319671f370e16eec66/src/Analyser/NodeScopeResolver.php#L2060-L2080

The condition with ClassConstFetch could be removed imho.

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

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

@@ @@
-24: Call to protected method getHintableProps() of class Model.
+ 9: Method Model::getHintableProps() should return X but return statement is missing.
+20: Method HelloWorld::sayHello() should return X but return statement is missing.
Full report
Line Error
9 Method Model::getHintableProps() should return X but return statement is missing.
20 Method HelloWorld::sayHello() should return X but return statement is missing.

@phpstan-bot
Copy link
Contributor

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

@@ @@
 PHP 7.1 – 7.3 (4 errors)
 ==========
 
-17: Syntax error, unexpected ')' on line 17
+17: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 17
+17: Syntax error, unexpected T_DOUBLE_ARROW on line 17
 17: Syntax error, unexpected ',' on line 17
-17: Syntax error, unexpected T_DOUBLE_ARROW on line 17
-17: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 17
+17: Syntax error, unexpected ')' on line 17
Full report

PHP 7.4 – 8.0 (1 error)

Line Error
17 Call to protected method unionTypes() of class UnionType.

PHP 7.1 – 7.3 (4 errors)

Line Error
17 Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 17
17 Syntax error, unexpected T_DOUBLE_ARROW on line 17
17 Syntax error, unexpected ',' on line 17
17 Syntax error, unexpected ')' on line 17

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

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

Successfully merging a pull request may close this issue.

3 participants