Fix wrong use of static

This commit is contained in:
Art4 2024-11-04 13:46:33 +00:00
parent 4a9c7d2f30
commit 57c188d01d

View file

@ -89,7 +89,7 @@ class BaseCollection extends \ArrayIterator
*/
public function map(callable $callback): BaseCollection
{
return new static(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
return new self(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
}
/**
@ -102,7 +102,7 @@ class BaseCollection extends \ArrayIterator
*/
public function filter(callable $callback = null, int $flag = 0): BaseCollection
{
return new static(array_filter($this->getArrayCopy(), $callback, $flag));
return new self(array_filter($this->getArrayCopy(), $callback, $flag));
}
/**
@ -112,14 +112,14 @@ class BaseCollection extends \ArrayIterator
*/
public function reverse(): BaseCollection
{
return new static(array_reverse($this->getArrayCopy()), $this->getTotalCount());
return new self(array_reverse($this->getArrayCopy()), $this->getTotalCount());
}
/**
* Split the collection in smaller collections no bigger than the provided length
*
* @param int $length
* @return static[]
* @return self[]
*/
public function chunk(int $length): array
{
@ -128,7 +128,7 @@ class BaseCollection extends \ArrayIterator
}
return array_map(function ($array) {
return new static($array);
return new self($array);
}, array_chunk($this->getArrayCopy(), $length));
}