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);
function doFoo(int $a, int $b, int $c): int
{
return $a + $b + $c;
}
/** @param array<int> $ints */
function test(array $ints): void
{
$f = doFoo(?, ...$ints);
}
Why is it reported? #
A partial function application (PHP 8.6+) needs to know at compile time which parameters are bound and which are left open by ? placeholders. Argument unpacking (...$args) supplies an unknown number of arguments, which makes that impossible. PHP rejects this combination with a compile-time error, so the file cannot be loaded at all.
How to fix it #
Pass the bound arguments individually instead of unpacking them:
/** @param array<int> $ints */
function test(array $ints): void
{
- $f = doFoo(?, ...$ints);
+ $f = doFoo(?, $ints[0], $ints[1]);
}
Or write an explicit closure that does the unpacking:
/** @param array<int> $ints */
function test(array $ints): void
{
- $f = doFoo(?, ...$ints);
+ $f = static fn (int $a): int => doFoo($a, ...$ints);
}
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\Classes\ClassAttributesRule [1]
- PHPStan\Rules\Classes\ClassConstantAttributesRule [1]
- PHPStan\Rules\Classes\InstantiationRule [1]
- PHPStan\Rules\Constants\ConstantAttributesRule [1]
- PHPStan\Rules\EnumCases\EnumCaseAttributesRule [1]
- PHPStan\Rules\Functions\ArrowFunctionAttributesRule [1]
- PHPStan\Rules\Functions\CallCallablesRule [1]
- PHPStan\Rules\Functions\CallToFunctionParametersRule [1]
- PHPStan\Rules\Functions\CallUserFuncRule [1]
- PHPStan\Rules\Functions\ClosureAttributesRule [1]
- PHPStan\Rules\Functions\FunctionAttributesRule [1]
- PHPStan\Rules\Functions\FunctionCallableRule [1]
- PHPStan\Rules\Functions\ParamAttributesRule [1]
- PHPStan\Rules\Methods\CallMethodsRule [1]
- PHPStan\Rules\Methods\CallStaticMethodsRule [1]
- PHPStan\Rules\Methods\MethodAttributesRule [1]
- PHPStan\Rules\Methods\MethodCallableRule [1]
- PHPStan\Rules\Methods\StaticMethodCallableRule [1]
- PHPStan\Rules\Properties\PropertyAttributesRule [1]
- PHPStan\Rules\Properties\PropertyHookAttributesRule [1]
- PHPStan\Rules\Traits\TraitAttributesRule [1]