fixup! Use JSLikeHTMLElement in type hints

pull/93/head
Jan Tojnar 1 year ago
parent e36f2ed70f
commit abf670d02e
  1. 4
      src/Readability.php
  2. 10
      stubs/dom.stub

@ -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));

@ -11,14 +11,18 @@ class DOMDocument
/** @var JSLikeHTMLElement|null */
public $documentElement;
/** @var null */
public $ownerDocument;
/**
* @param string $name
* @return DOMNodeList<JSLikeHTMLElement>
*/
public function getElementsByTagName($name) {}
/**
* @param string $localName
* @param string $value
* @return JSLikeHTMLElement Officially, this can return false but PHPStan decided to ignore that: <https://github.com/phpstan/phpstan-src/pull/1569>
*/
public function createElement($localName, $value = '') {}
}
class DOMNode

Loading…
Cancel
Save