PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Expected type hint "MyClass[]"; found "array"

Open NikolaySl opened this issue 11 years ago • 2 comments

Example code:

    /**
     * Does foo with MyClass objects.
     *
     * @param MyClass[] $list List of objects.
     */
    function foo( array $list ) {}

Expected result: This should be OK.

Actual result:

 4 | ERROR | Expected type hint "MyClass[]"; found "array" for $list

NikolaySl avatar Jun 18 '15 15:06 NikolaySl

Duplicate of #601.

gsherwood avatar Sep 21 '15 06:09 gsherwood

Why was this closed? The comments in #601 clearly mentioned to create a new issue?

I have the same issue, PHPStan is happy this comments but this rule is conflicting. What should the advice be when we PHPCS and PHPStan?

6d70 avatar Mar 10 '25 09:03 6d70