From 9d86fd5e53d5e2e185453f310262535cc1fa9fe5 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Thu, 22 Apr 2021 22:47:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86Collection=E5=92=8CC?= =?UTF-8?q?hapter=E5=9C=A8=E5=85=B6=E7=89=B9=E6=AE=8A=E7=88=B6=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E7=9A=84null=E5=80=BC=E8=B0=83=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Element/BookCollection.php | 8 ++++---- src/Element/BookContent/Chapter.php | 8 ++++---- src/Element/LinkCollection.php | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) 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()) {