Merge "Setup: Avoid using count() function in any kind of loop(s)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 16 Jan 2019 07:04:36 +0000 (07:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 16 Jan 2019 07:04:36 +0000 (07:04 +0000)
includes/Setup.php

index aba050d..61fad2d 100644 (file)
@@ -367,10 +367,9 @@ if ( $wgRCFilterByAge ) {
        // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
        sort( $wgRCLinkDays );
 
-       // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
-       for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
-               if ( $wgRCLinkDays[$i] >= $rcMaxAgeDays ) {
-                       $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
+       foreach ( $wgRCLinkDays as $i => $days ) {
+               if ( $days >= $rcMaxAgeDays ) {
+                       array_splice( $wgRCLinkDays, $i + 1 );
                        break;
                }
        }