Skip to content
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

Correct declaration of variadic $args as array #10352

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

oddnoc
Copy link
Contributor

@oddnoc oddnoc commented Jun 9, 2022

This declaration confuses static analyzers, specifically phan, which
throws PhanTypeMismatchArgument for every invocation of
Inejctable::create(). Removing this declaration from the doc block
prevents all those false positives.

Copy link
Contributor

@dhensby dhensby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use the write phpdoc than just remove it

src/Core/Injector/Injectable.php Show resolved Hide resolved
Declaring as array confuses static analyzers, specifically phan, which
throws PhanTypeMismatchArgument for every invocation of
Injectable::create(). Correcting this declaration in the doc block
prevents all those false positives.
@oddnoc oddnoc changed the title Remove declaration of variadic $args as array Correct declaration of variadic $args as array Jun 9, 2022
@GuySartorelli
Copy link
Member

Just so that we have a clear indication of why mixed is correct over array: https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list

It is also possible to add a type declaration before the ... token. If this is present, then all arguments captured by ... must match that parameter type.

@kinglozzer kinglozzer merged commit be19fa7 into silverstripe:4 Jun 13, 2022
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.

None yet

4 participants