From 6a549ba8d6d1a668bac024fac01f1a2a14af366c Mon Sep 17 00:00:00 2001 From: kw-pr <9133572+kw-pr@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:11:25 +0100 Subject: [PATCH] fix #820 ShapeCollection::addShape with instanceof and @throws --- src/PhpPresentation/Traits/ShapeCollection.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }