Feature: Collection types
Illuminate\Support\Collection has type support
Background:
Given I have the following config
"""
"""
Scenario:
Given I have the following code
"""
*/
public function getCollection(): Collection
{
return new Collection(['hi']);
}
public function popTest(): ?string
{
return $this->getCollection()->pop();
}
public function firstTest(): ?string
{
return $this->getCollection()->first(function (string $item) {
return strlen($item) > 3;
});
}
/**
* @return Collection
*/
public function testFlip(): Collection
{
return $this->getCollection()->flip();
}
public function lastTest(): ?string
{
return $this->getCollection()->last(function (string $item) {
return strlen($item) > 3;
});
}
public function getTest(): ?string
{
return $this->getCollection()->get(function (string $item) {
return strlen($item) > 3;
});
}
public function pullTest(): ?string
{
return $this->getCollection()->pull(function (string $item) {
return strlen($item) > 3;
});
}
/**
* @return int|false
*/
public function searchTest()
{
return $this->getCollection()->search(function (string $item) {
return strlen($item) > 3;
});
}
public function shiftTest(): ?string
{
return $this->getCollection()->shift();
}
/**
* @return array
*/
public function allTest(): array
{
return $this->getCollection()->all();
}
/**
* @return Collection
*/
public function putTest(): Collection
{
return $this->getCollection()->put(5, 'five');
}
}
"""
When I run Psalm
Then I see no errors