diff --git a/src/Readability.php b/src/Readability.php index 97d53f0..5c36b71 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -146,7 +146,7 @@ class Readability implements LoggerAwareInterface protected $domainRegExp = null; /** - * @var ?\DOMElement + * @var ?\JSLikeHTMLElement */ protected $body = null; @@ -603,7 +603,7 @@ class Readability implements LoggerAwareInterface * This is the amount of text that is inside a link divided by the total text in the node. * Can exclude external references to differentiate between simple text and menus/infoblocks. */ - public function getLinkDensity(\DOMElement $e, bool $excludeExternal = false): float + public function getLinkDensity(JSLikeHTMLElement $e, bool $excludeExternal = false): float { $links = $e->getElementsByTagName('a'); $textLength = mb_strlen($this->getInnerText($e, true, true)); diff --git a/stubs/dom.stub b/stubs/dom.stub index ac85e9d..09a39d6 100644 --- a/stubs/dom.stub +++ b/stubs/dom.stub @@ -11,14 +11,18 @@ class DOMDocument /** @var JSLikeHTMLElement|null */ public $documentElement; - /** @var null */ - public $ownerDocument; - /** * @param string $name * @return DOMNodeList */ public function getElementsByTagName($name) {} + + /** + * @param string $localName + * @param string $value + * @return JSLikeHTMLElement Officially, this can return false but PHPStan decided to ignore that: + */ + public function createElement($localName, $value = '') {} } class DOMNode