Skip to content

Commit

Permalink
Enhancement: Enable indentation_type fixer
Browse files Browse the repository at this point in the history
Closes GH-622.
  • Loading branch information
localheinz authored Jul 11, 2022
1 parent ba92fc9 commit f3585d9
Show file tree
Hide file tree
Showing 18 changed files with 524 additions and 523 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
->name(__FILE__);

$config->setRules([
'indentation_type' => true,
'no_trailing_whitespace' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
Expand Down
10 changes: 5 additions & 5 deletions archive/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
include_once __DIR__ . '/../include/prepend.inc';
$i = 0;
do {
$y = date("Y")-$i;
if (file_exists("./$y.php")) {
mirror_redirect("/archive/$y.php");
break;
}
$y = date("Y")-$i;
if (file_exists("./$y.php")) {
mirror_redirect("/archive/$y.php");
break;
}
} while(++$i<3);

include_once __DIR__ . '/../include/errors.inc';
Expand Down
6 changes: 3 additions & 3 deletions docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
// List all manual languages viewable online
$lastlang = end($ACTIVE_ONLINE_LANGUAGES);
foreach ($ACTIVE_ONLINE_LANGUAGES as $langcode => $langname) {
if (!file_exists($_SERVER["DOCUMENT_ROOT"] . "/manual/{$langcode}/index.php")) {
continue;
}
if (!file_exists($_SERVER["DOCUMENT_ROOT"] . "/manual/{$langcode}/index.php")) {
continue;
}

// Make preferred language bold
if ($langcode == $LANG) { echo "<strong>"; }
Expand Down
22 changes: 11 additions & 11 deletions eol.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
// Notes for specific branches can be added here, and will appear in the table.
$BRANCH_NOTES = array(
'7.3' => '<a href="/migration74">A guide is available for migrating from PHP 7.3 to 7.4.</a>',
'7.2' => '<a href="/migration73">A guide is available for migrating from PHP 7.2 to 7.3.</a>',
'7.1' => '<a href="/migration72">A guide is available for migrating from PHP 7.1 to 7.2.</a>',
'7.0' => '<a href="/migration71">A guide is available for migrating from PHP 7.0 to 7.1.</a>',
'5.6' => '<a href="/migration70">A guide is available for migrating from PHP 5.6 to 7.0.</a>',
'5.5' => '<a href="/migration56">A guide is available for migrating from PHP 5.5 to 5.6.</a>',
'5.4' => '<a href="/migration55">A guide is available for migrating from PHP 5.4 to 5.5.</a>',
'5.3' => '<a href="/migration54">A guide is available for migrating from PHP 5.3 to 5.4.</a>',
'5.2' => '<a href="/migration53">A guide is available for migrating from PHP 5.2 to 5.3.</a>',
'5.1' => '<a href="/migration52">A guide is available for migrating from PHP 5.1 to 5.2.</a>',
'5.0' => '<a href="/migration51">A guide is available for migrating from PHP 5.0 to 5.1.</a>',
'4.4' => '<a href="/migration5">A guide is available for migrating from PHP 4 to PHP 5.0.</a>',
'7.2' => '<a href="/migration73">A guide is available for migrating from PHP 7.2 to 7.3.</a>',
'7.1' => '<a href="/migration72">A guide is available for migrating from PHP 7.1 to 7.2.</a>',
'7.0' => '<a href="/migration71">A guide is available for migrating from PHP 7.0 to 7.1.</a>',
'5.6' => '<a href="/migration70">A guide is available for migrating from PHP 5.6 to 7.0.</a>',
'5.5' => '<a href="/migration56">A guide is available for migrating from PHP 5.5 to 5.6.</a>',
'5.4' => '<a href="/migration55">A guide is available for migrating from PHP 5.4 to 5.5.</a>',
'5.3' => '<a href="/migration54">A guide is available for migrating from PHP 5.3 to 5.4.</a>',
'5.2' => '<a href="/migration53">A guide is available for migrating from PHP 5.2 to 5.3.</a>',
'5.1' => '<a href="/migration52">A guide is available for migrating from PHP 5.1 to 5.2.</a>',
'5.0' => '<a href="/migration51">A guide is available for migrating from PHP 5.0 to 5.1.</a>',
'4.4' => '<a href="/migration5">A guide is available for migrating from PHP 4 to PHP 5.0.</a>',
);

site_header('Unsupported Branches');
Expand Down
8 changes: 4 additions & 4 deletions git-php.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
} // endif: no data or checkread not checked

else {
if (count($_POST)) {
if (count($_POST)) {
print <<<EOT
<div class="warning">
<p>
Expand Down Expand Up @@ -361,9 +361,9 @@ class="max" value="<?php if (isset($_POST['email'])) echo clean($_POST['email'])
<td>
<?php
$purposes = array("Learning PHP", "Coding in PHP", "Reading the PHP source",
"Using PHP extensions", "Creating experimental PHP extensions",
"Submitting a patch to PHP", "Adding notes to the documentation",
"Writing web pages with PHP");
"Using PHP extensions", "Creating experimental PHP extensions",
"Submitting a patch to PHP", "Adding notes to the documentation",
"Writing web pages with PHP");

foreach ($purposes as $i => $p) { ?>
<input type="checkbox" name="purpose[<?php echo $i?>]" value="1"
Expand Down
12 changes: 6 additions & 6 deletions images/logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ function serve_compressed_if_available($logo): void {

$logo = './logos/php-logo.svg';
if (isset($_SERVER['QUERY_STRING'])) {
switch ($_SERVER['QUERY_STRING']) {
case 'QA':
case 'qa':
$logo = './logos/qa.jpg';
break;
}
switch ($_SERVER['QUERY_STRING']) {
case 'QA':
case 'qa':
$logo = './logos/qa.jpg';
break;
}
}

// xmas season, december and the first week of January
Expand Down
66 changes: 33 additions & 33 deletions images/supported-versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,49 @@
$footer_height = 24;

function branches_to_show() {
// Basically: show all 5.3+ branches with EOL dates > min_date().
$branches = array();

// Flatten out the majors.
foreach (get_all_branches() as $major_branches) {
foreach ($major_branches as $branch => $version) {
if (version_compare($branch, '5.3', 'ge') && get_branch_security_eol_date($branch) > min_date()) {
$branches[$branch] = $version;
}
}
}

ksort($branches);
return $branches;
// Basically: show all 5.3+ branches with EOL dates > min_date().
$branches = array();

// Flatten out the majors.
foreach (get_all_branches() as $major_branches) {
foreach ($major_branches as $branch => $version) {
if (version_compare($branch, '5.3', 'ge') && get_branch_security_eol_date($branch) > min_date()) {
$branches[$branch] = $version;
}
}
}

ksort($branches);
return $branches;
}

function min_date() {
$now = new DateTime('January 1');
return $now->sub(new DateInterval('P3Y'));
$now = new DateTime('January 1');
return $now->sub(new DateInterval('P3Y'));
}

function max_date() {
$now = new DateTime('January 1');
return $now->add(new DateInterval('P5Y'));
$now = new DateTime('January 1');
return $now->add(new DateInterval('P5Y'));
}

function date_horiz_coord(DateTime $date) {
$diff = $date->diff(min_date());
if (!$diff->invert) {
return $GLOBALS['margin_left'];
}
return $GLOBALS['margin_left'] + ($diff->days / (365.24 / $GLOBALS['year_width']));
$diff = $date->diff(min_date());
if (!$diff->invert) {
return $GLOBALS['margin_left'];
}
return $GLOBALS['margin_left'] + ($diff->days / (365.24 / $GLOBALS['year_width']));
}

$branches = branches_to_show();
$i = 0;
foreach ($branches as $branch => $version) {
$branches[$branch]['top'] = $header_height + ($branch_height * $i++);
$branches[$branch]['top'] = $header_height + ($branch_height * $i++);
}

if (!isset($non_standalone)) {
header('Content-Type: image/svg+xml');
echo '<?xml version="1.0"?>';
header('Content-Type: image/svg+xml');
echo '<?xml version="1.0"?>';
}

$years = iterator_to_array(new DatePeriod(min_date(), new DateInterval('P1Y'), max_date()));
Expand Down Expand Up @@ -132,10 +132,10 @@ function date_horiz_coord(DateTime $date) {
<g class="branches">
<?php foreach ($branches as $branch => $version): ?>
<?php
$x_release = date_horiz_coord(get_branch_release_date($branch));
$x_bug = date_horiz_coord(get_branch_bug_eol_date($branch));
$x_eol = date_horiz_coord(get_branch_security_eol_date($branch));
?>
$x_release = date_horiz_coord(get_branch_release_date($branch));
$x_bug = date_horiz_coord(get_branch_bug_eol_date($branch));
$x_eol = date_horiz_coord(get_branch_security_eol_date($branch));
?>
<rect class="stable" x="<?php echo $x_release ?>" y="<?php echo $version['top'] ?>" width="<?php echo $x_bug - $x_release ?>" height="<?php echo $branch_height ?>" />
<rect class="security" x="<?php echo $x_bug ?>" y="<?php echo $version['top'] ?>" width="<?php echo $x_eol - $x_bug ?>" height="<?php echo $branch_height ?>" />
<?php endforeach ?>
Expand All @@ -154,9 +154,9 @@ function date_horiz_coord(DateTime $date) {
<!-- Today -->
<g class="today">
<?php
$now = new DateTime;
$x = date_horiz_coord($now);
?>
$now = new DateTime;
$x = date_horiz_coord($now);
?>
<line x1="<?php echo $x ?>" y1="<?php echo $header_height ?>" x2="<?php echo $x ?>" y2="<?php echo $header_height + (count($branches) * $branch_height) ?>" />
<text x="<?php echo $x ?>" y="<?php echo $header_height + (count($branches) * $branch_height) + (0.8 * $footer_height) ?>">
<?php echo 'Today: '.$now->format('j M Y') ?>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
);
$announcements = "";
foreach($CONF_TEASER as $category => $entries) {
if ($entries) {
if ($entries) {
$announcements .= '<div class="panel">';
$announcements .= ' <a href="/conferences" class="headline" title="' . $conftype[$category] . '">' . $conftype[$category] .'</a>';
$announcements .= '<div class="body"><ul>';
Expand Down
4 changes: 2 additions & 2 deletions manual-lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
}

if(!empty($_GET['scope']) && is_string($_GET['scope'])) {
$scope = htmlspecialchars($_GET['scope'], ENT_QUOTES, 'UTF-8');
$scope = htmlspecialchars($_GET['scope'], ENT_QUOTES, 'UTF-8');
} else {
$scope = '';
$scope = '';
}

// Prepare data for search
Expand Down
54 changes: 27 additions & 27 deletions manual/spam_challenge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,63 @@
const NUMS = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');

function plus($a, $b) {
return $a + $b;
return $a + $b;
}

function gen_plus($a) {
return rand(0, 9 - $a);
return rand(0, 9 - $a);
}

function minus($a, $b) {
return $a - $b;
return $a - $b;
}

function gen_minus($a) {
return rand(0, $a);
return rand(0, $a);
}

function print_infix($name, $a, $b) {
return "$a $name $b";
return "$a $name $b";
}

function print_prefix($name, $a, $b) {
return "$name($a, $b)";
return "$name($a, $b)";
}

const CHALLENGES = array(
// name, print, generator
array('max', 'print_prefix'),
array('min', 'print_prefix'),
array('minus', 'print_infix', 'gen_minus'),
array('plus', 'print_infix', 'gen_plus'),
// name, print, generator
array('max', 'print_prefix'),
array('min', 'print_prefix'),
array('minus', 'print_infix', 'gen_minus'),
array('plus', 'print_infix', 'gen_plus'),
);

// generate a challenge
function gen_challenge() {
$c = CHALLENGES[rand(0, count(CHALLENGES)-1)];
$c = CHALLENGES[rand(0, count(CHALLENGES)-1)];

$a = rand(0, 9);
$an = NUMS[$a];
$b = isset($c[2]) ? $c[2]($a) : rand(0, 9);
$bn = NUMS[$b];
$a = rand(0, 9);
$an = NUMS[$a];
$b = isset($c[2]) ? $c[2]($a) : rand(0, 9);
$bn = NUMS[$b];

return array($c[0], $an, $bn, $c[1]($c[0], $an, $bn));
return array($c[0], $an, $bn, $c[1]($c[0], $an, $bn));
}


// test an answer for validity
function test_answer($name, $an, $bn, $answer) {
foreach (CHALLENGES as $x) {
if ($x[0] === $name) {
$c = $x;
break;
}
}
foreach (CHALLENGES as $x) {
if ($x[0] === $name) {
$c = $x;
break;
}
}

$a = array_search($an, NUMS);
$b = array_search($bn, NUMS);
$a = array_search($an, NUMS);
$b = array_search($bn, NUMS);

if (empty($c) || $a === false || $b === false) return false;
if (empty($c) || $a === false || $b === false) return false;

return (NUMS[$c[0]($a, $b)] === $answer);
return (NUMS[$c[0]($a, $b)] === $answer);
}
10 changes: 5 additions & 5 deletions mirror-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
$dist = $latest['source'][0];
$filename = __DIR__ . "/distributions/{$dist['filename']}";
if (!file_exists($filename)) {
$hash_ok = 0;
$hash_ok = 0;
} elseif (isset($dist['sha256']) &&
function_exists('hash_file') &&
in_array('sha256', hash_algos(), true)) {
$hash_ok = (int)(hash_file('sha256', $filename) === $dist['sha256']);
function_exists('hash_file') &&
in_array('sha256', hash_algos(), true)) {
$hash_ok = (int)(hash_file('sha256', $filename) === $dist['sha256']);
} else {
$hash_ok = 0;
$hash_ok = 0;
}

// Does this mirror have sqlite?
Expand Down
4 changes: 2 additions & 2 deletions releases/5_3_3.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
non-namespaced classes.

<p><?php
highlight_string('<?php
highlight_string('<?php
namespace Foo;
class Bar {
public function Bar() {
Expand All @@ -31,7 +31,7 @@ public function Bar() {
}
}
?>');
?></p>
?></p>
<p>There is no impact on migration from 5.2.x because namespaces were only introduced in PHP 5.3.</p></li>
</ul>
<p>
Expand Down
Loading

0 comments on commit f3585d9

Please sign in to comment.