magento / magento/magento-coding-standard
Magento2.Annotation.MethodArguments.MethodArguments can't deal with phpstan-style array argument types
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions
This started happening after upgrading the coding-standard library from version 6 to version 10 on a custom module of mine.
I suspect that this library currently can't deal wit [phpstan-style array argument types](https://phpstan.org/writing-php-code/phpdoc-types#general-arrays) (and [psalm has the same concept](https://github.com/vimeo/psalm/blob/master/docs/annotating_code/type_syntax/array_types.md#generic-arrays) btw)
### Steps to reproduce
1. Have a class like this:
```php
> $categoryData
*/
public function outputResult(array $categoryData, OutputInterface $output): int
{
return 0;
}
}
```
2. Run this library over it
### Expected result
1. No warnings
### Actual result
1. Warnings:
```
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
14 | WARNING | @param is not found for one or more params in method annotation
| | (Magento2.Annotation.MethodArguments.MethodArguments)
14 | WARNING | $categoryData parameter is missing in method annotation (Magento2.Annotation.MethodArguments.MethodArguments)
--------------------------------------------------------------------------------------------------------------------------------------
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Magento2.Annotation.MethodArguments.MethodArguments sniff named in the issue and reproduce the warning with the provided SomeClass example and its PHPStan-style array annotation. Done means the example produces no warnings, including no missing @param or missing parameter warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100