@@ -434,11 +434,7 @@ public function saveHTMLFragment(?DOMNode $node = null)
434434 }
435435 }
436436
437- if (null === $ node || PHP_VERSION_ID >= 70300 ) {
438- $ html = parent ::saveHTML ($ node );
439- } else {
440- $ html = $ this ->extractNodeViaFragmentBoundaries ($ node );
441- }
437+ $ html = parent ::saveHTML ($ node );
442438
443439 foreach ($ filtersInReverse as $ filter ) {
444440 if ($ filter instanceof AfterSaveFilter) {
@@ -474,43 +470,6 @@ private function insertMissingCharset()
474470 $ this ->head ->insertBefore ($ charset , $ this ->head ->firstChild );
475471 }
476472
477- /**
478- * Extract a node's HTML via fragment boundaries.
479- *
480- * Temporarily adds fragment boundary comments in order to locate the desired node to extract from
481- * the given HTML document. This is required because libxml seems to only preserve whitespace when
482- * serializing when calling DOMDocument::saveHTML() on the entire document. If you pass the element
483- * to DOMDocument::saveHTML() then formatting whitespace gets added unexpectedly. This is seen to
484- * be fixed in PHP 7.3, but for older versions of PHP the following workaround is needed.
485- *
486- * @param DOMNode $node Node to extract the HTML for.
487- * @return string Extracted HTML string.
488- */
489- private function extractNodeViaFragmentBoundaries (DOMNode $ node )
490- {
491- $ boundary = $ this ->uniqueIdManager ->getUniqueId ('fragment_boundary ' );
492- $ startBoundary = $ boundary . ':start ' ;
493- $ endBoundary = $ boundary . ':end ' ;
494- $ commentStart = $ this ->createComment ($ startBoundary );
495- $ commentEnd = $ this ->createComment ($ endBoundary );
496-
497- $ node ->parentNode ->insertBefore ($ commentStart , $ node );
498- $ node ->parentNode ->insertBefore ($ commentEnd , $ node ->nextSibling );
499-
500- $ pattern = '/^.*? '
501- . preg_quote ("<!-- {$ startBoundary }--> " , '/ ' )
502- . '(.*) '
503- . preg_quote ("<!-- {$ endBoundary }--> " , '/ ' )
504- . '.*?\s*$/s ' ;
505-
506- $ html = preg_replace ($ pattern , '$1 ' , parent ::saveHTML ());
507-
508- $ node ->parentNode ->removeChild ($ commentStart );
509- $ node ->parentNode ->removeChild ($ commentEnd );
510-
511- return $ html ;
512- }
513-
514473 /**
515474 * Normalize the document structure.
516475 *
@@ -1144,16 +1103,10 @@ private function instantiateFilter($filterClass)
11441103 foreach ($ parameters as $ parameter ) {
11451104 $ dependencyType = null ;
11461105
1147- // The use of `ReflectionParameter::getClass()` is deprecated in PHP 8, and is superseded
1148- // by `ReflectionParameter::getType()`. See https://github.com/php/php-src/pull/5209.
1149- if (PHP_VERSION_ID >= 70100 ) {
1150- if ($ parameter ->getType ()) {
1151- /** @var ReflectionNamedType $returnType */
1152- $ returnType = $ parameter ->getType ();
1153- $ dependencyType = new ReflectionClass ($ returnType ->getName ());
1154- }
1155- } else {
1156- $ dependencyType = $ parameter ->getClass ();
1106+ if ($ parameter ->getType ()) {
1107+ /** @var ReflectionNamedType $returnType */
1108+ $ returnType = $ parameter ->getType ();
1109+ $ dependencyType = new ReflectionClass ($ returnType ->getName ());
11571110 }
11581111
11591112 if ($ dependencyType === null ) {
0 commit comments