diff --git a/src/Readability.php b/src/Readability.php index e87aec6..8cf7202 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -28,9 +28,9 @@ class Readability implements LoggerAwareInterface public bool $convertLinksToFootnotes = false; public bool $revertForcedParagraphElements = false; - public ?\DOMElement $articleTitle; + public ?JSLikeHTMLElement $articleTitle; - public ?\DOMElement $articleContent; + public ?JSLikeHTMLElement $articleContent; public ?string $original_html; @@ -203,7 +203,7 @@ class Readability implements LoggerAwareInterface /** * Get article title element. */ - public function getTitle(): \DOMElement + public function getTitle(): JSLikeHTMLElement { return $this->articleTitle; } @@ -211,7 +211,7 @@ class Readability implements LoggerAwareInterface /** * Get article content element. */ - public function getContent(): \DOMElement + public function getContent(): JSLikeHTMLElement { return $this->articleContent; } @@ -394,7 +394,7 @@ class Readability implements LoggerAwareInterface */ public function prepArticle(\DOMNode $articleContent): void { - if (!$articleContent instanceof \DOMElement) { + if (!$articleContent instanceof JSLikeHTMLElement) { return; } @@ -590,7 +590,7 @@ class Readability implements LoggerAwareInterface /** * Remove extraneous break tags from a node. */ - public function killBreaks(\DOMElement $node): void + public function killBreaks(JSLikeHTMLElement $node): void { $html = $node->getInnerHTML(); $html = preg_replace($this->regexps['killBreaks'], '
', $html); diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php index cce4568..21f9bf7 100644 --- a/tests/ReadabilityTest.php +++ b/tests/ReadabilityTest.php @@ -5,7 +5,6 @@ namespace Tests\Readability; use Monolog\Handler\TestHandler; use Monolog\Logger; use Psr\Log\LoggerInterface; -use Readability\JSLikeHTMLElement; use Readability\Readability; class ReadabilityTest extends \PHPUnit\Framework\TestCase @@ -78,8 +77,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertFalse($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertStringContainsString('Sorry, Readability was unable to parse this page for content.', $readability->getContent()->getInnerHtml()); } @@ -90,8 +87,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('
getContent()->getInnerHtml()); @@ -103,8 +98,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('
getContent()->getInnerHtml()); @@ -116,8 +109,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('
getContent()->getInnerHtml()); @@ -130,8 +121,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('
getContent()->getInnerHtml()); @@ -146,8 +135,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('
getContent()->getInnerHtml()); @@ -161,8 +148,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('
getContent()->getInnerHtml()); @@ -175,8 +160,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertStringContainsString('alt="article"', $readability->getContent()->getInnerHtml()); $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml()); @@ -189,8 +172,6 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $res = $readability->init(); $this->assertTrue($res); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getContent()); - $this->assertInstanceOf(JSLikeHTMLElement::class, $readability->getTitle()); $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml()); $this->assertStringNotContainsString('