- Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
- Laravel Version: 10.3.3
- PHP Version: 8.1.11
- Database Driver & Version: N/A
Description:
The transform method phpdoc indicate that the return type of the callable should be the same as the input one, but transform should (like map) allow to change the type of the items.
It make it so that Phpstan think that valid code are not valid.
Steps To Reproduce:
Here's a basic example that trigger an error in phpstan:
$test = collect([1, 2, 3]); $test->transform(fn(int $input): string => (string)$input);When I run Phpstan on level 8 (I did not try it on lower level) I get this error:
Parameter #1 $callback of method Illuminate\Support\Collection<int,int>::transform() expects callable(int, int): int, Closure(int): numeric-string given. The same code with transform replace by map do not trigger any error.
Metadata
Metadata
Assignees
Labels
No labels