Skip to content

Commit 3519a1e

Browse files
authored
Merge pull request #341 from j0k3r/fix/2.x-update-deps
[2.x] Update deps
2 parents a8524b4 + b1aff11 commit 3519a1e

File tree

15 files changed

+80
-94
lines changed

15 files changed

+80
-94
lines changed

.github/workflows/coding-standards.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ name: "CS"
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- "master"
7+
- "2.x"
78
push:
89
branches:
9-
- master
10+
- "master"
11+
- "2.x"
1012

1113
jobs:
1214
coding-standards:
@@ -16,11 +18,11 @@ jobs:
1618
strategy:
1719
matrix:
1820
php:
19-
- "7.3"
21+
- "7.4"
2022

2123
steps:
2224
- name: "Checkout"
23-
uses: "actions/checkout@v2"
25+
uses: "actions/checkout@v4"
2426

2527
- name: "Install PHP"
2628
uses: "shivammathur/setup-php@v2"
@@ -33,7 +35,7 @@ jobs:
3335
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3436

3537
- name: "Install dependencies with Composer"
36-
uses: "ramsey/composer-install@v1"
38+
uses: "ramsey/composer-install@v2"
3739

3840
- name: "Run PHP CS Fixer"
3941
run: "php vendor/bin/php-cs-fixer fix --verbose --dry-run --format=checkstyle | cs2pr"

.github/workflows/continuous-integration.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
pull_request:
55
branches:
66
- "master"
7+
- "2.x"
78
push:
89
branches:
910
- "master"
11+
- "2.x"
1012

1113
env:
1214
fail-fast: true
@@ -24,10 +26,13 @@ jobs:
2426
- "7.3"
2527
- "7.4"
2628
- "8.0"
29+
- "8.1"
30+
- "8.2"
31+
- "8.3"
2732

2833
steps:
2934
- name: "Checkout"
30-
uses: "actions/checkout@v2"
35+
uses: "actions/checkout@v4"
3136
with:
3237
fetch-depth: 2
3338

@@ -43,7 +48,7 @@ jobs:
4348
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4449

4550
- name: "Install dependencies with Composer"
46-
uses: "ramsey/composer-install@v1"
51+
uses: "ramsey/composer-install@v2"
4752

4853
- name: "Setup logs"
4954
run: "mkdir -p build/logs"
@@ -62,7 +67,7 @@ jobs:
6267

6368
steps:
6469
- name: "Checkout"
65-
uses: "actions/checkout@v2"
70+
uses: "actions/checkout@v4"
6671
with:
6772
fetch-depth: 2
6873

@@ -78,7 +83,7 @@ jobs:
7883
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7984

8085
- name: "Install dependencies with Composer"
81-
uses: "ramsey/composer-install@v1"
86+
uses: "ramsey/composer-install@v2"
8287

8388
- name: "Setup logs"
8489
run: "mkdir -p build/logs"
@@ -108,7 +113,7 @@ jobs:
108113

109114
steps:
110115
- name: "Checkout"
111-
uses: "actions/checkout@v2"
116+
uses: "actions/checkout@v4"
112117
with:
113118
fetch-depth: 2
114119

@@ -124,7 +129,7 @@ jobs:
124129
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125130

126131
- name: "Install dependencies with Composer"
127-
uses: "ramsey/composer-install@v1"
132+
uses: "ramsey/composer-install@v2"
128133
with:
129134
dependency-versions: "lowest"
130135

@@ -145,7 +150,7 @@ jobs:
145150

146151
steps:
147152
- name: "Checkout"
148-
uses: "actions/checkout@v2"
153+
uses: "actions/checkout@v4"
149154
with:
150155
fetch-depth: 2
151156

@@ -161,7 +166,7 @@ jobs:
161166
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162167

163168
- name: "Install dependencies with Composer"
164-
uses: "ramsey/composer-install@v1"
169+
uses: "ramsey/composer-install@v2"
165170

166171
- name: "Setup adapter: Guzzle 5"
167172
run: |
@@ -185,7 +190,7 @@ jobs:
185190

186191
steps:
187192
- name: "Checkout"
188-
uses: "actions/checkout@v2"
193+
uses: "actions/checkout@v4"
189194
with:
190195
fetch-depth: 2
191196

@@ -201,7 +206,7 @@ jobs:
201206
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
202207

203208
- name: "Install dependencies with Composer"
204-
uses: "ramsey/composer-install@v1"
209+
uses: "ramsey/composer-install@v2"
205210

206211
- name: "Setup adapter: Guzzle 7"
207212
run: |
@@ -225,7 +230,7 @@ jobs:
225230

226231
steps:
227232
- name: "Checkout"
228-
uses: "actions/checkout@v2"
233+
uses: "actions/checkout@v4"
229234
with:
230235
fetch-depth: 2
231236

@@ -241,13 +246,12 @@ jobs:
241246
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
242247

