Author: Andreas Möller (localheinz) Committer: GitHub (web-flow) Pusher: cmb69 Date: 2022-07-12T11:44:23+02:00
Commit: https://github.com/php/web-php/commit/c68e5a9e4a080695cca2087e2957e659faadfd1f Raw diff: https://github.com/php/web-php/commit/c68e5a9e4a080695cca2087e2957e659faadfd1f.diff Enhancement: Enable `single_space_after_construct` fixer Closes GH-640. Changed paths: M .php-cs-fixer.php M archive/index.php M cal.php M conferences/index.php M download-docs.php M error.php M git-php.php M index.php M js/search-index.php M manual-lookup.php M manual/add-note.php M manual/vote-note.php M my.php M releases/feed.php M releases/index.php M security/index.php M src/News/Entry.php M submit-event.php M tests/run-tests.php Diff: diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index f9d0db2599..35d2266de3 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -12,6 +12,7 @@ $config->setRules([ 'indentation_type' => true, 'no_trailing_whitespace' => true, + 'single_space_after_construct' => true, 'visibility_required' => true, 'whitespace_after_comma_in_array' => true, ]); diff --git a/archive/index.php b/archive/index.php index 7b5aab024b..7f2b776bbd 100644 --- a/archive/index.php +++ b/archive/index.php @@ -7,7 +7,7 @@ mirror_redirect("/archive/$y.php"); break; } -} while(++$i<3); +} while (++$i<3); include_once __DIR__ . '/../include/errors.inc'; error_noservice(); diff --git a/cal.php b/cal.php index 24794d70e8..55599eb7e0 100644 --- a/cal.php +++ b/cal.php @@ -129,7 +129,7 @@ $eom = mktime(0, 0, 1, $cm+1, 0, $cy); // Link to previous month (but do not link to too early dates) -$prev_link = (function() use ($cm, $cy) { +$prev_link = (function () use ($cm, $cy) { $lm = mktime(0, 0, 1, $cm, 0, $cy); $year = date('Y', $lm); if (!valid_year($year)) { @@ -146,7 +146,7 @@ })(); // Link to next month (but do not link to too early dates) -$next_link = (function() use ($cm, $cy) { +$next_link = (function () use ($cm, $cy) { $nm = mktime(0, 0, 1, $cm+1, 1, $cy); $year = date('Y', $nm); if (!valid_year($year)) { diff --git a/conferences/index.php b/conferences/index.php index de805a194b..34ae0ed44a 100644 --- a/conferences/index.php +++ b/conferences/index.php @@ -13,8 +13,8 @@ $content = "<div class='home-content'>"; $frontpage = array(); -foreach($NEWS_ENTRIES as $entry) { - foreach($entry["category"] as $category) { +foreach ($NEWS_ENTRIES as $entry) { + foreach ($entry["category"] as $category) { if ($category["term"] == "cfp") { $frontpage[] = $entry; break; @@ -28,7 +28,7 @@ $panels = '<p class="prepend"><a href="https://wiki.php.net/conferences">Want to see your conference appear here?</a></p>'; -foreach($frontpage as $entry) { +foreach ($frontpage as $entry) { $link = preg_replace('~^(http://php.net/|https://www.php.net/)~', '', $entry["id"]); $id = parse_url($entry["id"], PHP_URL_FRAGMENT); $date = date_format(date_create($entry["updated"]), 'Y-m-d'); diff --git a/download-docs.php b/download-docs.php index 0c2e36f470..bdd5d4a247 100644 --- a/download-docs.php +++ b/download-docs.php @@ -91,7 +91,7 @@ // Go through all possible manual languages foreach ($LANGUAGES as $langcode => $language) { - if(isset($INACTIVE_ONLINE_LANGUAGES[$langcode]) && $MYSITE !== 'http://docs.php.net/') { + if (isset($INACTIVE_ONLINE_LANGUAGES[$langcode]) && $MYSITE !== 'http://docs.php.net/') { continue; } diff --git a/error.php b/error.php index ebf8895b5d..8de0b2d599 100644 --- a/error.php +++ b/error.php @@ -134,7 +134,7 @@ if (preg_match("!^get/([^/]+)/from/([^/]+)(/mirror)?$!", $URI, $dlinfo)) { $df = $dlinfo[1]; - if(strpos($df, "7-LATEST") !== false) { + if (strpos($df, "7-LATEST") !== false) { include_once __DIR__ . "/include/version.inc"; [ $latest ] = release_get_latest(); $df = str_replace("7-LATEST", $latest, $df); @@ -143,7 +143,7 @@ $mr = "https://www.php.net/"; // Check if that mirror really exists if not, bail out - if(!isset($MIRRORS[$mr])) { + if (!isset($MIRRORS[$mr])) { error_nomirror($mr); exit; } diff --git a/git-php.php b/git-php.php index 2da36b0b99..22ad1b68e1 100644 --- a/git-php.php +++ b/git-php.php @@ -48,7 +48,7 @@ // Check for errors if (empty($_POST['id'])) { $error .= "You must supply a desired Git user id. <br>"; - } elseif(!preg_match('!^[a-z]\w+$!', $_POST['id']) || strlen($_POST['id']) > 16) { + } elseif (!preg_match('!^[a-z]\w+$!', $_POST['id']) || strlen($_POST['id']) > 16) { $error .= "Your user id must be from 1-16 characters long, start with ". "a letter and contain nothing but a-z, 0-9, and _ <br>"; } @@ -398,7 +398,7 @@ class="max" value="<?php if (isset($_POST['password'])) echo clean($_POST['passw <td> <select name="group"> <?php -foreach($groups as $group => $name) { +foreach ($groups as $group => $name) { $selected = (isset($_POST["group"]) && $_POST["group"] == $group) ? ' selected="selected"' : ''; echo "<option value='$group'$selected>$name</option>\n"; } diff --git a/index.php b/index.php index 5e4abfc5ca..cd1d1dce9c 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ <?php // vim: et -(function($uri): void { +(function ($uri): void { // Special redirect cases not able to be captured in error.php $shortcuts = [ '/?:' => '/language.operators.comparison#language.operators.comparison.ternary', @@ -58,8 +58,8 @@ $content = "<div class='home-content'>"; $frontpage = array(); -foreach($NEWS_ENTRIES as $entry) { - foreach($entry["category"] as $category) { +foreach ($NEWS_ENTRIES as $entry) { + foreach ($entry["category"] as $category) { if ($category["term"] == "frontpage") { $frontpage[] = $entry; if (count($frontpage) >= 25) { @@ -68,7 +68,7 @@ } } } -foreach($frontpage as $entry) { +foreach ($frontpage as $entry) { $link = preg_replace('~^(http://php.net/|https://www.php.net/)~', '', $entry["id"]); $id = parse_url($entry["id"], PHP_URL_FRAGMENT); $date = date_create($entry['updated']); @@ -179,7 +179,7 @@ 'cfp' => 'Conferences calling for papers', ); $announcements = ""; - foreach($CONF_TEASER as $category => $entries) { + foreach ($CONF_TEASER as $category => $entries) { if ($entries) { $announcements .= '<div class="panel">'; $announcements .= ' <a href="/conferences" class="headline" title="' . $conftype[$category] . '">' . $conftype[$category] .'</a>'; diff --git a/js/search-index.php b/js/search-index.php index 1381861309..5c16dd3cc7 100644 --- a/js/search-index.php +++ b/js/search-index.php @@ -51,7 +51,7 @@ $js = json_decode($s, true); $index = array(); -foreach($js as $item) { +foreach ($js as $item) { if ($item[0]) { /* key: ID/filename, 0=>*/ $index[$item[1]] = array($item[0], "", $item[2]); @@ -61,7 +61,7 @@ $s = file_get_contents($descfile); $js = json_decode($s, true); -foreach($js as $k => $item) { +foreach ($js as $k => $item) { if ($item && isset($index[$k])) { $index[$k][1] = $item; } diff --git a/manual-lookup.php b/manual-lookup.php index 446df1fa2d..f07f4f4b06 100644 --- a/manual-lookup.php +++ b/manual-lookup.php @@ -12,7 +12,7 @@ $function = htmlspecialchars($_GET['pattern'], ENT_QUOTES, 'UTF-8'); } -if(!empty($_GET['scope']) && is_string($_GET['scope'])) { +if (!empty($_GET['scope']) && is_string($_GET['scope'])) { $scope = htmlspecialchars($_GET['scope'], ENT_QUOTES, 'UTF-8'); } else { $scope = ''; diff --git a/manual/add-note.php b/manual/add-note.php index 69cda77d4e..9d896d63eb 100644 --- a/manual/add-note.php +++ b/manual/add-note.php @@ -5,7 +5,7 @@ include_once __DIR__ . '/../include/prepend.inc'; include_once __DIR__ . '/../include/posttohost.inc'; include_once __DIR__ . '/../include/shared-manual.inc'; -include __DIR__ . '/spam_challenge.php'; +include __DIR__ . '/spam_challenge.php'; site_header("Add Manual Note", array( 'css' => 'add-note.css')); diff --git a/manual/vote-note.php b/manual/vote-note.php index 4a007d56c9..eae9c37225 100644 --- a/manual/vote-note.php +++ b/manual/vote-note.php @@ -3,7 +3,7 @@ include_once __DIR__ . '/../include/prepend.inc'; include_once __DIR__ . '/../include/posttohost.inc'; include_once __DIR__ . '/../include/shared-manual.inc'; -include __DIR__ . '/spam_challenge.php'; +include __DIR__ . '/spam_challenge.php'; // Initialize global variables $error = false; diff --git a/my.php b/my.php index b8a18193a8..84922a9429 100644 --- a/my.php +++ b/my.php @@ -197,7 +197,7 @@ We are experimenting with listing nearby user groups. This feature is highly experimental and will very likely change a lot and be broken at times. </p> -<label for="showugenable">Enable UG tips</label> <input type="radio" name="showug" id="showugenable" value="enable" <?php echo myphpnet_showug() ? "checked=checked" : "" ?>><br> +<label for="showugenable">Enable UG tips</label> <input type="radio" name="showug" id="showugenable" value="enable" <?php echo myphpnet_showug() ? "checked=checked" : "" ?>><br> <label for="showugdisable">Disable UG tips</label> <input type="radio" name="showug" id="showugdisable" value="disable" <?php echo myphpnet_showug() ? "" : "checked=checked" ?>> <p class="center"> diff --git a/releases/feed.php b/releases/feed.php index 3967c7c8d5..0cd3b65343 100644 --- a/releases/feed.php +++ b/releases/feed.php @@ -18,7 +18,7 @@ XML; -/* FIX silly editor highlighting */?><?php +/* FIX silly editor highlighting */ ?><?php // Flatten major versions out of RELEASES. $RELEASED_VERSIONS = array_reduce($RELEASES, 'array_merge', []); diff --git a/releases/index.php b/releases/index.php index ce2526e0ed..897639035b 100644 --- a/releases/index.php +++ b/releases/index.php @@ -51,7 +51,7 @@ $machineReadable = array("error" => "Unknown version"); } } else { - foreach($RELEASES as $major => $release) { + foreach ($RELEASES as $major => $release) { $version = key($release); $r = current($release); $r["version"] = $version; @@ -89,7 +89,7 @@ $active_majors = array_keys($RELEASES); $latest = max($active_majors); -foreach($OLDRELEASES as $major => $a) { +foreach ($OLDRELEASES as $major => $a) { echo '<a id="v' .$major. '"></a>'; if (!in_array($major, $active_majors)) { echo "\n<br>\n"; @@ -99,7 +99,7 @@ } $i = 0; - foreach($a as $ver => $release) { + foreach ($a as $ver => $release) { $i++; mk_rel( $major, @@ -193,7 +193,7 @@ function mk_rel(int $major, if ($announcement) { if (is_array($announcement)) { - foreach($announcement as $ann => $url) { + foreach ($announcement as $ann => $url) { echo "<a href=\"$url\">$ann</a> "; } } else { @@ -212,7 +212,7 @@ function mk_rel(int $major, echo "<ul>\n"; if (!$museum) { - foreach(array_merge($source, $windows) as $src) { + foreach (array_merge($source, $windows) as $src) { echo " <li>\n"; if (isset($src['filename'])) { download_link($src["filename"], $src["name"]); echo "<br>\n"; @@ -231,14 +231,14 @@ function mk_rel(int $major, } } else { /* $museum */ - foreach($source as $src) { + foreach ($source as $src) { if (!isset($src["filename"])) { continue; } printf('<li><a href="http://museum.php.net/php%d/%s">%s</a></li>', $major, $src["filename"], $src["name"]); } - foreach($windows as $src) { + foreach ($windows as $src) { printf('<li><a href="http://museum.php.net/%s/%s">%s</a></li>', ($major == 5 ? "php5" : "win32"), $src["filename"], $src["name"]); } diff --git a/security/index.php b/security/index.php index fb31a7ff44..5f03aa90cc 100644 --- a/security/index.php +++ b/security/index.php @@ -2,7 +2,7 @@ $_SERVER['BASE_PAGE'] = 'security/index.php'; include_once __DIR__ . '/../include/prepend.inc'; -if(!isset($_COOKIE["MAGIC_COOKIE"])) { +if (!isset($_COOKIE["MAGIC_COOKIE"])) { mirror_redirect("/manual/security"); exit; } @@ -34,27 +34,27 @@ $dbfile = $_SERVER['DOCUMENT_ROOT'] . '/security/vulndb.txt'; $fp = @fopen($dbfile, "rt"); -if(is_resource($fp)) { +if (is_resource($fp)) { $RECORDS = array(); $record_no = 1; - while($s = fgets($fp)) { - if($s == "\n") { - if(!isset($RECORDS[$record_no]["id"])) { + while ($s = fgets($fp)) { + if ($s == "\n") { + if (!isset($RECORDS[$record_no]["id"])) { $RECORDS[$record_no]["id"] = $record_no; } $field = null; $record_no++; continue; } - if(preg_match("/^([-\w]+):\s*(.*)/", $s, $m)) { + if (preg_match("/^([-\w]+):\s*(.*)/", $s, $m)) { // new record $field = strtolower($m[1]); $data = $m[2]; } else { $data = $s; } - if($field) { - if(isset($RECORDS[$record_no][$field])) { + if ($field) { + if (isset($RECORDS[$record_no][$field])) { $RECORDS[$record_no][$field] .= $data; } else { $RECORDS[$record_no][$field] = $data; @@ -65,7 +65,7 @@ //echo "<pre>";print_r($RECORDS); $id = isset($_GET["id"]) ? (int)$_GET["id"] : 0; - if(!$id || !isset($RECORDS[$id])) { + if (!$id || !isset($RECORDS[$id])) { ?> <h3>PHP Vulnerability Disclosures</h3> <p>This page contains information about PHP-related security threats, patches and known workarounds.</p> @@ -81,8 +81,8 @@ function cmp_records($a, $b) { $c = date("Ym", strtotime($a["published"])); $d = date("Ym", strtotime($b["published"])); - if($c >= $d) { - if($c > $d) { + if ($c >= $d) { + if ($c > $d) { return -1; } return 0; @@ -92,16 +92,16 @@ function cmp_records($a, $b) { usort($RECORDS, "cmp_records"); $last_month = ""; - foreach($RECORDS as $record) { - if(!isset($record["summary"])) { - if(strlen($record["description"]) > 80) { + foreach ($RECORDS as $record) { + if (!isset($record["summary"])) { + if (strlen($record["description"]) > 80) { $record["summary"] = substr($record["description"], 0, 70) . "..."; } else { $record["summary"] = $record["description"]; } } $current_month = date("Ym", strtotime($record["published"])); - if($current_month != $last_month) { + if ($current_month != $last_month) { $last_month = $current_month; $current_month = $record["affects"]; @@ -118,13 +118,13 @@ function cmp_records($a, $b) { <?php } // foreach($records); -} elseif(isset($RECORDS)) { // Print a single record +} elseif (isset($RECORDS)) { // Print a single record $date = date("F jS Y", strtotime($RECORDS[$id]["published"])); $RECORDS[$id]["id"] = sprintf("PHPSA-%04d", $RECORDS[$id]["id"]); printf("<h3>%s (%s)</h3>\n", $RECORDS[$id]["id"], $date); echo "<div class=\"singlerecord\">\n"; - foreach($RECORDS[$id] as $field => $data) { - if(!$data) { + foreach ($RECORDS[$id] as $field => $data) { + if (!$data) { continue; } $title = ucfirst(strtr($field, "-", " ")); diff --git a/src/News/Entry.php b/src/News/Entry.php index a106278c3d..ec40e2643b 100755 --- a/src/News/Entry.php +++ b/src/News/Entry.php @@ -143,7 +143,7 @@ public function save(): self { $content->setAttribute("type", "xhtml"); $div = $content->appendChild($dom->createElement("div")); $div->setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); - foreach($tdoc->firstChild->childNodes as $node) { + foreach ($tdoc->firstChild->childNodes as $node) { $div->appendChild($dom->importNode($node, true)); } } else { @@ -184,7 +184,7 @@ private static function ce(\DOMDocument $d, string $name, $value, array $attrs = } else { $n = $d->createElement($name); } - foreach($attrs as $k => $v) { + foreach ($attrs as $k => $v) { $n->setAttribute($k, $v); } if ($to) { diff --git a/submit-event.php b/submit-event.php index 4937c027bf..6d1ac148c6 100644 --- a/submit-event.php +++ b/submit-event.php @@ -22,7 +22,7 @@ $vars = array( 'type', 'country', 'category', 'email', 'url', 'ldesc', 'sdesc' ); -foreach($vars as $varname) { +foreach ($vars as $varname) { if (!isset($_POST[$varname])) { $_POST[$varname] = ""; } diff --git a/tests/run-tests.php b/tests/run-tests.php index 2c93f53ab4..1688e38565 100644 --- a/tests/run-tests.php +++ b/tests/run-tests.php @@ -1323,7 +1323,7 @@ function run_all_tests(array $test_files, array $env, $redir_tested = null): voi if ($file_cache !== null) { /* Automatically skip opcache tests in --file-cache mode, * because opcache generally doesn't expect those to run under file cache */ - $test_files = array_filter($test_files, function($test) { + $test_files = array_filter($test_files, function ($test) { return !is_string($test) || false === strpos($test, 'ext/opcache'); }); } -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php