Skip to content

Enhancement: Enable trailing_comma_in_multiline fixer #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
],
'strict_param' => true,
'switch_case_space' => true,
'trailing_comma_in_multiline' => [
'elements' => [
'arguments',
'arrays',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we use PHP 8.2 now, we could also add

  • match
  • parameters

to the elements option.

See https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.40.2/doc/rules/control_structure/trailing_comma_in_multiline.rst#elements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably makes sense as a follow-up PR to not clog this up any longer

],
],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
Expand Down
2 changes: 1 addition & 1 deletion credits.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$credits = str_replace(
["</center>", "& "],
["</div>", "&amp; "],
$credits
$credits,
);

// If there is something left, print it out
Expand Down
2 changes: 1 addition & 1 deletion download-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
$link_to,
(int) ($size / 1024),
date("j M Y", $changed),
$extension
$extension,
];
$found_formats[$formatname] = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"rel" => "alternate",
"type" => "application/atom+xml",
"href" => $MYSITE . "releases/feed.php",
"title" => "PHP Release feed"
"title" => "PHP Release feed",
],
],
"current" => "downloads",
]
],
);
?>
<?php $i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */
Expand Down
2 changes: 1 addition & 1 deletion elephpant.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
<?php
// Print the common footer.
site_footer([
'elephpants' => true
'elephpants' => true,
]);
2 changes: 1 addition & 1 deletion error.php
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@
$fallback = (myphpnet_urlsearch() === MYPHPNET_URL_MANUAL ? "404manual" : "404quickref");
mirror_redirect(
'/search.php?show=' . $fallback . '&lang=' . urlencode($LANG) .
'&pattern=' . substr($_SERVER['REQUEST_URI'], 1)
'&pattern=' . substr($_SERVER['REQUEST_URI'], 1),
);
/*
* vim: set et ts=4 sw=4 ft=php: :
Expand Down
2 changes: 1 addition & 1 deletion git-php.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"note" => $_POST['realpurpose'],
"yesno" => $_POST['yesno'],
"group" => $_POST['group'],
]
],
);
// Error while posting
if ($error) {
Expand Down
6 changes: 3 additions & 3 deletions images/elephpants.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
} else {
header('HTTP/1.1 400', true, 400);
echo json_encode([
'error' => "Specify how many elephpants to serve via 'count'."
'error' => "Specify how many elephpants to serve via 'count'.",
]);
exit;
}
Expand All @@ -53,7 +53,7 @@
if (!$photos || !is_array($photos)) {
header('HTTP/1.1 500', true, 500);
echo json_encode([
'error' => "No elephpant metadata available."
'error' => "No elephpant metadata available.",
]);
exit;
}
Expand All @@ -79,7 +79,7 @@
$elephpants[] = [
'title' => $photo['title'],
'url' => "http://flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'],
'data' => base64_encode(file_get_contents($path . '/' . $photo['filename']))
'data' => base64_encode(file_get_contents($path . '/' . $photo['filename'])),
];
}

Expand Down
8 changes: 4 additions & 4 deletions include/branches.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function format_interval($from, DateTime $to) {
return "$t[0] $t[1]" .
($t[0] != 1 ? 's' : '');
},
$times
)
$times,
),
);

if ($diff->invert) {
Expand Down Expand Up @@ -378,7 +378,7 @@ function version_array(string $version, ?int $length = null)
{
$versionArray = array_map(
'intval',
explode('.', $version)
explode('.', $version),
);

if (is_int($length)) {
Expand All @@ -387,7 +387,7 @@ function version_array(string $version, ?int $length = null)
: array_slice(
$versionArray,
0,
$length
$length,
);
}

Expand Down
2 changes: 1 addition & 1 deletion include/get-download.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $possible_files = [$df, "manual/$df"];

$site_config = [
'current' => 'downloads',
'css' => ['mirror.css']
'css' => ['mirror.css'],
];

// Find out what is the exact file requested
Expand Down
4 changes: 2 additions & 2 deletions include/ip-to-country.inc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function i2c_search_in_index($ip)
// Open the index file for reading
$dbidx = fopen(
__DIR__ . "/../backend/ip-to-country.idx",
"r"
"r",
);
if (!$dbidx) { return false; }

Expand Down Expand Up @@ -133,7 +133,7 @@ function i2c_search_in_db($ip, $idx)
// Open DB for reading
$ipdb = fopen(
$_SERVER['DOCUMENT_ROOT'] . "/backend/ip-to-country.db",
"r"
"r",
);

// Return with "NA" in case of we cannot open the db
Expand Down
2 changes: 1 addition & 1 deletion include/langchooser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function language_choose_code()

// Drop out langauge specification from URL, as this is already handled
$_SERVER['STRIPPED_URI'] = preg_replace(
"!^/$flang[1]/!", "/", htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8')
"!^/$flang[1]/!", "/", htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8'),
);

}
Expand Down
12 changes: 6 additions & 6 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function resize_image($img, $width = 1, $height = 1)
return preg_replace(
'!/?>$!',
sprintf(' height="%s" width="%s">', $height, $width),
$str
$str,
);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ function make_image($file, $alt = false, $align = false, $extras = false,
($alt ?: ''),
$sizeparams,
$align,
($extras ? ' ' . $extras : '')
($extras ? ' ' . $extras : ''),
);
}

Expand Down Expand Up @@ -132,7 +132,7 @@ function make_submit($file, $alt = false, $align = false, $extras = false,
$img = str_replace(
"border=\"$border\"",
"style=\"border: {$border}px;\"",
$img
$img,
);

// Return with ready input image
Expand All @@ -156,7 +156,7 @@ function make_popup_link($url, $linktext = false, $target = false, $windowprops
($target ?: "_new"),
$windowprops,
($extras ? ' ' . $extras : ''),
($linktext ?: $url)
($linktext ?: $url),
);
}

Expand Down Expand Up @@ -232,7 +232,7 @@ function clean_note($text)
return preg_replace(
'!((mailto:|(https?|ftp|nntp|news)://).*?)(\s|<|\)|"|\\\\|\'|$)!',
'<a href="\1" rel="nofollow" target="_blank">\1</a>\4',
$text
$text,
);
}

Expand Down Expand Up @@ -275,7 +275,7 @@ function display_event($event, $include_date = 1): void
4 => 'Fourth',
-1 => 'Last',
-2 => '2nd Last',
-3 => '3rd Last'
-3 => '3rd Last',
];

if (!isset($event['start']) && isset($event['sday'])) {
Expand Down
2 changes: 1 addition & 1 deletion include/results.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l =
'php' => '<img src="' . $php_img_dir . '/logos/php-icon-white.gif" height="32" width="32" style="float:left; margin-left:-40px;"/>',
'doc' => '<img src="' . $php_img_dir . '/logos/php-icon-white.gif" height="32" width="32" style="float:left; margin-left:-40px;"/>',
'bugs' => '<img src="' . $php_img_dir . '/php_bug.gif" height="32" width="32" style="float:left; margin-left:-40px;"/>',
'gtk' => '<img src="' . $php_img_dir . '/logos/php-gtk-white.gif" height="26" width="32" style="float:left; margin-left:-40px;"/>'
'gtk' => '<img src="' . $php_img_dir . '/logos/php-gtk-white.gif" height="26" width="32" style="float:left; margin-left:-40px;"/>',
];

foreach($res['ResultSet']['Result'] as $i => $hit) {
Expand Down
10 changes: 5 additions & 5 deletions include/shared-manual.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function manual_notes($notes):void {
'&amp;redirect=' . $_SERVER['BASE_HREF'];
$addnotesnippet = make_link(
$addnotelink,
"οΌ‹<small>add a note</small>"
"οΌ‹<small>add a note</small>",
);

$num_notes = count($notes);
Expand Down Expand Up @@ -165,21 +165,21 @@ VOTEDIV;
'https://main.php.net/manage/user-notes.php?action=edit+' . $note->id,
'<img src="/images/[email protected]" height="12" width="12" alt="edit note">',
'admin',
'scrollbars=yes,width=650,height=400'
'scrollbars=yes,width=650,height=400',
) . "\n " .

make_popup_link(
'https://main.php.net/manage/user-notes.php?action=reject+' . $note->id,
'<img src="/images/[email protected]" height="12" width="12" alt="reject note">',
'admin',
'scrollbars=no,width=300,height=200'
'scrollbars=no,width=300,height=200',
) . "\n " .

make_popup_link(
'https://main.php.net/manage/user-notes.php?action=delete+' . $note->id,
'<img src="/images/[email protected]" height="12" width="12" alt="delete note">',
'admin',
'scrollbars=no,width=300,height=200'
'scrollbars=no,width=300,height=200',
) . "\n </span>";

} else {
Expand Down Expand Up @@ -387,7 +387,7 @@ function manual_footer(): void {
manual_notes($USERNOTES);
site_footer([
'related_menu' => $__RELATED['toc'],
'related_menu_deprecated' => $__RELATED['toc_deprecated']
'related_menu_deprecated' => $__RELATED['toc_deprecated'],
]);
}

Expand Down
4 changes: 2 additions & 2 deletions include/site.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ $MIRRORS = [
MIRROR_SPECIAL,
true,
"en",
MIRROR_OK
]
MIRROR_OK,
],
];

/**
Expand Down
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@
'<script>',
"function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}",
"okc(function(){if(document.getElementById){i=document.getElementById('phplogo');i.src='" . $MYSITE . "images/php_konami.gif'}});",
'</script>'
'</script>',
],
'link' => [
[
"rel" => "search",
"type" => "application/opensearchdescription+xml",
"href" => $MYSITE . "phpnetimprovedsearch.src",
"title" => "Add PHP.net search"
"title" => "Add PHP.net search",
],
[
"rel" => "alternate",
"type" => "application/atom+xml",
"href" => $MYSITE . "releases/feed.php",
"title" => "PHP Release feed"
"title" => "PHP Release feed",
],

],
Expand All @@ -167,7 +167,7 @@

<link href="https://fosstodon.org/@php" rel="me" />
META
]
],
);

// Print body of home page.
Expand Down Expand Up @@ -228,5 +228,5 @@
site_footer([
"atom" => "/feed.atom", // Add a link to the feed at the bottom
'elephpants' => true,
'sidebar' => $SIDEBAR
'sidebar' => $SIDEBAR,
]);
Loading