Error Identifier: phpstan.debugScope
Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
<?php declare(strict_types = 1);
use function PHPStan\debugScope;
function doFoo(int $a, int $b): void
{
debugScope(); // Reports current scope: $a: int, $b: int
}
Why is it reported? #
This is a debugging tool built into PHPStan. When the PHPStan\debugScope() function is called in the analysed code, PHPStan outputs all the variables and their types that are currently in scope at that point. This is useful for debugging PHPStan’s type inference – for understanding what types PHPStan has inferred for each variable at a specific location in the code.
The error message contains a list of all variables in the current scope along with their types, including both the PHPDoc-level type and the native type.
This error is not ignorable because it is a debugging utility intended to be removed after the investigation is complete.
How to fix it #
Remove the debugScope() call once debugging is complete:
<?php declare(strict_types = 1);
-use function PHPStan\debugScope;
-
function doFoo(int $a, int $b): void
{
- debugScope();
+ // actual code here
}
Non-ignorable error #
This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.
Rules that report this error #
- PHPStan\Rules\Debug\DebugScopeRule [1]