Browse Source

Add changes from rector rule RemoveUnusedNonEmptyArrayBeforeForeachRector

Adam Halfar 1 year ago
parent
commit
76e7e962d3

+ 5 - 7
contrib/validate-split-packages.php

@@ -92,13 +92,11 @@ foreach ($packages as $fullPackageName => $package) {
     }
 }
 
-if ($issues) {
-    foreach ($issues as $packageName => $packageIssues) {
-        echo "\033[31m" . $packageName  . ':' . "\033[0m" . PHP_EOL;
-        foreach ($packageIssues as $issue) {
-            echo "\033[31m" . ' - ' . $issue  . "\033[0m" . PHP_EOL;
-            $code = 1;
-        }
+foreach ($issues as $packageName => $packageIssues) {
+    echo "\033[31m" . $packageName  . ':' . "\033[0m" . PHP_EOL;
+    foreach ($packageIssues as $issue) {
+        echo "\033[31m" . ' - ' . $issue  . "\033[0m" . PHP_EOL;
+        $code = 1;
     }
 }
 

+ 6 - 8
src/Form/FormProtector.php

@@ -332,14 +332,12 @@ class FormProtector
         foreach ($fieldList as $i => $key) {
             $isLocked = in_array($key, $locked, true);
 
-            if ($unlockedFields) {
-                foreach ($unlockedFields as $off) {
-                    $off = explode('.', $off);
-                    $field = array_values(array_intersect(explode('.', $key), $off));
-                    $isUnlocked = ($field === $off);
-                    if ($isUnlocked) {
-                        break;
-                    }
+            foreach ($unlockedFields as $off) {
+                $off = explode('.', $off);
+                $field = array_values(array_intersect(explode('.', $key), $off));
+                $isUnlocked = ($field === $off);
+                if ($isUnlocked) {
+                    break;
                 }
             }
 

+ 3 - 5
src/Routing/Route/Route.php

@@ -731,11 +731,9 @@ class Route
         }
 
         // check patterns for routed params
-        if ($this->options) {
-            foreach ($this->options as $key => $pattern) {
-                if (isset($url[$key]) && !preg_match('#^' . $pattern . '$#u', (string)$url[$key])) {
-                    return null;
-                }
+        foreach ($this->options as $key => $pattern) {
+            if (isset($url[$key]) && !preg_match('#^' . $pattern . '$#u', (string)$url[$key])) {
+                return null;
             }
         }
         $url += $hostOptions;

+ 5 - 7
src/Utility/Hash.php

@@ -884,13 +884,11 @@ class Hash
     public static function maxDimensions(array $data): int
     {
         $depth = [];
-        if ($data) {
-            foreach ($data as $value) {
-                if (is_array($value)) {
-                    $depth[] = static::maxDimensions($value) + 1;
-                } else {
-                    $depth[] = 1;
-                }
+        foreach ($data as $value) {
+            if (is_array($value)) {
+                $depth[] = static::maxDimensions($value) + 1;
+            } else {
+                $depth[] = 1;
             }
         }