Skip to content

Commit

Permalink
Merge pull request #60 from warhuhn/php-8.2
Browse files Browse the repository at this point in the history
Remove function declaration for PHP 8.2 compatibility
  • Loading branch information
PerryRylance authored Aug 25, 2023
2 parents 0588917 + e4daf46 commit 1bb0914
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":1,"defects":[],"times":{"DOMDocumentTest::testQuerySelector":0.025,"DOMDocumentTest::testSortAndOrder":0.01,"DOMDocumentTest::testChildrenFiltering":0.012,"DOMDocumentTest::testBeforeAfterPrevNext":0.015,"DOMDocumentTest::testClassManipulation":0.008,"DOMDocumentTest::testInlineCss":0.009,"DOMDocumentTest::testTextClear":0.007,"DOMDocumentTest::testHtmlStringManipulation":0.009,"DOMDocumentTest::testHtmlClear":0.007,"DOMDocumentTest::testAttributeHandling":0.008,"DOMDocumentTest::testDataAttributeInterface":0.008,"DOMDocumentTest::testNodeRemoval":0.008,"DOMDocumentTest::testNodeClearance":0.009,"DOMDocumentTest::testWrappingAndClosest":0.011,"DOMDocumentTest::testNodeReplacement":0.009,"DOMDocumentTest::testFragmentHandling":0.003,"DOMDocumentTest::testListPopulation":0.008,"DOMDocumentTest::testLinkConcatenation":0.008,"DOMDocumentTest::testCheckboxValueHandling":0.007,"DOMDocumentTest::testRadioValueHandling":0.008,"DOMDocumentTest::testCheckboxPropHandling":0.008,"DOMDocumentTest::testRadioPropHandling":0.008,"DOMDocumentTest::testHtmlParsing":0.008,"DOMDocumentTest::testShorthandMethod":0.009,"DOMDocumentTest::testCloneNode":0.002,"DOMDocumentTest::testToArray":0.009,"DOMDocumentTest::testPhpEvaluation":0.002,"DOMDocumentTest::testNoPhpEvaluation":0.002,"DOMDocumentTest::testImport":0.008,"DOMDocumentTest::testOutputNotEmpty":0.013}}
{"version":1,"defects":{"DOMDocumentTest::testSortAndOrder":8},"times":{"DOMDocumentTest::testQuerySelector":0.028,"DOMDocumentTest::testSortAndOrder":0.01,"DOMDocumentTest::testChildrenFiltering":0.014,"DOMDocumentTest::testBeforeAfterPrevNext":0.015,"DOMDocumentTest::testClassManipulation":0.008,"DOMDocumentTest::testInlineCss":0.009,"DOMDocumentTest::testTextClear":0.008,"DOMDocumentTest::testHtmlStringManipulation":0.01,"DOMDocumentTest::testHtmlClear":0.008,"DOMDocumentTest::testAttributeHandling":0.008,"DOMDocumentTest::testDataAttributeInterface":0.008,"DOMDocumentTest::testNodeRemoval":0.007,"DOMDocumentTest::testNodeClearance":0.009,"DOMDocumentTest::testWrappingAndClosest":0.011,"DOMDocumentTest::testNodeReplacement":0.009,"DOMDocumentTest::testFragmentHandling":0.003,"DOMDocumentTest::testListPopulation":0.008,"DOMDocumentTest::testLinkConcatenation":0.008,"DOMDocumentTest::testCheckboxValueHandling":0.009,"DOMDocumentTest::testRadioValueHandling":0.008,"DOMDocumentTest::testCheckboxPropHandling":0.009,"DOMDocumentTest::testRadioPropHandling":0.008,"DOMDocumentTest::testHtmlParsing":0.009,"DOMDocumentTest::testShorthandMethod":0.009,"DOMDocumentTest::testCloneNode":0.002,"DOMDocumentTest::testToArray":0.009,"DOMDocumentTest::testPhpEvaluation":0.001,"DOMDocumentTest::testNoPhpEvaluation":0.001,"DOMDocumentTest::testImport":0.008,"DOMDocumentTest::testOutputNotEmpty":0.012}}
10 changes: 5 additions & 5 deletions src/DOMDocument/DOMElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ private function implicitCastParentNode(): DOMElement
return $this->parentNode;
}

private static function implicitCastDomElement($el): DOMElement {
return $el;
}

/**
* Test if this element comes before the other element in the DOM tree
* @param DOMElement $other The element to compare positions with
Expand Down Expand Up @@ -69,11 +73,7 @@ public function isBefore(DOMElement $other)
$ancestor_depth--;
}

function implicitCastDomElement($el): DOMElement {
return $el;
}

return implicitCastDomElement($ancestor)->isBefore($other);
return static::implicitCastDomElement($ancestor)->isBefore($other);
}

if($this_depth < $other_depth)
Expand Down
3 changes: 3 additions & 0 deletions tests/DOMDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function testSortAndOrder()
&&
$document->find(".after")->text() == "This element is after"
);

// NB: Reverse compare across levels to reach part where this depth is greater than other depth
$this->assertFalse($after[0]->isBefore($before[0]), 'Reverse compare across levels');
}

public function testChildrenFiltering()
Expand Down

0 comments on commit 1bb0914

Please sign in to comment.