mirror of
https://github.com/getgrav/grav.git
synced 2026-07-08 19:51:28 +02:00
Fix for PHP 5.5 support in ObjectCollectionTrait
This commit is contained in:
@@ -14,12 +14,6 @@ namespace Grav\Framework\Object;
|
||||
*/
|
||||
trait ObjectCollectionTrait
|
||||
{
|
||||
/**
|
||||
* @param array $elements
|
||||
* @return static
|
||||
*/
|
||||
abstract public function createFrom(array $elements);
|
||||
|
||||
/**
|
||||
* Create a copy from this collection by cloning all objects in the collection.
|
||||
*
|
||||
@@ -32,7 +26,12 @@ trait ObjectCollectionTrait
|
||||
$list[$key] = is_object($value) ? clone $value : $value;
|
||||
}
|
||||
|
||||
return $this->createFrom($list);
|
||||
if (method_exists($this, 'createFrom')) {
|
||||
return $this->createFrom($list);
|
||||
} else {
|
||||
// TODO: remove when PHP 5.6 is minimum (with doctrine/collections v1.4).
|
||||
return new static($list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user