Skip to content

Commit c5a5f6a

Browse files
committed
composer: Update dependencies
The SimplePie bump required replacing `SimplePieFileGuzzle` with newly introduced PSR-18 support due to PHPStan complaining about a ton of deprecations and type mismatch in `set_curl_options` hack. Changelogs summary: - php-http/message-factory removed (installed version was 1.1.0) - bcosca/fatfree-core updated from 3.9.0 to 3.9.1 patch See changes: f3-factory/fatfree-core@3.9.0...3.9.1 Release notes: https://github.com/f3-factory/fatfree-core/releases/tag/3.9.1 - guzzlehttp/psr7 updated from 2.7.0 to 2.8.0 minor See changes: guzzle/psr7@2.7.0...2.8.0 Release notes: https://github.com/guzzle/psr7/releases/tag/2.8.0 - guzzlehttp/promises updated from 2.0.4 to 2.3.0 minor See changes: guzzle/promises@2.0.4...2.3.0 Release notes: https://github.com/guzzle/promises/releases/tag/2.3.0 - guzzlehttp/guzzle updated from 7.9.2 to 7.10.0 minor See changes: guzzle/guzzle@7.9.2...7.10.0 Release notes: https://github.com/guzzle/guzzle/releases/tag/7.10.0 - symfony/polyfill-php80 updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-php80@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-php80/releases/tag/v1.33.0 - symfony/polyfill-php84 installed in version v1.33.0 Release notes: https://github.com/symfony/polyfill-php84/releases/tag/v1.33.0 - symfony/polyfill-php81 updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-php81@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-php81/releases/tag/v1.33.0 - symfony/polyfill-mbstring updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-mbstring@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-mbstring/releases/tag/v1.33.0 - symfony/polyfill-php73 updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-php73@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-php73/releases/tag/v1.33.0 - symfony/polyfill-ctype updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-ctype@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-ctype/releases/tag/v1.33.0 - symfony/polyfill-intl-normalizer updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-intl-normalizer@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-intl-normalizer/releases/tag/v1.33.0 - symfony/polyfill-intl-grapheme updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-intl-grapheme@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-intl-grapheme/releases/tag/v1.33.0 - react/promise updated from v3.2.0 to v3.3.0 minor See changes: reactphp/promise@v3.2.0...v3.3.0 Release notes: https://github.com/reactphp/promise/releases/tag/v3.3.0 - fidry/cpu-core-counter updated from 1.2.0 to 1.3.0 minor See changes: theofidry/cpu-core-counter@1.2.0...1.3.0 Release notes: https://github.com/theofidry/cpu-core-counter/releases/tag/1.3.0 - composer/semver updated from 3.4.3 to 3.4.4 patch See changes: composer/semver@3.4.3...3.4.4 Release notes: https://github.com/composer/semver/releases/tag/3.4.4 - friendsofphp/php-cs-fixer updated from v3.72.0 to v3.88.1 patch See changes: PHP-CS-Fixer/PHP-CS-Fixer@v3.72.0...v3.88.1 Release notes: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/tag/v3.88.0 Release notes: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/tag/v3.88.1 - symfony/polyfill-intl-idn updated from v1.31.0 to v1.33.0 minor See changes: symfony/polyfill-intl-idn@v1.31.0...v1.33.0 Release notes: https://github.com/symfony/polyfill-intl-idn/releases/tag/v1.33.0 - simplepie/simplepie updated from 1.8.1 to 1.9.0 minor See changes: simplepie/simplepie@1.8.1...1.9.0 Release notes: https://github.com/simplepie/simplepie/releases/tag/1.9.0 - masterminds/html5 updated from 2.9.0 to 2.10.0 minor See changes: Masterminds/html5-php@2.9.0...2.10.0 Release notes: https://github.com/Masterminds/html5-php/releases/tag/2.10.0 - j0k3r/php-readability updated from 1.2.12 to 1.3.0 minor See changes: j0k3r/php-readability@1.2.12...1.3.0 Release notes: https://github.com/j0k3r/php-readability/releases/tag/1.3.0 - j0k3r/httplug-ssrf-plugin updated from v2.0.2 to v3.0.1 major See changes: j0k3r/httplug-ssrf-plugin@v2.0.2...v3.0.1 Release notes: https://github.com/j0k3r/httplug-ssrf-plugin/releases/tag/v3.0.1 - j0k3r/graby-site-config updated from 1.0.197 to 1.0.203 patch See changes: j0k3r/graby-site-config@1.0.197...1.0.203 Release notes: https://github.com/j0k3r/graby-site-config/releases/tag/1.0.203 - j0k3r/graby updated from 2.4.6 to v2.5.0 minor See changes: j0k3r/graby@2.4.6...v2.5.0 Release notes: https://github.com/j0k3r/graby/releases/tag/v2.5.0 - phpstan/phpstan updated from 2.1.8 to 2.1.29 patch See changes: phpstan/phpstan-phar-composer-source@phpstan:2.1.8...phpstan:2.1.29 Release notes: https://github.com/phpstan/phpstan-phar-composer-source/releases/tag/2.1.29 - phpstan/phpstan-deprecation-rules updated from 2.0.1 to 2.0.3 patch See changes: phpstan/phpstan-deprecation-rules@2.0.1...2.0.3 Release notes: https://github.com/phpstan/phpstan-deprecation-rules/releases/tag/2.0.3 - symfony/phpunit-bridge updated from v7.2.0 to v7.3.3 minor See changes: symfony/phpunit-bridge@v7.2.0...v7.3.3 Release notes: https://github.com/symfony/phpunit-bridge/releases/tag/v7.3.3 - vstelmakh/url-highlight updated from v3.1.1 to v3.1.2 patch See changes: vstelmakh/url-highlight@v3.1.1...v3.1.2 Release notes: https://github.com/vstelmakh/url-highlight/releases/tag/v3.1.2
1 parent ec5cb62 commit c5a5f6a