243248
- name: "Install dependencies with Composer"
244-
uses: "ramsey/composer-install@v1"
249+
uses: "ramsey/composer-install@v2"
245250

246251
- name: "Setup adapter: cURL"
247252
run: |
248253
composer remove php-http/guzzle6-adapter --dev -n
249254
composer require php-http/curl-client --dev -n
250-
composer require zendframework/zend-diactoros --dev -n
251255
252256
- name: "Setup logs"
253257
run: "mkdir -p build/logs"
@@ -266,7 +270,7 @@ jobs:
266270

267271
steps:
268272
- name: "Checkout"
269-
uses: "actions/checkout@v2"
273+
uses: "actions/checkout@v4"
270274
with:
271275
fetch-depth: 2
272276

@@ -282,7 +286,7 @@ jobs:
282286
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
283287

284288
- name: "Install dependencies with Composer"
285-
uses: "ramsey/composer-install@v1"
289+
uses: "ramsey/composer-install@v2"
286290

287291
- name: "Setup logs"
288292
run: "mkdir -p build/logs"

composer.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
"ext-curl": "*",
2020
"ext-tidy": "*",
2121
"fossar/htmlawed": "^1.2.7",
22-
"http-interop/http-factory-guzzle": "^1.0",
23-
"j0k3r/graby-site-config": "^1.0.110",
22+
"http-interop/http-factory-guzzle": "^1.1",
23+
"j0k3r/graby-site-config": "^1.0.181",
2424
"j0k3r/httplug-ssrf-plugin": "^2.0",
25-
"j0k3r/php-readability": "^1.2.3",
25+
"j0k3r/php-readability": "^1.2.10",
2626
"monolog/monolog": "^1.18.0|^2.0",
27-
"php-http/client-common": "^2.3",
28-
"php-http/discovery": "^1.12",
29-
"php-http/httplug": "^2.2",
30-
"php-http/message": "^1.9",
31-
"simplepie/simplepie": "^1.5",
32-
"smalot/pdfparser": "^1.0",
33-
"symfony/options-resolver": "^3.4|^4.4|^5.3|^6.0",
27+
"php-http/client-common": "^2.7",
28+
"php-http/discovery": "^1.19",
29+
"php-http/httplug": "^2.4",
30+
"php-http/message": "^1.14",
31+
"simplepie/simplepie": "^1.7",
32+
"smalot/pdfparser": "^1.1",
33+
"symfony/options-resolver": "^3.4|^4.4|^5.3|^6.0|^7.0",
3434
"true/punycode": "^2.1",
3535
"guzzlehttp/psr7": "^1.5.0|^2.0"
3636
},
@@ -43,7 +43,7 @@
4343
"phpstan/phpstan": "^0.12",
4444
"phpstan/phpstan-deprecation-rules": "^0.12",
4545
"phpstan/phpstan-phpunit": "^0.12",
46-
"symfony/phpunit-bridge": "^5.3"
46+
"symfony/phpunit-bridge": "^6.4.1"
4747
},
4848
"extra": {
4949
"branch-alias": {
@@ -61,6 +61,10 @@
6161
}
6262
},
6363
"config": {
64-
"sort-packages": true
64+
"sort-packages": true,
65+
"allow-plugins": {
66+
"php-http/discovery": true,
67+
"phpstan/extension-installer": true
68+
}
6569
}
6670
}

phpunit.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
</listener>
3939
</listeners>
4040

41+
<php>
42+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0" />
43+
</php>
44+
4145
<!-- <logging>
4246
<log type="coverage-html" target="build" lowUpperBound="35" highLowerBound="70"/>
4347
</logging> -->

src/Extractor/ContentExtractor.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ class ContentExtractor
2121
private $xpath;
2222
private $html;
2323
private $config;
24-
private $siteConfig = null;
25-
private $title = null;
26-
private $language = null;
24+
private $siteConfig;
25+
private $title;
26+
private $language;
2727
private $authors = [];
28-
private $body = null;
29-
private $image = null;
28+
private $body;
29+
private $image;
3030
private $nativeAd = false;
31-
private $date = null;
31+
private $date;
3232
private $success = false;
3333
private $nextPageUrl;
3434
/** @var LoggerInterface */

src/Extractor/HttpClient.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use Http\Client\Common\Plugin\RedirectPlugin;
1414
use Http\Client\Common\PluginClient;
1515
use Http\Client\Exception\TransferException;
16-
use Http\Client\HttpClient as Client;
1716
use Http\Discovery\Psr17FactoryDiscovery;
17+
use Psr\Http\Client\ClientInterface;
1818
use Psr\Http\Message\ResponseInterface;
1919
use Psr\Log\LoggerInterface;
2020
use Psr\Log\NullLogger;
@@ -42,11 +42,7 @@ class HttpClient
4242
*/
4343
private $responseHistory;
4444

