Skip to content

Commit 951092e

Browse files
authored
Fix coding style missed by phpbcf (#2901)
$ composer require --dev friendsofphp/php-cs-fixer $ echo >.php-cs-fixer.dist.php "<?php $finder = PhpCsFixer\Finder::create() ->in(__DIR__); $rules = [ '@psr12' => true, // '@psr12:risky' => true, '@PHP74Migration' => true, // '@PHP74Migration:risky' => true, // buggy, duplicates existing comment sometimes 'no_break_comment' => false, 'array_syntax' => true, 'lowercase_static_reference' => true, 'visibility_required' => false, // Too much noise 'binary_operator_spaces' => false, 'heredoc_indentation' => false, 'trailing_comma_in_multiline' => false, ]; $config = new PhpCsFixer\Config(); return $config ->setRules($rules) // ->setRiskyAllowed(true) ->setFinder($finder); " $ vendor/bin/php-cs-fixer --version PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski. PHP runtime: 8.1.7 $ vendor/bin/php-cs-fixer fix $ rm .php-cs-fixer.cache $ vendor/bin/php-cs-fixer fix
1 parent dbf8c5b commit 951092e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+172
-175
lines changed

Diff for: bridges/AssociatedPressNewsBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function collectCardData()
119119
foreach ($tagContents['cards'] as $card) {
120120
$item = [];
121121

122-
// skip hub peeks & Notifications
122+
// skip hub peeks & Notifications
123123
if ($card['cardType'] == 'Hub Peek' || $card['cardType'] == 'Notification') {
124124
continue;
125125
}

Diff for: bridges/CeskaTelevizeBridge.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private function getUploadTimeFromString($string)
3333
returnServerError('Could not get date from Česká televize string');
3434
}
3535

36-
$date = sprintf('%04d-%02d-%02d', isset($match[3]) ? $match[3] : date('Y'), $match[2], $match[1]);
36+
$date = sprintf('%04d-%02d-%02d', $match[3] ?? date('Y'), $match[2], $match[1]);
3737
return strtotime($date);
3838
}
3939

@@ -46,7 +46,7 @@ public function collectData()
4646
returnServerError('Invalid url');
4747
}
4848

49-
$category = isset($match[4]) ? $match[4] : 'nove';
49+
$category = $match[4] ?? 'nove';
5050
$fixedUrl = "{$match[1]}dily/{$category}/";
5151

5252
$html = getSimpleHTMLDOM($fixedUrl);
@@ -78,11 +78,11 @@ public function collectData()
7878

7979
public function getURI()
8080
{
81-
return isset($this->feedUri) ? $this->feedUri : parent::getURI();
81+
return $this->feedUri ?? parent::getURI();
8282
}
8383

8484
public function getName()
8585
{
86-
return isset($this->feedName) ? $this->feedName : parent::getName();
86+
return $this->feedName ?? parent::getName();
8787
}
8888
}

Diff for: bridges/Drive2ruBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private function adjustContent($content)
182182

183183
private function addCommentsLink($content, $url)
184184
{
185-
return $content . '<br><a href="' . $url . '#comments">Перейти к комментариям</a>';
185+
return $content . '<br><a href="' . $url . '#comments">Перейти к комментариям</a>';
186186
}
187187

188188
private function addReadMoreLink($content, $url)

Diff for: bridges/FB2Bridge.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ public function collectData()
8585
$pageInfo = $this->getPageInfos($page, $cookies);
8686

