diff --git a/src/PhpPresentation/Traits/ShapeCollection.php b/src/PhpPresentation/Traits/ShapeCollection.php index 0a2d1c5c3..ea71fa581 100644 --- a/src/PhpPresentation/Traits/ShapeCollection.php +++ b/src/PhpPresentation/Traits/ShapeCollection.php @@ -20,6 +20,7 @@ namespace PhpOffice\PhpPresentation\Traits; use PhpOffice\PhpPresentation\AbstractShape; +use PhpOffice\PhpPresentation\ShapeContainerInterface; trait ShapeCollection { @@ -76,12 +77,13 @@ public function setShapeCollection(array $shapeCollection = []): self /** * @return static + * @throws ShapeContainerAlreadyAssignedException */ public function addShape(AbstractShape $shape) { $this->shapeCollection[] = $shape; - if (method_exists($shape, 'setContainer') && $shape->getContainer() === null) { + if ($this instanceof ShapeContainerInterface && $shape->getContainer() === null) { $shape->setContainer($this); }