Skip to content

Commit

Permalink
Fix for PHP 5.5 support in ObjectCollectionTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed May 10, 2017
1 parent 65c0c44 commit ec4d451
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions system/src/Grav/Framework/Object/ObjectCollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
*/
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.
*
Expand All @@ -32,7 +26,12 @@ public function copy()
$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);
}
}

/**
Expand Down

0 comments on commit ec4d451

Please sign in to comment.