8787
if ($pageInfo['userId'] === null) {
88-
returnClientError(<<<EOD
88+
returnClientError(
89+
<<<EOD
8990
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
9091
EOD
9192
);
9293
} elseif ($pageInfo['userId'] == -1) {
93-
returnClientError(<<<EOD
94+
returnClientError(
95+
<<<EOD
9496
This page is not accessible without being logged in.
9597
EOD
9698
);
@@ -120,7 +122,7 @@ public function collectData()
120122

121123
//Decode images
122124
$imagecleaned = preg_replace_callback('/<i [^>]* style="[^"]*url\(\'(.*?)\'\).*?><\/i>/m', function ($matches) {
123-
return "<img src='" . str_replace(['\\3a ', '\\3d ', '\\26 '], [':', '=', '&'], $matches[1]) . "' />";
125+
return "<img src='" . str_replace(['\\3a ', '\\3d ', '\\26 '], [':', '=', '&'], $matches[1]) . "' />";
124126
}, $content);
125127
$content = str_get_html($imagecleaned);
126128

@@ -158,7 +160,7 @@ public function collectData()
158160
'rel',
159161
'id'] as $property_name
160162
) {
161-
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
163+
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
162164
}
163165
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
164166

Diff for: bridges/FDroidBridge.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ public function collectData()
7272
// and now extracting app info from the selected widget (and yeah turns out icons are of heterogeneous sizes)
7373

7474
foreach ($html_widget->find('a') as $element) {
75-
$item = [];
76-
$item['uri'] = self::URI . $element->href;
77-
$item['title'] = $element->find('h4', 0)->plaintext;
78-
$item['icon'] = $element->find('img', 0)->src;
79-
$item['timestamp'] = $this->getTimestamp($item['icon']);
80-
$item['summary'] = $element->find('span.package-summary', 0)->plaintext;
81-
$item['content'] = '
75+
$item = [];
76+
$item['uri'] = self::URI . $element->href;
77+
$item['title'] = $element->find('h4', 0)->plaintext;
78+
$item['icon'] = $element->find('img', 0)->src;
79+
$item['timestamp'] = $this->getTimestamp($item['icon']);
80+
$item['summary'] = $element->find('span.package-summary', 0)->plaintext;
81+
$item['content'] = '
8282
<a href="' . $item['uri'] . '">
8383
<img alt="" style="max-height:128px" src="' . $item['icon'] . '">
8484
</a><br>' . $item['summary'];
85-
$this->items[] = $item;
85+
$this->items[] = $item;
8686
}
8787
}
8888
}