45-
/**
46-
* @param Client $client Http client
47-
* @param array $config
48-
*/
49-
public function __construct(Client $client, $config = [], LoggerInterface $logger = null)
45+
public function __construct(ClientInterface $client, $config = [], LoggerInterface $logger = null)
5046
{
5147
$resolver = new OptionsResolver();
5248
$resolver->setDefaults([
@@ -254,7 +250,7 @@ public function fetch($url, $skipTypeVerification = false, $httpHeader = [])
254250
// check for <meta name='fragment' content='!'/>
255251
// for AJAX sites, e.g. Blogger with its dynamic views templates.
256252
// Based on Google's spec: https://developers.google.com/webmasters/ajax-crawling/docs/specification
257-
if (false === strpos($effectiveUrl, '_escaped_fragment_')) {
253+
if (!str_contains($effectiveUrl, '_escaped_fragment_')) {
258254
$redirectURL = $this->getMetaRefreshURL($effectiveUrl, $body) ?: $this->getUglyURL($effectiveUrl, $body);
259255

260256
if (false !== $redirectURL) {
@@ -296,7 +292,7 @@ private function cleanupUrl($url)
296292
{
297293
// rewrite part of urls to something more readable
298294
foreach ($this->config['rewrite_url'] as $find => $action) {
299-
if (false !== strpos($url, $find) && \is_array($action)) {
295+
if (str_contains($url, $find) && \is_array($action)) {
300296
$url = strtr($url, $action);
301297
}
302298
}

src/Graby.php

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
use GuzzleHttp\Psr7\Uri;
1010
use GuzzleHttp\Psr7\UriResolver;
1111
use Http\Client\Common\PluginClient;
12-
use Http\Client\HttpClient as Client;
13-
use Http\Discovery\HttpClientDiscovery;
12+
use Http\Discovery\Psr18ClientDiscovery;
1413
use Http\Message\CookieJar;
1514
use Monolog\Handler\StreamHandler;
1615
use Monolog\Logger;
16+
use Psr\Http\Client\ClientInterface;
1717
use Psr\Log\LoggerInterface;
1818
use Psr\Log\NullLogger;
1919
use Readability\Readability;
@@ -34,21 +34,17 @@ class Graby
3434

3535
private $config = [];
3636

37-
private $httpClient = null;
38-
private $extractor = null;
37+
private $httpClient;
38+
private $extractor;
3939

4040
/** @var ConfigBuilder */
4141
private $configBuilder;
4242
private $punycode;
4343

4444
private $imgNoReferrer = false;
45-
private $prefetchedContent = null;
45+
private $prefetchedContent;
4646

47-
/**
48-
* @param array $config
49-
* @param Client|null $client Http client
50-
*/
51-
public function __construct($config = [], Client $client = null, ConfigBuilder $configBuilder = null)
47+
public function __construct($config = [], ClientInterface $client = null, ConfigBuilder $configBuilder = null)
5248
{
5349
$resolver = new OptionsResolver();
5450
$resolver->setDefaults([
@@ -118,7 +114,7 @@ public function __construct($config = [], Client $client = null, ConfigBuilder $
118114
);
119115

120116
$this->httpClient = new HttpClient(
121-
$client ?: new PluginClient(HttpClientDiscovery::find(), [new CookiePlugin(new CookieJar())]),
117+
$client ?: new PluginClient(Psr18ClientDiscovery::find(), [new CookiePlugin(new CookieJar())]),
122118
$this->config['http_client'],
123119
$this->logger
124120
);
@@ -150,8 +146,6 @@ public function reloadConfigFiles()
150146
* Return a config.
151147
*
152148
* @param string $key
153-
*
154-
* @return mixed
155149
*/
156150
public function getConfig($key)
157151
{
@@ -226,7 +220,7 @@ public function cleanupHtml($contentBlock, $url)
226220
}
227221

228222
// footnotes
229-
if ('footnotes' === $this->config['content_links'] && false === strpos($url, 'wikipedia.org')) {
223+
if ('footnotes' === $this->config['content_links'] && !str_contains($url, 'wikipedia.org')) {
230224
$this->extractor->readability->addFootnotes($contentBlock);
231225
}
232226

@@ -343,13 +337,6 @@ private function doFetchContent($url)
343337

344338
$this->logger->debug('HTML after regex empty nodes stripping', ['html' => $html]);
345339

346-
// some non utf8 enconding might be breaking after converting to utf8
347-
// when it happen the string (usually) starts with this character
348-
// in that case, we'll take the default response instead of the utf8 forced one
349-
if (0 === strpos(utf8_encode($response['body']), 'ÿþ')) {
350-
$html = $response['body'];
351-
}
352-
353340
// check site config for single page URL - fetch it if found
354341
$isSinglePage = false;
355342
if ($this->config['singlepage'] && null === $this->prefetchedContent && ($singlePageResponse = $this->getSinglePage($html, $effectiveUrl))) {

0 commit comments

Comments
 (0)