diff --git a/src/Element/BookCollection.php b/src/Element/BookCollection.php index b467de5..cb32958 100644 --- a/src/Element/BookCollection.php +++ b/src/Element/BookCollection.php @@ -10,9 +10,9 @@ class BookCollection { /** @var Book[]|BookCollection[] */ private array $array; - private BookCollection $parent; + private ?BookCollection $parent; - private function __construct (string $name, array $a, BookCollection $parent) { + private function __construct (string $name, array $a, ?BookCollection $parent) { $this->name = $name; $this->array = $a; $this->parent = $parent; @@ -20,12 +20,12 @@ class BookCollection { /** * @param DOMNode $root - * @param BookCollection $parent + * @param ?BookCollection $parent * @param bool $isRoot * @return BookCollection * @throws Exception */ - public static function parse (DOMNode $root, BookCollection $parent, bool $isRoot = false): BookCollection { + public static function parse (DOMNode $root, ?BookCollection $parent, bool $isRoot = false): BookCollection { $name = BookCollection::ROOT; if (!$isRoot) { if ($root->hasAttributes()) { diff --git a/src/Element/BookContent/Chapter.php b/src/Element/BookContent/Chapter.php index 23389cb..8354b97 100644 --- a/src/Element/BookContent/Chapter.php +++ b/src/Element/BookContent/Chapter.php @@ -9,9 +9,9 @@ class Chapter { /** @var Chapter[]|Page[] */ private array $childs; - private Chapter $parent; + private ?Chapter $parent; - private function __construct (string $name, array $array, Chapter $parent) { + private function __construct (string $name, array $array, ?Chapter $parent) { $this->name = $name; $this->childs = $array; $this->parent = $parent; @@ -19,11 +19,11 @@ class Chapter { /** * @param DOMNode $xmlData - * @param Chapter $parent + * @param ?Chapter $parent * @return Chapter * @throws Exception */ - public static function parse (DOMNode $xmlData, Chapter $parent): Chapter { + public static function parse (DOMNode $xmlData, ?Chapter $parent): Chapter { if ($xmlData->hasAttributes()) { $attrName = $xmlData->attributes->getNamedItem("name"); if ($attrName == null) throw new Exception("Chapter xml data missing attribute \"name\""); diff --git a/src/Element/LinkCollection.php b/src/Element/LinkCollection.php index e43438e..5d6caf8 100644 --- a/src/Element/LinkCollection.php +++ b/src/Element/LinkCollection.php @@ -10,9 +10,9 @@ class LinkCollection { /** @var Link[]|LinkCollection[] */ private array $array; - private LinkCollection $parent; + private ?LinkCollection $parent; - private function __construct (string $name, array $a, LinkCollection $parent) { + private function __construct (string $name, array $a, ?LinkCollection $parent) { $this->name = $name; $this->array = $a; $this->parent = $parent; @@ -20,12 +20,12 @@ class LinkCollection { /** * @param DOMNode $root - * @param LinkCollection $parent + * @param ?LinkCollection $parent * @param bool $isRoot * @return LinkCollection * @throws Exception */ - public static function parse (DOMNode $root, LinkCollection $parent, bool $isRoot = false): LinkCollection { + public static function parse (DOMNode $root, ?LinkCollection $parent, bool $isRoot = false): LinkCollection { $name = LinkCollection::ROOT; if (!$isRoot) { if ($root->hasAttributes()) {