Diff for: bridges/FacebookBridge.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getName()
6767
switch ($this->queriedContext) {
6868
case 'User':
6969
if (!empty($this->authorName)) {
70-
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName;
70+
return $this->extraInfos['name'] ?? $this->authorName;
7171
}
7272
break;
7373

@@ -425,7 +425,7 @@ private function removeTrackingCodes($content)
425425
private function unescapeFacebookEmote($content)
426426
{
427427
return preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', function ($matches) {
428-
static $facebook_emoticons = [
428+
static $facebook_emoticons = [
429429
'smile' => ':)',
430430
'frown' => ':(',
431431
'tongue' => ':P',
@@ -448,19 +448,19 @@ private function unescapeFacebookEmote($content)
448448
'colonthree' => ':3',
449449
'like' => '&#x1F44D;'];
450450

451-
$len = count($matches);
451+
$len = count($matches);
452452

453-
if ($len > 1) {
454-
for ($i = 1; $i < $len; $i++) {
455-
foreach ($facebook_emoticons as $name => $emote) {
456-
if ($matches[$i] === $name) {
457-
return $emote;
458-
}
453+
if ($len > 1) {
454+
for ($i = 1; $i < $len; $i++) {
455+
foreach ($facebook_emoticons as $name => $emote) {
456+
if ($matches[$i] === $name) {
457+
return $emote;
459458
}
460459
}
461460
}
461+
}
462462

463-
return $matches[0];
463+
return $matches[0];
464464
}, $content);
465465
}
466466

Diff for: bridges/FeedMergeBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function collectData()
5151
}
5252

5353
// Sort by timestamp descending
54-
usort($this->items, fn($a, $b) => $b['timestamp'] <=> $a['timestamp']);
54+
usort($this->items, fn ($a, $b) => $b['timestamp'] <=> $a['timestamp']);
5555

5656
// Remove duplicates
5757
$items = [];

Diff for: bridges/FurAffinityBridge.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -795,37 +795,37 @@ public function collectData()
795795

796796
private function postFASimpleHTMLDOM($data)
797797
{
798-
$opts = [
798+
$opts = [
799799
CURLOPT_CUSTOMREQUEST => 'POST',
800800
CURLOPT_POSTFIELDS => http_build_query($data)
801801
];
802-
$header = [
802+
$header = [
803803
'Host: ' . parse_url(self::URI, PHP_URL_HOST),
804804
'Content-Type: application/x-www-form-urlencoded',
805805
'Cookie: ' . self::FA_AUTH_COOKIE
806806
];
807807

808-
$html = getSimpleHTMLDOM($this->getURI(), $header, $opts);
809-
$html = defaultLinkTo($html, $this->getURI());
808+
$html = getSimpleHTMLDOM($this->getURI(), $header, $opts);
809+
$html = defaultLinkTo($html, $this->getURI());
810810

811-
return $html;
811+
return $html;
812812
}
813813

814814
private function getFASimpleHTMLDOM($url, $cache = false)
815815
{
816-
$header = [
816+
$header = [
817817
'Cookie: ' . self::FA_AUTH_COOKIE
818818
];
819819

820-
if ($cache) {
821-
$html = getSimpleHTMLDOMCached($url, 86400, $header); // 24 hours
822-
} else {
823-
$html = getSimpleHTMLDOM($url, $header);
824-
}
820+
if ($cache) {
821+
$html = getSimpleHTMLDOMCached($url, 86400, $header); // 24 hours
822+
} else {
823+
$html = getSimpleHTMLDOM($url, $header);
824+
}
825825

826-
$html = defaultLinkTo($html, $url);
826+
$html = defaultLinkTo($html, $url);
827827

828-
return $html;
828+
return $html;
829829
}
830830

831831
private function itemsFromJournalList($html, $limit)

Diff for: bridges/GithubIssueBridge.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,18 @@ public function detectParameters($url)
274274

275275
switch (count($path_segments)) {
276276
case 2: // Project issues
277-
list($user, $project) = $path_segments;
277+
[$user, $project] = $path_segments;
278278
$show_comments = 'off';
279279
break;
280280
case 3: // Project issues with issue comments
281281
if ($path_segments[2] !== static::URL_PATH) {
282282
return null;
283283
}
284-
list($user, $project) = $path_segments;
284+
[$user, $project] = $path_segments;
285285
$show_comments = 'on';
286286
break;
287287
case 4: // Issue comments
288-
list($user, $project, /* issues */, $issue) = $path_segments;
288+
[$user, $project, /* issues */, $issue] = $path_segments;
289289
break;
290290
default:
291291
return null;
@@ -294,8 +294,8 @@ public function detectParameters($url)
294294
return [
295295
'u' => $user,
296296
'p' => $project,
297-
'c' => isset($show_comments) ? $show_comments : null,
298-
'i' => isset($issue) ? $issue : null,
297+
'c' => $show_comments ?? null,
298+
'i' => $issue ?? null,
299299
];
300300
}
301301
}

Diff for: bridges/GolemBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function collectData()
6666
protected function parseItem($item)
6767
{
6868
$item = parent::parseItem($item);
69-
$item['content'] = $item['content'] ?? '';
69+
$item['content'] ??= '';
7070
$uri = $item['uri'];
7171

7272
while ($uri) {

Diff for: bridges/GoodreadsBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private function collectAuthorBooks($url)
4747
$dateSpan = $row->find('.uitext', 0)->plaintext;
4848
$date = null;
4949

50-
// If book is not yet published, ignore for now
50+
// If book is not yet published, ignore for now
5151
if (preg_match('/published\s+(\d{4})/', $dateSpan, $matches) === 1) {
5252
// Goodreads doesn't give us exact publication date here, only a year
5353
// We are skipping future dates anyway, so this is def published

Diff for: bridges/InstagramBridge.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function getInstagramUserId($username)
106106
$key = $cache->loadData();
107107

108108
if ($key == null) {
109-
$data = $this->getContents(self::URI . 'web/search/topsearch/?query=' . $username);
109+
$data = $this->getContents(self::URI . 'web/search/topsearch/?query=' . $username);
110110
foreach (json_decode($data)->users as $user) {
111111
if (strtolower($user->user->username) === strtolower($username)) {
112112
$key = $user->user->pk;
@@ -115,7 +115,7 @@ protected function getInstagramUserId($username)
115115
if ($key == null) {
116116
returnServerError('Unable to find username in search result.');
117117
}
118-
$cache->saveData($key);
118+
$cache->saveData($key);
119119
}
120120
return $key;
121121
}

Diff for: bridges/InternetArchiveBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private function processReview($result)
196196

197197
$item['content'] = <<<EOD
198198
<p><strong>Subject: {$result->find('div.review-title', 0)->plaintext}</strong></p>
199-
<p>{$result->find('div.hidden-lists.review' , 0)->children(1)->plaintext}</p>
199+
<p>{$result->find('div.hidden-lists.review', 0)->children(1)->plaintext}</p>
200200
EOD;
201201

202202
$item['enclosures'][] = self::URI . $result->find('img.item-img', 0)->source;

Diff for: bridges/IvooxBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function collectData()
120120

121121
foreach ($originalLocales as $localeSetting) {
122122
if (strpos($localeSetting, '=') !== false) {
123-
list($category, $locale) = explode('=', $localeSetting);
123+
[$category, $locale] = explode('=', $localeSetting);
124124
} else {
125125
$category = LC_ALL;
126126
$locale = $localeSetting;

Diff for: bridges/MallTvBridge.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ public function collectData()
6666

6767
public function getURI()
6868
{
69-
return isset($this->feedUri) ? $this->feedUri : parent::getURI();
69+
return $this->feedUri ?? parent::getURI();
7070
}
7171

7272
public function getName()
7373
{
74-
return isset($this->feedName) ? $this->feedName : parent::getName();
74+
return $this->feedName ?? parent::getName();
7575
}
7676
}

Diff for: bridges/MarktplaatsBridge.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public function collectData()
126126
public function getName()
127127
{
128128
if (!is_null($this->getInput('q'))) {
129-
return $this->getInput('q') . ' - Marktplaats';
129+
return $this->getInput('q') . ' - Marktplaats';
130130
}
131-
return parent::getName();
131+
return parent::getName();
132132
}
133133
}

Diff for: bridges/NationalGeographicBridge.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,17 @@ private function handleImages($image_module, $image_type)
230230
if (isset($image['crdt'])) {
231231
$image_credit = $image['crdt'];
232232
}
233-
$caption = (isset($image_module['caption']) ? $image_module['caption'] : '');
233+
$caption = ($image_module['caption'] ?? '');
234234
break;
235235
case 'photogallery':
236-
$image_credit = (isset($image_module['caption']['credit']) ? $image_module['caption']['credit'] : '');
236+
$image_credit = ($image_module['caption']['credit'] ?? '');
237237
$caption = $image_module['caption']['text'];
238238
$image_src = $image_module['img']['src'];
239239
$image_alt = $image_module['img']['altText'];
240240
break;
241241
case 'video':
242-
$image_credit = (isset($image_module['credit']) ? $image_module['credit'] : '');
243-
$description = (isset($image_module['description']) ? $image_module['description'] : '');
242+
$image_credit = ($image_module['credit'] ?? '');
243+
$description = ($image_module['description'] ?? '');
244244
$caption = $description . ' Video can be watched on the article\'s page';
245245
$image = $image_module['image'];
246246
$image_alt = $image['altText'];
@@ -325,7 +325,7 @@ private function getFullArticle($uri)
325325
if (isset($module['image'])) {
326326
$content .= $this->handleImages($module['image'], $module['image']['cmsType']);
327327
}
328-
$content .= '<p>' . (isset($module['text']) ? $module['text'] : '') . '</p>';
328+
$content .= '<p>' . ($module['text'] ?? '') . '</p>';
329329
break;
330330
case 'photogallery':
331331
$gallery = $body['cntnt']['media'];
@@ -339,9 +339,9 @@ private function getFullArticle($uri)
339339
case 'pullquote':
340340
$quote = $module['quote'];
341341
$author_name = '';
342-
$authors = (isset($module['byLineProps']['authors']) ? $module['byLineProps']['authors'] : []);
342+
$authors = ($module['byLineProps']['authors'] ?? []);
343343
foreach ($authors as $author) {
344-
$author_desc = (isset($author['authorDesc']) ? $author['authorDesc'] : '');
344+
$author_desc = ($author['authorDesc'] ?? '');
345345
$author_name .= $author['displayName'] . ', ' . $author_desc;
346346
}
347347
$content .= <<<EOD

0 commit comments

Comments
 (0)