Fix for PHP 5.5 support in ObjectCollectionTrait

This commit is contained in:
Matias Griese
2017-05-10 11:34:23 +03:00
parent 65c0c4438f
commit ec4d451d7f

View File

@@ -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);
}
}
/**