From 80adfe870bdfbfefdb6a58dea3e8208f37447cc3 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 10 Oct 2024 01:01:35 +0200 Subject: [PATCH 1/4] Fix coding style With php-cs-fixer 3.64.0, the `native_function_invocation` rule no longer passed. --- src/Readability.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Readability.php b/src/Readability.php index b0b815f..6fb88ad 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -668,10 +668,10 @@ class Readability implements LoggerAwareInterface $this->logger->debug(' content length less than 6 chars, 0 embeds and either 0 images or more than 2 images'); $toRemove = true; } elseif (!$isList && $weight < 25 && $linkDensity > 0.25) { - $this->logger->debug(' weight is ' . $weight . ' < 25 and link density is ' . sprintf('%.2f', $linkDensity) . ' > 0.25'); + $this->logger->debug(' weight is ' . $weight . ' < 25 and link density is ' . \sprintf('%.2f', $linkDensity) . ' > 0.25'); $toRemove = true; } elseif ($a > 2 && ($weight >= 25 && $linkDensity > 0.5)) { - $this->logger->debug(' more than 2 links and weight is ' . $weight . ' > 25 but link density is ' . sprintf('%.2f', $linkDensity) . ' > 0.5'); + $this->logger->debug(' more than 2 links and weight is ' . $weight . ' > 25 but link density is ' . \sprintf('%.2f', $linkDensity) . ' > 0.5'); $toRemove = true; } elseif ($embedCount > 3) { $this->logger->debug(' more than 3 embeds'); @@ -691,10 +691,10 @@ class Readability implements LoggerAwareInterface $this->logger->debug(' content length less than 10 chars and 0 images, or more than 2 images'); $toRemove = true; } elseif (!$isList && $weight < 25 && $linkDensity > 0.2) { - $this->logger->debug(' weight is ' . $weight . ' lower than 0 and link density is ' . sprintf('%.2f', $linkDensity) . ' > 0.2'); + $this->logger->debug(' weight is ' . $weight . ' lower than 0 and link density is ' . \sprintf('%.2f', $linkDensity) . ' > 0.2'); $toRemove = true; } elseif ($weight >= 25 && $linkDensity > 0.5) { - $this->logger->debug(' weight above 25 but link density is ' . sprintf('%.2f', $linkDensity) . ' > 0.5'); + $this->logger->debug(' weight above 25 but link density is ' . \sprintf('%.2f', $linkDensity) . ' > 0.5'); $toRemove = true; } elseif ((1 === $embedCount && $contentLength < 75) || $embedCount > 1) { $this->logger->debug(' 1 embed and content length smaller than 75 chars, or more than one embed'); From c7b10dcc45b3729d5a2d6469cb2b26495b45edd6 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 10 Oct 2024 01:25:41 +0200 Subject: [PATCH 2/4] Avoid E_STRICT constant It will be deprecated in PHP 8.4 and it is meaningless nowadays anyway: https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant The use of the constant was introduced in 175196d6c2e2a2cc920c5e1720639b770a2edd10. --- tests/ReadabilityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php index 3fb9dc0..1215f17 100644 --- a/tests/ReadabilityTest.php +++ b/tests/ReadabilityTest.php @@ -335,12 +335,12 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase public function testAutoClosingIframeNotThrowingException(): void { - $oldErrorReporting = error_reporting(\E_ALL | \E_STRICT); + $oldErrorReporting = error_reporting(\E_ALL); $oldDisplayErrors = ini_set('display_errors', '1'); // dummy function to be used to the next test set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) { throw new \Exception($errstr, $errno); - }, \E_ALL | \E_STRICT); + }); try { $data = ' From 5b9551d1e325f4a7060e1e64ee20bdbfcb632b8f Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 10 Oct 2024 01:06:13 +0200 Subject: [PATCH 3/4] ci: Add PHP 8.4 PHP 8.4 is in beta, with final version scheduled for November so it is time to start testing it. --- .github/workflows/continuous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3e2562c..b233fbe 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -24,6 +24,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" steps: - name: "Checkout" From da755013aadc3745ba5a13e9e77f6463ba959949 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 10 Oct 2024 08:42:00 +0200 Subject: [PATCH 4/4] Remove extra set_error_handler callback argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is unused and would cause an error on PHP ≥ 8.0: https://www.php.net/manual/en/function.set-error-handler.php#refsect1-function.set-error-handler-parameters Not sure if the handler is even necessary – it was introduced in 175196d6c2e2a2cc920c5e1720639b770a2edd10 but I did not manage to reproduce the original error (Entity 'nbsp' not defined). It was probably fixed by f2a43b476c039105cd0a4370b35b0244826913fa. --- tests/ReadabilityTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php index 1215f17..8a29629 100644 --- a/tests/ReadabilityTest.php +++ b/tests/ReadabilityTest.php @@ -338,7 +338,7 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $oldErrorReporting = error_reporting(\E_ALL); $oldDisplayErrors = ini_set('display_errors', '1'); // dummy function to be used to the next test - set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) { + set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { throw new \Exception($errstr, $errno); });