You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Squiz.Commenting.FunctionComment.IncorrectTypeHint sniff gives me an error that I should include the generics part <> in type hints, which is not valid PHP code.
It works good with @return or array for @params, but it definitely has a problem with other types as in the code sample below.
As Laravel 9 and PhpStorm 2022.1 have recently supported generics, I think the sniff's problem can be a barrier for their users.
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):
OS: Windows 10 WSL 2 Ubuntu 18.04
PHP: 8.0
PHPCS: 3.6.2
Standard: Squiz
The text was updated successfully, but these errors were encountered:
Describe the bug
The
Squiz.Commenting.FunctionComment.IncorrectTypeHint
sniff gives me an error that I should include the generics part<>
in type hints, which is not valid PHP code.It works good with
@return
orarray
for@params
, but it definitely has a problem with other types as in the code sample below.As Laravel 9 and PhpStorm 2022.1 have recently supported generics, I think the sniff's problem can be a barrier for their users.
Code sample
Custom ruleset
N/A
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
Expected behavior
Errors should not occur with generics
<>
, just like how it works for an array.Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: