diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f195fa9f8..4f4d5ab8f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,7 +10,6 @@ parameters: - src/ ignoreErrors: - '#^PHPDoc tag @throws with type AmpProject\\Exception\\FailedRemoteRequest is not subtype of Throwable$#' - - '#^Parameter \#1 (\$exception_handler|\$callback) of function set_exception_handler expects#' excludePaths: analyse: - src/FakeEnum.php diff --git a/src/Cli/Options.php b/src/Cli/Options.php index ff5a234be..5efd264f4 100644 --- a/src/Cli/Options.php +++ b/src/Cli/Options.php @@ -535,6 +535,7 @@ public function help() */ private function readPHPArgv() { + /** @var list|null $argv */ global $argv; if (is_array($argv)) { diff --git a/src/Dom/Document/Filter/DeduplicateTag.php b/src/Dom/Document/Filter/DeduplicateTag.php index a0a87f1d1..db0106031 100644 --- a/src/Dom/Document/Filter/DeduplicateTag.php +++ b/src/Dom/Document/Filter/DeduplicateTag.php @@ -71,9 +71,7 @@ public function afterLoad(Document $document) } // Avoid doing the above query again if possible. - if (in_array($tagName, [Tag::HEAD, Tag::BODY], true)) { - $document->$tagName = $mainTag; - } + $document->$tagName = $mainTag; } } } diff --git a/src/Dom/Document/Filter/MustacheScriptTemplates.php b/src/Dom/Document/Filter/MustacheScriptTemplates.php index 800c403aa..248811738 100644 --- a/src/Dom/Document/Filter/MustacheScriptTemplates.php +++ b/src/Dom/Document/Filter/MustacheScriptTemplates.php @@ -8,6 +8,7 @@ use AmpProject\Dom\Document\BeforeLoadFilter; use AmpProject\Dom\Document\BeforeSaveFilter; use AmpProject\Html\Tag; +use DOMElement; /** * Filter to handle the script[template="amp-mustache"]. @@ -128,8 +129,9 @@ static function ($matches) use ($mustacheTagPlaceholders) { // unterminated entity reference "baz". When the attribute value is updated via setAttribute() this // same problem does not occur, so that is why the following is used. - // @phpstan-ignore method.notFound - $attribute->parentNode->setAttribute($attribute->nodeName, $value); + if ($attribute->parentNode instanceof DOMElement) { + $attribute->parentNode->setAttribute($attribute->nodeName, $value); + } $this->mustacheTagsReplaced = true; } diff --git a/src/RemoteRequest/TemporaryFileCachedRemoteGetRequest.php b/src/RemoteRequest/TemporaryFileCachedRemoteGetRequest.php index bf534f560..b9f8d80e8 100644 --- a/src/RemoteRequest/TemporaryFileCachedRemoteGetRequest.php +++ b/src/RemoteRequest/TemporaryFileCachedRemoteGetRequest.php @@ -86,7 +86,7 @@ public function get($url, $headers = []) // phpcs:disable PHPCompatibility.FunctionUse.NewFunctionParameters.unserialize_optionsFound if ($cachedResponse !== false) { - $cachedResponse = unserialize($cachedResponse, [RemoteGetRequestResponse::class]); + $cachedResponse = unserialize($cachedResponse, ['allowed_classes' => [RemoteGetRequestResponse::class]]); } // phpcs:enable PHPCompatibility.FunctionUse.NewFunctionParameters.unserialize_optionsFound