magento / magento/magento-coding-standard

Magento2.Annotation.MethodArguments.MethodArguments can't deal with phpstan-style array argument types

Open
#276 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Progress: ready for grooming
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.