Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Apr 10, 2025

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

@staabm staabm marked this pull request as ready for review April 10, 2025 08:15
@nikic
Copy link
Owner

nikic commented Apr 10, 2025

This looks fine, but will this cause BC issues? I think people were concerned about that in the past.

@staabm
Copy link
Contributor Author

staabm commented Apr 11, 2025

yes, I had similar feelings when submitting the PR. When in doubt this PR has to wait for the next major version

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

Successfully merging this pull request may close these issues.

2 participants