Skip to content

Commit

Permalink
fix #820 ShapeCollection::addShape with instanceof and @throws
Browse files Browse the repository at this point in the history
  • Loading branch information
kw-pr authored Nov 27, 2024
1 parent b08eb11 commit 6a549ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/PhpPresentation/Traits/ShapeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace PhpOffice\PhpPresentation\Traits;

use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\ShapeContainerInterface;

trait ShapeCollection
{
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6a549ba

Please sign in to comment.