Skip to content

Commit 79a0dd0

Browse files
committed
Use method param type hints instead of PHPDoc
Since we require PHP 7.4, contravariance in param types is supported, so we do not need to worry about subclasses that widen the param type. It will be only breaking in the unlikely case a subclass uses a type that contradicts the PHPDoc type annotation and does not not extend `DOMNode`. Also fix the type annotation since some invocations pass it a `DOMText`, an arbitrary sibling/child `DOMNode` or even `null`.
1 parent 93fc76a commit 79a0dd0

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'ordered_imports' => true,
2323
'php_unit_strict' => false,
2424
'phpdoc_order' => true,
25+
'phpdoc_to_param_type' => true,
2526
// 'psr4' => true,
2627
'strict_comparison' => true,
2728
'strict_param' => true,

src/Readability.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,8 @@ public function prepArticle(\DOMNode $articleContent): void
546546
/**
547547
* Get the inner text of a node.
548548
* This also strips out any excess whitespace to be found.
549-
*
550-
* @param \DOMElement $e
551-
* @param bool $normalizeSpaces (default: true)
552-
* @param bool $flattenLines (default: false)
553549
*/
554-
public function getInnerText($e, bool $normalizeSpaces = true, bool $flattenLines = false): string
550+
public function getInnerText(?\DOMNode $e, bool $normalizeSpaces = true, bool $flattenLines = false): string
555551
{
556552
if (null === $e || !isset($e->textContent) || '' === $e->textContent) {
557553
return '';

0 commit comments

Comments
 (0)