Compare commits

...

3 Commits

Author SHA1 Message Date
Jérémy Benoist 03533f5e4f
Merge pull request #111 from j0k3r/fix/tidy-php85 4 days ago
Jeremy Benoist 009b4ab9b8
Add PHP 8.5 on CI 4 days ago
Jeremy Benoist f9e73fb49a
Fix bad encoding for `tidy_repair_string` 4 days ago
  1. 1
      .github/workflows/continuous-integration.yml
  2. 6
      src/Readability.php
  3. 3
      tests/ReadabilityTest.php

@ -25,6 +25,7 @@ jobs:
- "8.2" - "8.2"
- "8.3" - "8.3"
- "8.4" - "8.4"
- "8.5"
steps: steps:
- name: "Checkout" - name: "Checkout"

@ -88,7 +88,7 @@ class Readability implements LoggerAwareInterface
'enclose-text' => true, 'enclose-text' => true,
'merge-divs' => true, 'merge-divs' => true,
// 'merge-spans' => true, // 'merge-spans' => true,
'input-encoding' => '????', 'input-encoding' => 'utf8',
'output-encoding' => 'utf8', 'output-encoding' => 'utf8',
'hide-comments' => true, 'hide-comments' => true,
]; ];
@ -1118,7 +1118,7 @@ class Readability implements LoggerAwareInterface
$topCandidates = array_filter( $topCandidates = array_filter(
$topCandidates, $topCandidates,
fn ($v, $idx) => 0 === $idx || null !== $v, static fn ($v, $idx) => 0 === $idx || null !== $v,
\ARRAY_FILTER_USE_BOTH \ARRAY_FILTER_USE_BOTH
); );
$topCandidate = $topCandidates[0]; $topCandidate = $topCandidates[0];
@ -1481,7 +1481,7 @@ class Readability implements LoggerAwareInterface
private function hasSingleTagInsideElement(\DOMElement $node, string $tag): bool private function hasSingleTagInsideElement(\DOMElement $node, string $tag): bool
{ {
$childNodes = iterator_to_array($node->childNodes); $childNodes = iterator_to_array($node->childNodes);
$children = array_filter($childNodes, fn ($childNode) => $childNode instanceof \DOMElement); $children = array_filter($childNodes, static fn ($childNode) => $childNode instanceof \DOMElement);
// There should be exactly 1 element child with given tag // There should be exactly 1 element child with given tag
if (1 !== \count($children) || $children[0]->nodeName !== $tag) { if (1 !== \count($children) || $children[0]->nodeName !== $tag) {

@ -21,6 +21,7 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase
public function testConstructDefault(): void public function testConstructDefault(): void
{ {
$readability = $this->getReadability(''); $readability = $this->getReadability('');
$this->assertSame('utf8', $readability->tidy_config['input-encoding']);
$readability->init(); $readability->init();
$this->assertNull($readability->url); $this->assertNull($readability->url);
@ -323,7 +324,7 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase
$oldErrorReporting = error_reporting(\E_ALL); $oldErrorReporting = error_reporting(\E_ALL);
$oldDisplayErrors = ini_set('display_errors', '1'); $oldDisplayErrors = ini_set('display_errors', '1');
// dummy function to be used to the next test // dummy function to be used to the next test
set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { set_error_handler(static function (int $errno, string $errstr, string $errfile, int $errline) {
throw new \Exception($errstr, $errno); throw new \Exception($errstr, $errno);
}); });

Loading…
Cancel
Save