diff --git a/lib/common/phpstan.neon.dist b/lib/common/phpstan.neon.dist index 0946588ab5d..841272db310 100644 --- a/lib/common/phpstan.neon.dist +++ b/lib/common/phpstan.neon.dist @@ -10,3 +10,7 @@ parameters: - %currentWorkingDirectory%/vendor/autoload.php ignoreErrors: - '#^PHPDoc tag @throws with type AmpProject\\Exception\\FailedRemoteRequest is not subtype of Throwable$#' + - + message: '#^If condition is always false\.$#' + path: 'src/Dom/Document.php' + # See https://github.com/phpstan/phpstan/issues/3291 diff --git a/lib/common/src/Dom/Document.php b/lib/common/src/Dom/Document.php index c7fc801e42f..4ffc1c079b1 100644 --- a/lib/common/src/Dom/Document.php +++ b/lib/common/src/Dom/Document.php @@ -847,26 +847,26 @@ private function restoreSelfClosingTags($html) */ private function maybeReplaceNoscriptElements($html) { - if (! version_compare(LIBXML_DOTTED_VERSION, '2.8', '<')) { - return $html; + if (version_compare(LIBXML_DOTTED_VERSION, '2.8', '<')) { + $html = preg_replace_callback( + '#^.+?(?=]*>.*?#si', + function ($noscriptMatches) { + $placeholder = sprintf('', (string)$this->rand()); + + $this->noscriptPlaceholderComments[$placeholder] = $noscriptMatches[0]; + return $placeholder; + }, + $headMatches[0] + ); + }, + $html + ); } - return preg_replace_callback( - '#^.+?(?=]*>.*?#si', - function ($noscriptMatches) { - $placeholder = sprintf('', (string)$this->rand()); - - $this->noscriptPlaceholderComments[$placeholder] = $noscriptMatches[0]; - return $placeholder; - }, - $headMatches[0] - ); - }, - $html - ); + return $html; } /**