Skip to content

Declare CallLike $args as list #1080

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Declare CallLike $args as list #1080

wants to merge 1 commit into from

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