Repository navigation
Conversation
PHPStan has improved a lot since version 1.12 used by SimplePie until now. Take advantage of explicit PHPStan phpVersion range. Define explicit range of minimum and maximum PHP version supported. Useful e.g. for function signatures, which have changed over time https://phpstan.org/config-reference#phpversion Do not run PHPStan for PHP < 7.4 but the tests are covered by phpVersion min, so it is actually enough to run PHPStan once on any supported PHP version. Cannot support PHPUnit >= 10 at the same time as PHP 7.2.
Keep change for another PR
Co-authored-by: Jan Tojnar <[email protected]>
# Conflicts: # tests/Integration/HTTP/ClientsTest.php
composer.json now requires PHP 7.4, so raise phpVersion.min to match. That also clears the parse_iri() return type, since PHP 7.4 fills trailing unmatched groups with PREG_UNMATCHED_AS_NULL. curlInit() is analysed against the PHP 7 cURL signatures, so type it as a resource and throw if curl_init() fails. Skip CURLOPT_REFERER and CURLOPT_USERAGENT when empty, which sends the same request as setting them to an empty string.
| "phpstan/phpstan": "~2.1.25", | ||
| "phpstan/phpstan-phpunit": "~2.0.7", |
There was a problem hiding this comment.
| "phpstan/phpstan": "~2.1.25", | |
| "phpstan/phpstan-phpunit": "~2.0.7", | |
| "phpstan/phpstan": "~2.3.5", | |
| "phpstan/phpstan-phpunit": "~2.1.2", |
There was a problem hiding this comment.
Applied in 36c181f, after merging current master. PHPStan 2.3.6 with phpstan-phpunit 2.1.2 reports no errors, with and without mf2 installed.
--fix-ignored now offers to replace the ignored phpunit.assertCount in SimplePieTest::testMicroformatItems() with assertCount(). I left it as is to keep this PR to the version bump.
There was a problem hiding this comment.
I have applied the assertCount() suggestion in my own branch. I think it is OK to fix it at the same time since it is related to the PHPStan upgrade, but up to maintainers
There was a problem hiding this comment.
Applied in f5b987b: testMicroformatItems() now uses assertCount() and the ignore is gone. PHPStan 2.3.6 reports no errors, and the suite shows the same failures as master.
Currently, SimplePie uses legacy DOMDocument parsing, which outputs potentially problematic HTML, not correctly sanitised.
This breaks the assumption that one can use something like `<div><!-- some HTML sanitized from SimplePie --></div>`.
```
--- Expected
+++ Actual
@@ @@
'<ul>
- <li><div></div></li>
+ <li><div>
<li>Item</li>
-</ul>'
+</div></li></ul>'
```
When shown in a compliant Web browser, several tags will be wrongly closed, breaking the layout of the client.
This PR patches SimplePie to use the modern parser and code syntax, while maintaining a best-effort polyfill for legacy PHP versions < 8.4.
Depends on:
SimplePie: Upgrade to PHPStan 2
* FreshRSS/simplepie#97
* simplepie/simplepie#939
* simplepie/simplepie#1019
SimplePie: Use PHP 8.4+ \Dom classes and functions
* FreshRSS/simplepie#98
* simplepie/simplepie#1021
SimplePie: Add unit test for HTML5 sanitizing compliance
* simplepie/simplepie#1022
SimplePie: Remove obsolete xml_is_sane and XMLReader fallback
* simplepie/simplepie#1023
CssXPath: Add support for case insensitivity
* phpgt/CssXPath#256
fix #5201
fix #6830
fix #6831
~5% faster for HTML sanitising.
Remove SimpleXML. Remove XMLReader.
This PR carries #939 (PHPStan 2, by @Alkarex) over to current master, as agreed in #939 (comment). His commits are kept as they are, with master merged in on top, so the history and authorship of #939 stay intact.
On top of the merge:
tests/Integration/HTTP/ClientsTest.phptakes master's side, since SimplePie: Avoid requesting local files usingHTTP\Client#993/File,Psr18Client: Remove support for local files #994 removed local file fetching. ThestaticMethod.alreadyNarrowedTypeignore went with the old assertions.phpVersion.minis now 70400, matchingcomposer.jsonsince Require PHP 7.4 or newer #1006. This also clears theIRI::parse_iri()error: on PHP 7.4PREG_UNMATCHED_AS_NULLfills trailing unmatched groups, so the shape is always complete.File::curlInit()(added after Upgrade to PHPStan 2 #939 was opened) was typed@return \CurlHandle, which PHPStan 2 rejects under a 7.4 to 8.5 range because it checks against the PHP 7 cURL signatures. It's now@return resourceand throws ifcurl_init()returns false.CURLOPT_REFERERandCURLOPT_USERAGENTare skipped when empty: I checked that libcurl sends the same request either way (noUser-AgentorRefererheader).PHPStan 2.1.56 reports no errors, both with and without
mf2/mf2installed (CI removes it on PHP 8.4+). The test suite gives the same results as master locally (PHP 8.5.11, PHPUnit 9.6), with the same failing test names on both.Supersedes #939.