Open
Description
Describe the bug
Hi, I ran into this issue again. which was already addressed in the old package. Even PR is mentioned as a likely solution. Can we get it into the production version if possible? Thank you for your time :)
Code sample
use Illuminate\Support\Collection;
/**
* @param array<int, string> $array
* @param iterable<string> $iterable
* @param int<0, 100> $int
* @param \Illuminate\Support\Collection<int, string> $collection
*
* @return \Illuminate\Support\Collection<int, string>
*/
function test(
array $array,
iterable $iterable,
int $int,
Collection $collection,
): Collection {
return new Collection();
}
Custom ruleset
N/A
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php
with the code sample above... - Run
phpcs test.php ...
- See error message displayed
15 | ERROR | [ ] Expected type hint "iterable<string>"; found "iterable" for $iterable (Squiz.Commenting.FunctionComment.IncorrectTypeHint)
15 | ERROR | [ ] Expected type hint "int<0, 100>"; found "int" for $int (Squiz.Commenting.FunctionComment.IncorrectTypeHint)
15 | ERROR | [ ] Expected type hint "\Illuminate\Support\Collection<int, string>"; found "Collection" for $collection
| | (Squiz.Commenting.FunctionComment.IncorrectTypeHint)
Expected behavior
Errors should not occur with generics <>, just like how it works for an array
Versions (please complete the following information)
Operating System | [MacOS 15.1.1 - docker container] |
PHP version | [8.1] |
PHP_CodeSniffer version | [3.11.1, master] |
Standard | [Squiz] |
Install type | [Composer] |