Declare CallLike $args as list
having a more precise type helps to prevent false positives when implementing e.g. PHPStan rules
private function findInputTypeIdsInNew(New_ $newExpr, ClassReflection $class, Scope $scope): array
{
if (\count($newExpr->args) === 0) {
// more logic
return [];
}
$firstArg = $newExpr->args[0]; // Offset 0 might not exist on non-empty-array<PhpParser\Node\Arg|PhpParser\Node\VariadicPlaceholder>.
if (! $firstArg instanceof Arg) {
return [];
}
happens when PHPStan is configured with reportPossiblyNonexistentGeneralArrayOffset
This looks fine, but will this cause BC issues? I think people were concerned about that in the past.
yes, I had similar feelings when submitting the PR. When in doubt this PR has to wait for the next major version
@nikic today I stumbled over this again while working on phpstan-src.
do you think it makes sense merging?
alternatively (and more safe) we could re-activate https://github.com/phpstan/phpstan-php-parser to override the signatures in phpstan context
do it here instead: https://github.com/phpstan/phpstan-src/pull/4503