diff --git a/stubs/illuminate.support.collection.phpstub b/stubs/illuminate.support.collection.phpstub index 6efda10..87beb6e 100644 --- a/stubs/illuminate.support.collection.phpstub +++ b/stubs/illuminate.support.collection.phpstub @@ -132,6 +132,17 @@ class Collection implements ArrayAccess, Enumerable { } + /** + * @template TCallbackReturn + * + * @param callable(TValue):TCallbackReturn $keyBy + * + * @return Collection + */ + public function keyBy($keyBy) + { + } + /** * @return Collection */ @@ -405,6 +416,13 @@ class Collection implements ArrayAccess, Enumerable { } + /** + * @return array + */ + public function toArray() + { + } + /** * @template TCallbackReturn * @param Closure(TValue,?TKey):TCallbackReturn $callback diff --git a/tests/acceptance/IlluminateSupportCollection.feature b/tests/acceptance/IlluminateSupportCollection.feature index 801776a..b531c5b 100644 --- a/tests/acceptance/IlluminateSupportCollection.feature +++ b/tests/acceptance/IlluminateSupportCollection.feature @@ -34,7 +34,7 @@ Feature: Collections When I run Psalm Then I see these errors | Type | Message | - | InvalidScalarArgument | Argument 1 of Illuminate\Support\Collection::add expects bool, int(1) provided | + | InvalidScalarArgument | Argument 1 of Illuminate\Support\Collection::add expects bool, 1 provided | And I see no other errors @Collection::times @@ -55,6 +55,7 @@ Feature: Collections """ /** @var Collection */ $c = new Collection(['a' => 'A', 'b' => 'B', 'c' => 'C']); + /** @psalm-suppress UnusedMethodCall */ $c->all()[1]; """ When I run Psalm @@ -69,6 +70,7 @@ Feature: Collections """ /** @var Collection */ $c = new Collection(['a' => 'A', 'b' => 'B', 'c' => 'C']); + /** @psalm-suppress UnusedMethodCall */ $c->all()['a']; """ When I run Psalm @@ -85,7 +87,7 @@ Feature: Collections When I run Psalm Then I see these errors | Type | Message | - | InvalidScalarArgument | Argument 1 of Illuminate\Support\Collection::add expects string, int(1) provided | + | InvalidScalarArgument | Argument 1 of Illuminate\Support\Collection::add expects string, 1 provided | And I see no other errors @Collection::add