File tree

8 files changed

+372
-365
lines changed

8 files changed

+372
-365
lines changed

composer.lock

Lines changed: 332 additions & 258 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.dist.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ parameters:
1818
- utils/PHPStan/Stubs/IcoFileLoader.stub
1919

2020
ignoreErrors:
21-
# The arguments are provided by SimplePie and we want the value of a later one.
22-
- '(Constructor of class helpers\\SimplePieFileGuzzle has an unused parameter \$force_fsockopen\.)'
23-
2421
# Bad PHPStan typing rules.
2522
- '(Parameter #3 \$namespace of method XMLWriter::writeAttributeNs\(\) expects string, null given\.)'
2623

src/common.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use helpers\Configuration;
66
use helpers\DatabaseConnection;
7+
use helpers\WebClient;
78
use Monolog\Formatter\LineFormatter;
89
use Monolog\Handler\ErrorLogHandler;
910
use Monolog\Handler\NullHandler;
1011
use Monolog\Handler\StreamHandler;
1112
use Monolog\Logger;
1213
use Psr\Container\ContainerInterface;
14+
use Psr\Http\Client\ClientInterface;
1315
use Psr\SimpleCache\CacheInterface;
1416
use Slince\Di\Container;
1517
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
@@ -252,6 +254,11 @@ function(string $pattern, string $text): bool {
252254
->setShared(true)
253255
;
254256

257+
$container
258+
->register(ClientInterface::class, WebClient::class)
259+
->setShared(true)
260+
;
261+
255262
$container
256263
->register(ContainerInterface::class, $container)
257264
->setShared(true)

src/helpers/FeedReader.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace helpers;
66

7+
use GuzzleHttp\Psr7\HttpFactory;
8+
use Psr\Http\Client\ClientInterface;
79
use Psr\SimpleCache\CacheInterface;
810
use SimplePie\SimplePie;
911

@@ -14,8 +16,9 @@ class FeedReader {
1416
private SimplePie $simplepie;
1517

1618
public function __construct(
19+
HttpFactory $httpFactory,
1720
SimplePie $simplepie,
18-
WebClient $webClient,
21+
ClientInterface $webClient,
1922
?CacheInterface $cache = null
2023
) {
2124
$this->simplepie = $simplepie;
@@ -25,14 +28,14 @@ public function __construct(
2528
$this->simplepie->set_cache($cache);
2629
}
2730

28-
// abuse set_curl_options since there is no sane way to pass data to SimplePie\File
29-
$this->simplepie->set_curl_options([
30-
WebClient::class => $webClient,
31-
]);
31+
$this->simplepie->set_http_client(
32+
$webClient,
33+
$httpFactory,
34+
$httpFactory,
35+
);
3236

33-
$this->simplepie->get_registry()->register(\SimplePie\File::class, SimplePieFileGuzzle::class, true);
37+
// @phpstan-ignore argument.type (https://github.com/simplepie/simplepie/pull/946)
3438
$this->simplepie->set_autodiscovery_level(SimplePie::LOCATOR_AUTODISCOVERY | SimplePie::LOCATOR_LOCAL_EXTENSION | SimplePie::LOCATOR_LOCAL_BODY);
35-
$this->simplepie->set_useragent($webClient->getUserAgent());
3639
}
3740

3841
/**
@@ -48,7 +51,6 @@ public function load(string $url): array {
4851
@$this->simplepie->init();
4952

5053
// on error retry with force_feed
51-
// @phpstan-ignore-next-line notIdentical.alwaysTrue (The upstream type is incorrect: https://github.com/simplepie/simplepie/pull/903)
5254
if ($this->simplepie->error() !== null) {
5355
@$this->simplepie->set_autodiscovery_level(SimplePie::LOCATOR_NONE);
5456
@$this->simplepie->force_feed(true);

src/helpers/Image.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public function loadImage(
157157
// get image type
158158
if (extension_loaded('imagick')) {
159159
// check for svgz or svg
160+
// @phpstan-ignore notIdentical.alwaysTrue (fatfree includes gzdecode polyfill which has incorrect phpdoc type)
160161
if (str_starts_with($data, "\x1f\x8b") && ($d = gzdecode($data)) !== false) {
161162
$data = $d;
162163
}

src/helpers/SimplePieFileGuzzle.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/helpers/WebClient.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
use Fossar\GuzzleTranscoder\GuzzleTranscoder;
99
use GuzzleHttp;
1010
use GuzzleHttp\HandlerStack;
11+
use GuzzleHttp\Psr7\HttpFactory;
1112
use Monolog\Logger;
13+
use Override;
14+
use Psr\Http\Client\ClientInterface;
15+
use Psr\Http\Message\RequestInterface;
1216
use Psr\Http\Message\ResponseInterface;
1317

1418
/**
@@ -18,13 +22,19 @@
1822
* @license GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html)
1923
* @author Alexandre Rossi <[email protected]>
2024
*/
21-
class WebClient {
25+
class WebClient implements ClientInterface {
2226
private Configuration $configuration;
2327
private ?GuzzleHttp\Client $httpClient = null;
28+
private HttpFactory $httpFactory;
2429
private Logger $logger;
2530

26-
public function __construct(Configuration $configuration, Logger $logger) {
31+
public function __construct(
32+
Configuration $configuration,
33+
HttpFactory $httpFactory,
34+
Logger $logger
35+
) {
2736
$this->configuration = $configuration;
37+
$this->httpFactory = $httpFactory;
2838
$this->logger = $logger;
2939
}
3040

@@ -113,8 +123,7 @@ public function getUserAgent(?array $agentInfo = null): string {
113123
* @throws Exception Unless 200 0K response is received
114124
*/
115125
public function request(string $url, ?string $agentInfo = null): string {
116-
$http = $this->getHttpClient();
117-
$response = $http->get($url);
126+
$response = $this->sendRequest($this->httpFactory->createRequest('GET', $url));
118127
$data = (string) $response->getBody();
119128

120129
if ($response->getStatusCode() !== 200) {
@@ -124,6 +133,13 @@ public function request(string $url, ?string $agentInfo = null): string {
124133
return $data;
125134
}
126135

136+
#[Override]
137+
public function sendRequest(RequestInterface $request): ResponseInterface {
138+
$http = $this->getHttpClient();
139+
140+
return $http->send($request);
141+
}
142+
127143
/**
128144
* Get effective URL of the response.
129145
* RedirectMiddleware will need to be enabled for this to work.

tests/Spouts/YouTubeTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use GuzzleHttp\HandlerStack;
1111
use GuzzleHttp\Psr7\Response;
1212
use helpers\HtmlString;
13-
use helpers\WebClient;
1413
use Monolog\Logger;
1514
use PHPUnit\Framework\TestCase;
15+
use Psr\Http\Client\ClientInterface;
1616
use Slince\Di\Container;
1717
use spouts\youtube\youtube;
1818

@@ -62,13 +62,7 @@ function(array $remoteFile): Response {
6262
->setShared(true)
6363
;
6464
$container
65-
->register(WebClient::class, function() use ($httpClient) {
66-
$stub = $this->createMock(WebClient::class);
67-
$stub->method('getHttpClient')->willReturn($httpClient);
68-
69-
return $stub;
70-
})
71-
;
65+
->register(ClientInterface::class, $httpClient);
7266

7367
$yt = $container->get(youtube::class);
7468

0 commit comments

Comments
 (0)