Skip to content

Commit bb29da7

Browse files
committed
Extends type support to include DOMCdataSection and DOMProcessingInstruction in various method signatures
1 parent 705feb5 commit bb29da7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/Nodes/DOM/DOMNodeList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __get($name)
4242
/**
4343
* Add node to the list.
4444
*/
45-
public function add(DOMNode|DOMElement|DOMText|DOMComment|DOMProcessingInstruction $node): DOMNodeList
45+
public function add(DOMNode|DOMElement|DOMText|DOMComment|DOMProcessingInstruction|DOMCdataSection $node): DOMNodeList
4646
{
4747
$this->items[] = $node;
4848
$this->length++;
@@ -53,7 +53,7 @@ public function add(DOMNode|DOMElement|DOMText|DOMComment|DOMProcessingInstructi
5353
/**
5454
* Get node.
5555
*/
56-
public function item(int $offset): DOMNode|DOMElement|DOMText|DOMComment|DOMProcessingInstruction
56+
public function item(int $offset): DOMNode|DOMElement|DOMText|DOMComment|DOMProcessingInstruction|DOMCdataSection
5757
{
5858
return $this->items[$offset];
5959
}

src/Nodes/NodeUtility.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use fivefilters\Readability\Nodes\DOM\DOMText;
1010
use fivefilters\Readability\Nodes\DOM\DOMComment;
1111
use fivefilters\Readability\Nodes\DOM\DOMNodeList;
12+
use fivefilters\Readability\Nodes\DOM\DOMCdataSection;
1213

1314
/**
1415
* Class NodeUtility.
@@ -121,7 +122,7 @@ public static function removeNode(DOMNode|DOMComment|DOMText|DOMElement $node):
121122
* Returns the next node. First checks for children (if the flag allows it), then for siblings, and finally
122123
* for parents.
123124
*/
124-
public static function getNextNode(DOMNode|DOMComment|DOMText|DOMElement|DOMDocument|DOMProcessingInstruction $originalNode, bool $ignoreSelfAndKids = false): DOMNode|DOMComment|DOMText|DOMElement|DOMDocument|DOMProcessingInstruction|null
125+
public static function getNextNode(DOMNode|DOMComment|DOMText|DOMElement|DOMDocument|DOMProcessingInstruction|DOMCdataSection $originalNode, bool $ignoreSelfAndKids = false): DOMNode|DOMComment|DOMText|DOMElement|DOMDocument|DOMProcessingInstruction|DOMCdataSection|null
125126
{
126127
/*
127128
* Traverse the DOM from node to node, starting at the node passed in.

src/Readability.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use fivefilters\Readability\Nodes\DOM\DOMProcessingInstruction;
99
use fivefilters\Readability\Nodes\DOM\DOMText;
1010
use fivefilters\Readability\Nodes\DOM\DOMComment;
11+
use fivefilters\Readability\Nodes\DOM\DOMCdataSection;
1112
use fivefilters\Readability\Nodes\NodeUtility;
1213
use Psr\Log\LoggerInterface;
1314
use Masterminds\HTML5;
@@ -961,7 +962,7 @@ private function textSimilarity(string $textA, string $textB): float
961962
/**
962963
* Checks if the node is a byline.
963964
*/
964-
private function checkByline(DOMNode|DOMText|DOMElement|DOMProcessingInstruction $node, string $matchString): bool
965+
private function checkByline(DOMNode|DOMText|DOMElement|DOMProcessingInstruction|DOMCdataSection $node, string $matchString): bool
965966
{
966967
if (!$this->configuration->getArticleByline()) {
967968
return false;
@@ -1755,7 +1756,7 @@ public function _fixLazyImages(DOMDocument $article): void
17551756
/**
17561757
* Remove the style attribute on every e and under.
17571758
**/
1758-
public function _cleanStyles(DOMDocument|DOMNode|DOMElement|DOMText $node): void
1759+
public function _cleanStyles(DOMDocument|DOMNode|DOMElement|DOMText|DOMProcessingInstruction|DOMCdataSection $node): void
17591760
{
17601761
if (property_exists($node, 'tagName') && $node->tagName === 'svg') {
17611762
return;

0 commit comments

Comments
 (0)