Author: Andreas Möller (localheinz)
Committer: GitHub (web-flow)
Pusher: cmb69
Date: 2022-07-15T14:48:44+02:00

Commit: 
https://github.com/php/web-php/commit/f127de5db9a95c271f3c1a8126f654e9ca231609
Raw diff: 
https://github.com/php/web-php/commit/f127de5db9a95c271f3c1a8126f654e9ca231609.diff

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.

Changed paths:
  M  .php-cs-fixer.php
  M  cal.php
  M  error.php
  M  include/langchooser.inc
  M  include/layout.inc
  M  include/manual-lookup.inc
  M  include/prepend.inc
  M  include/shared-manual.inc
  M  manual/help-translate.php
  M  manual/spam_challenge.php
  M  releases/index.php
  M  src/News/Entry.php
  M  submit-event.php


Diff:

diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index 6d4f8da6d..bee766f1f 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -15,18 +15,21 @@
     ->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;
diff --git a/cal.php b/cal.php
index 990040cf5..9da3e20d1 100644
--- a/cal.php
+++ b/cal.php
@@ -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,
     );
diff --git a/error.php b/error.php
index f3bb55053..01d197678 100644
--- a/error.php
+++ b/error.php
@@ -175,7 +175,7 @@
 // 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");
 }
diff --git a/include/langchooser.inc b/include/langchooser.inc
index cc42acf41..9b6cd8a0e 100644
--- a/include/langchooser.inc
+++ b/include/langchooser.inc
@@ -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;
     }
diff --git a/include/layout.inc b/include/layout.inc
index 26944447f..2d4ff6367 100644
--- a/include/layout.inc
+++ b/include/layout.inc
@@ -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;
         }
 
diff --git a/include/manual-lookup.inc b/include/manual-lookup.inc
index cb125a43a..6dcde1321 100644
--- a/include/manual-lookup.inc
+++ b/include/manual-lookup.inc
@@ -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) );
diff --git a/include/prepend.inc b/include/prepend.inc
index 6332d5a33..51a7024f3 100644
--- a/include/prepend.inc
+++ b/include/prepend.inc
@@ -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;
     }
 
diff --git a/include/shared-manual.inc b/include/shared-manual.inc
index 0fc1104c8..dd43245d1 100644
--- a/include/shared-manual.inc
+++ b/include/shared-manual.inc
@@ -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)
             );
         }
diff --git a/manual/help-translate.php b/manual/help-translate.php
index 577e5e197..25f0da297 100644
--- a/manual/help-translate.php
+++ b/manual/help-translate.php
@@ -28,7 +28,7 @@
 
 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>';
diff --git a/manual/spam_challenge.php b/manual/spam_challenge.php
index dea89dd66..9a0c353ac 100644
--- a/manual/spam_challenge.php
+++ b/manual/spam_challenge.php
@@ -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;
 
diff --git a/releases/index.php b/releases/index.php
index 1a8a8bb7c..bd1651626 100644
--- a/releases/index.php
+++ b/releases/index.php
@@ -89,7 +89,7 @@
 $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>.';
diff --git a/src/News/Entry.php b/src/News/Entry.php
index c94cb0d9b..0d1ee0706 100755
--- a/src/News/Entry.php
+++ b/src/News/Entry.php
@@ -48,7 +48,7 @@ public function addCategory(string $cat): self {
         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;
diff --git a/submit-event.php b/submit-event.php
index f7301f0e8..3b7647593 100644
--- a/submit-event.php
+++ b/submit-event.php
@@ -69,7 +69,7 @@
     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.";
     }
 

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to