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

MutatingScope not being covered by backward compatibility promise #7516

Open
vojtech-dobes opened this issue Jun 23, 2022 · 5 comments
Open
Labels

Comments

@vojtech-dobes
Copy link

vojtech-dobes commented Jun 23, 2022

Bug report

MethodCallThrowTypeExtension started to complain about MutatingScope not being covered by backward compatibility promise.

I would like to know how to modify the code to avoid this warning.

Code snippet that reproduces the problem

https://phpstan.org/r/5fd1150d-a3e3-478d-af2b-a7b82a4d9193

Expected output

No error reported.

Did PHPStan help you today? Did it make you happy in any way?

It transformed the way we work in PHP, it has incredibly positive impact on our productivity at ContentKing.

@ondrejmirtes
Copy link
Member

Your example shows a different error - please send a PR that adds @api above NodeScopeResolver::processStmtNodes :)

But with bleedingEdge yeah, the assert() is marked too: https://phpstan.org/r/eb34f039-7994-4588-9755-a749aafa6db9

I'll see what can be done about it, thanks

@phpstan-bot
Copy link
Contributor

@vojtech-dobes After the latest commit in 1.7.x, PHPStan now reports different result with your code snippet:

@@ @@
-58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
-60: Calling PHPStan\Analyser\NodeScopeResolver::processStmtNodes() is not covered by backward compatibility promise. The method might change in a minor PHPStan version.
+58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
Full report
Line Error
58 Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in 1.7.x, PHPStan now reports different result with your code snippet:

@@ @@
-58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
-60: Calling PHPStan\Analyser\NodeScopeResolver::processStmtNodes() is not covered by backward compatibility promise. The method might change in a minor PHPStan version.
+58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
Full report
Line Error
58 Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.

@phpstan-bot
Copy link
Contributor

@vojtech-dobes After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:

@@ @@
+PHP 8.1 (1 error)
+==========
+
 58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
-60: Calling PHPStan\Analyser\NodeScopeResolver::processStmtNodes() is not covered by backward compatibility promise. The method might change in a minor PHPStan version.
+
+PHP 7.4 – 8.0 (4 errors)
+==========
+
+ 7: Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
+18: Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
+58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
+60: Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.
+
+PHP 7.1 – 7.3 (7 errors)
+==========
+
+ 7: Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
+18: Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
+35: Call to method getName() on an unknown class PHPStan\Reflection\ClassReflection.
+58: Class PHPStan\Analyser\MutatingScope not found.
+60: Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.
+63: Call to method enterAnonymousFunction() on an unknown class PHPStan\Analyser\MutatingScope.
+83: Call to static method union() on an unknown class PHPStan\Type\TypeCombinator.
Full report

PHP 8.1 (1 error)

Line Error
58 Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.

PHP 7.4 – 8.0 (4 errors)

Line Error
7 Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
18 Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
58 Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
60 Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.

PHP 7.1 – 7.3 (7 errors)

Line Error
7 Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
18 Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
35 Call to method getName() on an unknown class PHPStan\Reflection\ClassReflection.
58 Class PHPStan\Analyser\MutatingScope not found.
60 Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.
63 Call to method enterAnonymousFunction() on an unknown class PHPStan\Analyser\MutatingScope.
83 Call to static method union() on an unknown class PHPStan\Type\TypeCombinator.

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:

@@ @@
+PHP 8.1 (1 error)
+==========
+
 58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
-60: Calling PHPStan\Analyser\NodeScopeResolver::processStmtNodes() is not covered by backward compatibility promise. The method might change in a minor PHPStan version.
+
+PHP 7.4 – 8.0 (4 errors)
+==========
+
+ 7: Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
+18: Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
+58: Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
+60: Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.
+
+PHP 7.1 – 7.3 (7 errors)
+==========
+
+ 7: Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
+18: Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
+35: Call to method getName() on an unknown class PHPStan\Reflection\ClassReflection.
+58: Class PHPStan\Analyser\MutatingScope not found.
+60: Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.
+63: Call to method enterAnonymousFunction() on an unknown class PHPStan\Analyser\MutatingScope.
+83: Call to static method union() on an unknown class PHPStan\Type\TypeCombinator.
Full report

PHP 8.1 (1 error)

Line Error
58 Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.

PHP 7.4 – 8.0 (4 errors)

Line Error
7 Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
18 Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
58 Asking about instanceof PHPStan\Analyser\MutatingScope is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
60 Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.

PHP 7.1 – 7.3 (7 errors)

Line Error
7 Property ImmediatelyCalledClosureInMethodCallThrowTypeExtension::$nodeScopeResolver has unknown class PHPStan\Analyser\NodeScopeResolver as its type.
18 Parameter $nodeScopeResolver of method ImmediatelyCalledClosureInMethodCallThrowTypeExtension::__construct() has invalid type PHPStan\Analyser\NodeScopeResolver.
35 Call to method getName() on an unknown class PHPStan\Reflection\ClassReflection.
58 Class PHPStan\Analyser\MutatingScope not found.
60 Call to method processStmtNodes() on an unknown class PHPStan\Analyser\NodeScopeResolver.
63 Call to method enterAnonymousFunction() on an unknown class PHPStan\Analyser\MutatingScope.
83 Call to static method union() on an unknown class PHPStan\Type\TypeCombinator.

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

No branches or pull requests

3 participants