Skip to content

Commit

Permalink
make removeChild and removeBlock as NEXT_MAJOR
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanmac committed Aug 7, 2023
1 parent f458a25 commit 5b5f29a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/Model/PageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

/**
* @author Thomas Rabaix <[email protected]>
*
* NEXT_MAJOR: add these methods
*
* @method removeChild(PageInterface $child)
* @method removeBlock(PageBlockInterface $block)
*/
interface PageInterface extends \Stringable
{
Expand Down Expand Up @@ -113,7 +118,10 @@ public function setChildren(Collection $children): void;

public function addChild(self $child): void;

public function removeChild(self $child): void;
/**
* NEXT_MAJOR uncomment this.
*/
// public function removeChild(self $child): void;

/**
* @return Collection<array-key, PageBlockInterface>
Expand All @@ -122,7 +130,10 @@ public function getBlocks(): Collection;

public function addBlock(PageBlockInterface $block): void;

public function removeBlock(PageBlockInterface $block): void;
/**
* NEXT_MAJOR uncomment this.
*/
// public function removeBlock(PageBlockInterface $block): void;

public function getContainerByCode(string $code): ?PageBlockInterface;

Expand Down
10 changes: 8 additions & 2 deletions src/Model/SnapshotPageProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ public function addChild(PageInterface $child): void

public function removeChild(PageInterface $child): void
{
$this->getPage()->removeChild($child);
// NEXT_MAJOR remove check
if (method_exists($this->getPage(), 'removeChild')) {

Check failure on line 262 in src/Model/SnapshotPageProxy.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to function method_exists() with Sonata\PageBundle\Model\PageInterface and 'removeChild' will always evaluate to true.
$this->getPage()->removeChild($child);
}
}

public function getBlocks(): Collection
Expand Down Expand Up @@ -286,7 +289,10 @@ public function addBlock(PageBlockInterface $block): void

public function removeBlock(PageBlockInterface $block): void
{
$this->getPage()->removeBlock($block);
// NEXT_MAJOR remove check
if (method_exists($this->getPage(), 'removeBlock')) {

Check failure on line 293 in src/Model/SnapshotPageProxy.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to function method_exists() with Sonata\PageBundle\Model\PageInterface and 'removeBlock' will always evaluate to true.
$this->getPage()->removeBlock($block);
}
}

public function getContainerByCode(string $code): ?PageBlockInterface
Expand Down

0 comments on commit 5b5f29a

Please sign in to comment.