mirror of
https://github.com/friendica/friendica
synced 2024-11-17 18:23:40 +00:00
use get_class() instead of static() in BaseCollection
This commit is contained in:
parent
31665e795c
commit
12d5e4da44
1 changed files with 13 additions and 5 deletions
|
@ -89,7 +89,9 @@ class BaseCollection extends \ArrayIterator
|
||||||
*/
|
*/
|
||||||
public function map(callable $callback): BaseCollection
|
public function map(callable $callback): BaseCollection
|
||||||
{
|
{
|
||||||
return new self(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
|
$class = get_class($this);
|
||||||
|
|
||||||
|
return new $class(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +104,9 @@ class BaseCollection extends \ArrayIterator
|
||||||
*/
|
*/
|
||||||
public function filter(callable $callback = null, int $flag = 0): BaseCollection
|
public function filter(callable $callback = null, int $flag = 0): BaseCollection
|
||||||
{
|
{
|
||||||
return new self(array_filter($this->getArrayCopy(), $callback, $flag));
|
$class = get_class($this);
|
||||||
|
|
||||||
|
return new $class(array_filter($this->getArrayCopy(), $callback, $flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,14 +116,16 @@ class BaseCollection extends \ArrayIterator
|
||||||
*/
|
*/
|
||||||
public function reverse(): BaseCollection
|
public function reverse(): BaseCollection
|
||||||
{
|
{
|
||||||
return new self(array_reverse($this->getArrayCopy()), $this->getTotalCount());
|
$class = get_class($this);
|
||||||
|
|
||||||
|
return new $class(array_reverse($this->getArrayCopy()), $this->getTotalCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split the collection in smaller collections no bigger than the provided length
|
* Split the collection in smaller collections no bigger than the provided length
|
||||||
*
|
*
|
||||||
* @param int $length
|
* @param int $length
|
||||||
* @return self[]
|
* @return static[]
|
||||||
*/
|
*/
|
||||||
public function chunk(int $length): array
|
public function chunk(int $length): array
|
||||||
{
|
{
|
||||||
|
@ -128,7 +134,9 @@ class BaseCollection extends \ArrayIterator
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_map(function ($array) {
|
return array_map(function ($array) {
|
||||||
return new self($array);
|
$class = get_class($this);
|
||||||
|
|
||||||
|
return new $class($array);
|
||||||
}, array_chunk($this->getArrayCopy(), $length));
|
}, array_chunk($this->getArrayCopy(), $length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue