Skip to content
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

Enhancement: Enable method_argument_space fixer #648

Closed
Closed
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
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
],
'indentation_type' => true,
'line_ending' => true,
'method_argument_space' => true,
'new_with_parentheses' => true,
'no_extra_blank_lines' => true,
'no_trailing_whitespace' => true,
Expand Down
222 changes: 111 additions & 111 deletions ChangeLog-8.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cached.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$abs = realpath($abs);

if (strncmp($abs, $pwd, strlen($pwd)) != 0) {
header("Location: https://www.php.net/" . strtr($_GET["f"],["\r" => "", "\n" => ""]));
header("Location: https://www.php.net/" . strtr($_GET["f"], ["\r" => "", "\n" => ""]));
exit;
}

Expand Down
52 changes: 28 additions & 24 deletions cal.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
elseif ($cy && $cm && $cd) {

// Check if date is valid
if (checkdate($cm,$cd,$cy)) {
if (checkdate($cm, $cd, $cy)) {

// Date integer for that day
$date = mktime(0, 0, 1, $cm, $cd, $cy);
Expand All @@ -68,7 +68,7 @@

// Unable to load events for that day
else {
$errors[] = "There are no events for the specified date (" . date("F j, Y",$date) . ").";
$errors[] = "There are no events for the specified date (" . date("F j, Y", $date) . ").";
}
}

Expand All @@ -80,7 +80,7 @@
}

// Check if month and year is valid
if ($cm && $cy && !checkdate($cm,1,$cy)) {
if ($cm && $cy && !checkdate($cm, 1, $cy)) {
$errors[] = "The specified year and month (" . htmlentities("$cy, $cm", ENT_QUOTES | ENT_IGNORE, 'UTF-8') . ") are not valid.";
unset($cm, $cy);
}
Expand Down Expand Up @@ -125,7 +125,7 @@
}

// Beginning and end of this month
$bom = mktime(0, 0, 1, $cm, 1, $cy);
$bom = mktime(0, 0, 1, $cm, 1, $cy);
$eom = mktime(0, 0, 1, $cm + 1, 0, $cy);

// Link to previous month (but do not link to too early dates)
Expand All @@ -138,11 +138,13 @@

$month = date('m', $lm);
$monthName = date('F', $lm);
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year));
return sprintf(
'<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year)
cmb69 marked this conversation as resolved.
Show resolved Hide resolved
);
})();

// Link to next month (but do not link to too early dates)
Expand All @@ -155,11 +157,13 @@

$month = date('m', $nm);
$monthName = date('F', $nm);
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year));
return sprintf(
'<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year)
);
})();

// Print out navigation links for previous and next month
Expand All @@ -174,22 +178,22 @@

// Print out headers for weekdays
for ($i = 0; $i < 7; $i++) {
echo '<th width="14%">', date("l",mktime(0,0,1,4,$i + 1,2001)), "</th>\n";
echo '<th width="14%">', date("l", mktime(0, 0, 1, 4, $i + 1, 2001)), "</th>\n";
}
echo "</tr>\n<tr>";

// Generate the requisite number of blank days to get things started
for ($days = $i = date("w",$bom); $i > 0; $i--) {
for ($days = $i = date("w", $bom); $i > 0; $i--) {
echo '<td class="notaday">&nbsp;</td>';
}

// Print out all the days in this month
for ($i = 1; $i <= date("t",$bom); $i++) {
for ($i = 1; $i <= date("t", $bom); $i++) {

// Print out day number and all events for the day
echo '<td><a class="day" href="/cal.php', "?cm=$cm&amp;cd=$i&amp;cy=$cy",
'">',$i,'</a>';
display_events_for_day(date("Y-m-",$bom) . sprintf("%02d",$i), $events);
display_events_for_day(date("Y-m-", $bom) . sprintf("%02d", $i), $events);
echo '</td>';

// Break HTML table row if at end of week
Expand Down Expand Up @@ -218,11 +222,11 @@ function date_for_recur($recur, $day, $bom, $eom)
if ($recur > 0) {
$bomd = date("w", $bom) + 1;
$days = (($day - $bomd + 7) % 7) + (($recur - 1) * 7);
return mktime(0,0,1, date("m",$bom), $days + 1, date("Y",$bom));
return mktime(0, 0, 1, date("m", $bom), $days + 1, date("Y", $bom));
}

// ${recur}th to last $day of the month
$eomd = date("w",$eom) + 1;
$eomd = date("w", $eom) + 1;
$days = (($eomd - $day + 7) % 7) + ((abs($recur) - 1) * 7);

return mktime(0, 0, 1, date("m", $bom) + 1, -$days, date("Y", $bom));
Expand Down Expand Up @@ -256,7 +260,7 @@ function display_events_for_day($day, $events): void
function load_event($id)
{
// Open events CSV file, return on error
$fp = @fopen("backend/events.csv",'r');
$fp = @fopen("backend/events.csv", 'r');
if (!$fp) { return false; }

// Read as we can, event by event
Expand All @@ -283,15 +287,15 @@ function load_events($from, $whole_month = false)
{
// Take advantage of the equality behavior of this date format
$from_date = date("Y-m-d", $from);
$bom = mktime(0, 0, 1, date("m",$from), 1, date("Y",$from));
$eom = mktime(0, 0, 1, date("m",$from) + 1, 0, date("Y",$from));
$bom = mktime(0, 0, 1, date("m", $from), 1, date("Y", $from));
$eom = mktime(0, 0, 1, date("m", $from) + 1, 0, date("Y", $from));
$to_date = date("Y-m-d", $whole_month ? $eom : $from);

// Set arrays to their default
$events = $seen = [];

// Try to open the events file for reading, return if unable to
$fp = @fopen("backend/events.csv",'r');
$fp = @fopen("backend/events.csv", 'r');
if (!$fp) { return false; }

// For all events, read in the event and check it if fits our scope
Expand Down
3 changes: 2 additions & 1 deletion downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<p class="panel"><a href="/releases/">Old archives</a></p>
';

site_header("Downloads",
site_header(
"Downloads",
[
'link' => [
[
Expand Down
13 changes: 7 additions & 6 deletions include/branches.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ function format_interval($from, $to) {
$eolPeriod = 'midnight';
}
if ($times) {
$eolPeriod = implode(', ',
array_map(
function ($t) {
$eolPeriod = implode(
', ',
array_map(
function ($t) {
return "$t[0] $t[1]" .
($t[0] != 1 ? 's' : '');
},
$times
)
);
$times
)
);

if ($diff->invert) {
$eolPeriod = "$eolPeriod ago";
Expand Down
2 changes: 1 addition & 1 deletion include/email-validation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ function blacklisted($email) {
'@conferenceseries.com',
];
foreach ($mosquitoes as $m) {
if (preg_match('/' . preg_quote($m, '/') . '/i',$email)) return true;
if (preg_match('/' . preg_quote($m, '/') . '/i', $email)) return true;
}
}
3 changes: 2 additions & 1 deletion include/gpg-keys.inc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ function gpg_key_show_keys(bool $activeOnly): void {
foreach (gpg_key_get_branches($activeOnly) as $branch => $rms) {
$keys = array_filter(
array_map(function ($rm) { return gpg_key_get($rm); }, $rms),
function ($key) { return $key !== null; });
function ($key) { return $key !== null; }
);
if (empty($keys)) { continue; }

$branch = htmlentities($branch, ENT_QUOTES, 'UTF-8');
Expand Down
6 changes: 4 additions & 2 deletions include/langchooser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function language_choose_code()
}

// Specified in a shortcut URL (eg. /en/echo or /pt_br/echo)
if (preg_match("!^/(\\w{2}(_\\w{2})?)/!", htmlspecialchars($_SERVER['REQUEST_URI'],ENT_QUOTES, 'UTF-8'), $flang)) {
if (preg_match("!^/(\\w{2}(_\\w{2})?)/!", htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8'), $flang)) {

// Put language into preference list
$rlang = language_add($flang[1], $languages);
Expand All @@ -68,7 +68,9 @@ 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
51 changes: 35 additions & 16 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ $_SERVER['MYSITE'] = $MYSITE;
ini_set('highlight.comment', 'comment');
ini_set('highlight.default', 'default');
ini_set('highlight.keyword', 'keyword');
ini_set('highlight.string', 'string');
ini_set('highlight.html', 'html');
ini_set('highlight.string', 'string');
ini_set('highlight.html', 'html');

// Highlight PHP code
function highlight_php($code, $return = false)
Expand Down Expand Up @@ -57,7 +57,7 @@ function commonFooter(): void { site_footer(); }
function resize_image($img, $width = 1, $height = 1)
{
// Drop width and height values from image if available
$str = preg_replace('!width=\"([0-9]+?)\"!i', '', $img);
$str = preg_replace('!width=\"([0-9]+?)\"!i', '', $img);
$str = preg_replace('!height=\"([0-9]+?)\"!i', '', $str);

// Return image with new width and height added
Expand All @@ -69,8 +69,14 @@ function resize_image($img, $width = 1, $height = 1)
}

// Return an <img> tag for a given image file available on the server
function make_image($file, $alt = false, $align = false, $extras = false,
$dir = '/images', $addsize = true)
function make_image(
$file,
$alt = false,
$align = false,
$extras = false,
$dir = '/images',
$addsize = true
)
{
// If no / was provided at the start of $dir, add it
$webdir = $_SERVER['MYSITE'] . ($dir[0] == '/' ? '' : '/') . $dir;
Expand All @@ -93,7 +99,8 @@ function make_image($file, $alt = false, $align = false, $extras = false,
}

// Return with image built up
return sprintf('<img src="%s/%s" alt="%s"%s%s%s>',
return sprintf(
'<img src="%s/%s" alt="%s"%s%s%s>',
$webdir,
$file,
($alt ?: ''),
Expand All @@ -104,8 +111,13 @@ function make_image($file, $alt = false, $align = false, $extras = false,
}

// Print an <img> tag out for a given file
function print_image($file, $alt = false, $align = false, $extras = false,
$dir = '/images'): void
function print_image(
$file,
$alt = false,
$align = false,
$extras = false,
$dir = '/images'
): void
{
echo make_image($file, $alt, $align, $extras, $dir);
}
Expand All @@ -122,8 +134,14 @@ function news_image($URL, $image, $alt, $print = true)
}

// Return HTML code for a submit button image
function make_submit($file, $alt = false, $align = false, $extras = false,
$dir = '/images', $border = 0)
function make_submit(
$file,
$alt = false,
$align = false,
$extras = false,
$dir = '/images',
$border = 0
)
{
// Get an image without size info and convert the
// border attribute to use CSS, as border="" is not
Expand All @@ -149,12 +167,13 @@ function make_link (string $url, string $linktext = ''): string
// return a hyperlink to something, within the site, that pops up a new window
//
function make_popup_link ($url, $linktext = false, $target = false, $windowprops = "", $extras = false) {
return sprintf("<a href=\"%s\" target=\"%s\" onclick=\"window.open('%s','%s','%s');return false;\"%s>%s</a>",
return sprintf(
"<a href=\"%s\" target=\"%s\" onclick=\"window.open('%s','%s','%s');return false;\"%s>%s</a>",
htmlspecialchars($url, ENT_QUOTES | ENT_IGNORE),
($target ?: "_new"),
htmlspecialchars($url, ENT_QUOTES | ENT_IGNORE),
($target ?: "_new"),
$windowprops,
$windowprops,
($extras ? ' ' . $extras : ''),
($linktext ?: $url)
);
Expand Down Expand Up @@ -279,13 +298,13 @@ function display_event($event, $include_date = 1): void
];

if (!isset($event['start']) && isset($event['sday'])) {
$sday = mktime(12,0,0,$event['smonth'],$event['sday'],$event['syear']);
$sday = mktime(12, 0, 0, $event['smonth'], $event['sday'], $event['syear']);
} else {
$sday = (isset($event['start']) && !empty($event['start'])) ? strtotime($event['start']) : 0;
}

if (!isset($event['end']) && isset($event['eday'])) {
$eday = mktime(12,0,0,$event['emonth'],$event['eday'],$event['eyear']);
$eday = mktime(12, 0, 0, $event['emonth'], $event['eday'], $event['eyear']);
} else {
$eday = (isset($event['end']) && !empty($event['end'])) ? strtotime($event['end']) : 0;
}
Expand All @@ -311,7 +330,7 @@ function display_event($event, $include_date = 1): void
case 2:
case 'multi':
$dtend = date("Y-m-d", strtotime("+1 day", $eday));
echo " (<abbr class='dtstart'>", date("Y-m-d",$sday), "</abbr> to <abbr class='dtend' title='$dtend'>", date("Y-m-d",$eday), "</abbr>)";
echo " (<abbr class='dtstart'>", date("Y-m-d", $sday), "</abbr> to <abbr class='dtend' title='$dtend'>", date("Y-m-d", $eday), "</abbr>)";
break;
case 3:
case 'recur':
Expand Down Expand Up @@ -340,7 +359,7 @@ function display_event($event, $include_date = 1): void
<?php

// Print long description
echo preg_replace("/\r?\n\r?\n/", "<br><br>", trim(htmlentities($event['ldesc'],ENT_QUOTES | ENT_IGNORE, 'UTF-8')));
echo preg_replace("/\r?\n\r?\n/", "<br><br>", trim(htmlentities($event['ldesc'], ENT_QUOTES | ENT_IGNORE, 'UTF-8')));
// If we have an URL, print it out
if ($event['url']) {
echo '<br><br><b>URL:</b> ',
Expand Down
6 changes: 3 additions & 3 deletions include/results.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l =
// rewrite mirrors urls (\w\w\d? or www, but not qa, doc, gtk and ~/user)
$real_url = preg_replace('@^http://(?!doc|qa|gtk)\w{2,3}\.php\.net(?!/~)(.*)$@', '$1', $hit['Url']);
$displayurl = preg_replace('@^http://(?:(?!doc|qa|php|gtk)\w{2,3}\.)?(.+[^/])/?$@', '$1', $hit['Url']);
$type = substr($displayurl,0,strpos($displayurl,'.'));
if($type == 'pecl' && strstr($displayurl,"/bugs/")) $type = "peclbugs";
if($type == 'pear' && strstr($displayurl,"/bugs/")) $type = "pearbugs";
$type = substr($displayurl, 0, strpos($displayurl, '.'));
if($type == 'pecl' && strstr($displayurl, "/bugs/")) $type = "peclbugs";
if($type == 'pear' && strstr($displayurl, "/bugs/")) $type = "pearbugs";
if($type == 'smarty') continue;
$display_title = str_replace(['PHP:', '&amp;'], ['', '&'], $hit['Title']);

Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
$meta_image_path = $MYSITE . 'images/meta-image.png';
$meta_description = "PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.";

site_header("Hypertext Preprocessor",
site_header(
"Hypertext Preprocessor",
[
'current' => 'home',
'headtags' => [
Expand Down
Loading
Loading