Skip to content

Commit 9fab492

Browse files
committed
Added checks that tag::$parent is not null.
1 parent 4b73f0a commit 9fab492

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tokens/tag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ public function find(array $selector, bool $searchChildren = true) : array {
744744

745745
// match first-child
746746
case 'first-child':
747-
$children = $this->parent->children();
747+
$children = !== null ? $this->parent->children() : [];
748748
if (!isset($children[0]) || $this !== $children[0]) {
749749
$match = false;
750750
break 2;
@@ -753,7 +753,7 @@ public function find(array $selector, bool $searchChildren = true) : array {
753753

754754
// match last child
755755
case 'last-child':
756-
$children = $this->parent->children();
756+
$children = $this->parent !== null ? $this->parent->children() : [];
757757
if (($last = \end($children)) === false || $this !== $last) {
758758
$match = false;
759759
break 2;

0 commit comments

Comments
 (0)