magento-coding-standard icon indicating copy to clipboard operation
magento-coding-standard copied to clipboard

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

Open hostep opened this issue 2 years ago • 3 comments

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 (and psalm has the same concept btw)

Steps to reproduce

  1. Have a class like this:
<?php

declare(strict_types=1);

namespace Whatever;

use Symfony\Component\Console\Output\OutputInterface;

class SomeClass
{
    /**
     * @param array<array<string, mixed>> $categoryData
     */
    public function outputResult(array $categoryData, OutputInterface $output): int
    {
        return 0;
    }
}
  1. 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)
--------------------------------------------------------------------------------------------------------------------------------------

hostep avatar Sep 16 '21 21:09 hostep

Hi @hostep. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Sep 16 '21 21:09 m2-assistant[bot]

Just ran into the same issue. Would love to see this fixed. For now, I disabled the magento-coding-standard checks in our CI pipeline in favor of phpstan.

shochdoerfer avatar Apr 24 '22 07:04 shochdoerfer

Although this is not how it should be, and this issue should be addressed correctly, you might skip the error detection by removing any space within the parameter's type section:

    /**
     * @param array<array<string,mixed>> $categoryData
     */

mansourwalid avatar Sep 29 '22 07:09 mansourwalid