mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 19:58:53 +02:00
Fixed PHPstan issues for level 5.
This commit is contained in:
parent
a9293b7ceb
commit
da72f5b3ec
24 changed files with 87 additions and 49 deletions
|
@ -26,6 +26,7 @@ namespace App\Helpers\Trees;
|
|||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use ArrayIterator;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use RecursiveIterator;
|
||||
|
||||
final class StructuralDBElementIterator extends ArrayIterator implements RecursiveIterator
|
||||
|
@ -48,6 +49,15 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
|
|||
/** @var StructuralDBElement $element */
|
||||
$element = $this->current();
|
||||
|
||||
return new self($element->getSubelements()->toArray());
|
||||
$subelements = $element->getSubelements();
|
||||
if (is_array($subelements)) {
|
||||
$array = $subelements;
|
||||
} elseif ($subelements instanceof Collection) {
|
||||
$array = $subelements->toArray();
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid subelements type on $element!');
|
||||
}
|
||||
|
||||
return new self($array);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue