1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Enhancement: Enable strict_param fixer

We set strict param to false to ensure current behavior,
except for two cases where it is safe to go with true.

Closes GH-658.
This commit is contained in:
Andreas Möller
2022-07-15 14:48:44 +02:00
committed by GitHub
parent 5c9eab2f38
commit f127de5db9
13 changed files with 31 additions and 28 deletions

View File

@@ -15,18 +15,21 @@ $finder = $config->getFinder()
->notPath('include/pregen-news.inc')
->notPath('tests/run-tests.php');
$config->setRules([
'array_indentation' => true,
'constant_case' => true,
'indentation_type' => true,
'line_ending' => true,
'no_extra_blank_lines' => true,
'no_trailing_whitespace' => true,
'ordered_class_elements' => true,
'single_space_after_construct' => true,
'trim_array_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
]);
$config
->setRiskyAllowed(true)
->setRules([
'array_indentation' => true,
'constant_case' => true,
'indentation_type' => true,
'line_ending' => true,
'no_extra_blank_lines' => true,
'no_trailing_whitespace' => true,
'ordered_class_elements' => true,
'single_space_after_construct' => true,
'strict_param' => true,
'trim_array_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
]);
return $config;

View File

@@ -371,7 +371,7 @@ function read_event($fp)
'recur_day' => $recur_day,
'sdesc' => $sdesc,
'url' => $url,
'ldesc' => base64_decode($ldesc),
'ldesc' => base64_decode($ldesc, false),
'country' => $country,
'category' => $category,
);

View File

@@ -175,7 +175,7 @@ if (preg_match('/^GH-(\d+)$/', $URI, $matches)) {
// Redirect if the entered URI was a PHP page name (except some pages,
// which we display in the mirror's language or the explicitly specified
// language [see below])
if (!in_array($URI, array('mirror-info', 'error', 'mod')) &&
if (!in_array($URI, array('mirror-info', 'error', 'mod'), false) &&
file_exists($_SERVER['DOCUMENT_ROOT'] . "/$URI.php")) {
mirror_redirect("/$URI.php");
}

View File

@@ -177,7 +177,7 @@ function language_add($langcode, &$langs)
// Append language code in priority order if it is not
// there already and supported by the PHP site. Try to
// lower number of file_exists() calls to the minumum...
if (!in_array($langcode, $langs) && isset($LANGUAGES[$langcode])
if (!in_array($langcode, $langs, false) && isset($LANGUAGES[$langcode])
&& !isset($INACTIVE_ONLINE_LANGUAGES[$langcode])) {
$langs[] = $langcode;
}

View File

@@ -96,7 +96,7 @@ function make_image($file, $alt = false, $align = false, $extras = false,
// Convert right or left alignment to CSS float,
// but leave other alignments intact (for now)
if (in_array($align, array("right", "left"))) {
if (in_array($align, array("right", "left"), false)) {
$align = ' style="float: ' . $align . ';"';
} elseif ($align) {
$align = ' align="' . $align . '"';
@@ -402,7 +402,7 @@ function print_news($news, $dog, $max = 5, $onlyyear = null, $return = false) {
// Only print entries in the provided s/dog/cat/ egory
// If $dog is null, everything matches
foreach ($item["category"] as $category) {
if (is_null($dog) || in_array($category["term"], (array)$dog)) {
if (is_null($dog) || in_array($category["term"], (array)$dog, false)) {
$ok = true;
++$count;
break;
@@ -561,7 +561,7 @@ function news_toc($sections = null) {
foreach ($items as $section => $menu) {
// only print requested sections.
if (is_array($sections) && !in_array($section, $sections)) {
if (is_array($sections) && !in_array($section, $sections, false)) {
continue;
}

View File

@@ -107,7 +107,7 @@ function find_manual_page($lang, $keyword)
// when rsync updates the database
$dbh = false;
if (class_exists('PDO')) {
if (in_array('sqlite', PDO::getAvailableDrivers())) {
if (in_array('sqlite', PDO::getAvailableDrivers(), true)) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite')) {
try {
$dbh = new PDO( 'sqlite:' . $_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite', '', '', array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true) );

View File

@@ -140,7 +140,7 @@ function myphpnet_urlsearch($type = false)
global $MYPHPNET;
// Set type if specified and if correct
if ($type && in_array($type, array(MYPHPNET_URL_FUNC, MYPHPNET_URL_MANUAL))) {
if ($type && in_array($type, array(MYPHPNET_URL_FUNC, MYPHPNET_URL_MANUAL), false)) {
$MYPHPNET[1] = $type;
}

View File

@@ -102,7 +102,7 @@ function manual_notes_load($id)
"rate" => $rate,
"xwhen" => $ts,
"user" => $user,
"note" => base64_decode($note),
"note" => base64_decode($note, false),
"votes" => array("up"=> (int)$up, "down"=> (int)$down)
);
}

View File

@@ -28,7 +28,7 @@ $archived = array('da', 'kr', 'pl', 'tw');
foreach ($INACTIVE_ONLINE_LANGUAGES as $cc => $lang) {
$link = 'no archive';
if (in_array($cc, $archived)) {
if (in_array($cc, $archived, true)) {
$link = '<a href="http://docs.php.net/manual/'. $cc .'">archive</a>';
}
echo '<li>', $lang, ': (', $link, ')</li>';

View File

@@ -56,8 +56,8 @@ function test_answer($name, $an, $bn, $answer) {
}
}
$a = array_search($an, NUMS);
$b = array_search($bn, NUMS);
$a = array_search($an, NUMS, false);
$b = array_search($bn, NUMS, false);
if (empty($c) || $a === false || $b === false) return false;

View File

@@ -89,7 +89,7 @@ $active_majors = array_keys($RELEASES);
$latest = max($active_majors);
foreach ($OLDRELEASES as $major => $a) {
echo '<a id="v' .$major. '"></a>';
if (!in_array($major, $active_majors)) {
if (!in_array($major, $active_majors, false)) {
echo "\n<br>\n";
echo "<p>Support for PHP $major has been <b style=\"color: red;\">discontinued</b> ";
echo "since <b>" . current($a)['date'] . '</b>.';

View File

@@ -48,7 +48,7 @@ class Entry {
if (!isset(self::CATEGORIES[$cat])) {
throw new \Exception("Unknown category: $cat");
}
if (!in_array($cat, $this->categories)) {
if (!in_array($cat, $this->categories, false)) {
$this->categories[] = $cat;
}
return $this;

View File

@@ -69,7 +69,7 @@ if ($process) {
if (!$_POST['url']) {
$errors[] = "You must supply a URL with more information about the event.";
}
elseif (empty($pu['host']) || !in_array($pu['scheme'], $valid_schemes)) {
elseif (empty($pu['host']) || !in_array($pu['scheme'], $valid_schemes, false)) {
$errors[] = "The URL you supplied was invalid.";
}