Max command length using one line of code
authorAntoine Musso <hashar@users.mediawiki.org>
Sat, 4 Dec 2010 08:58:32 +0000 (08:58 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sat, 4 Dec 2010 08:58:32 +0000 (08:58 +0000)
Follow-up r76621 code review

maintenance/mcc.php

index 92f6863..a8c79a7 100644 (file)
@@ -31,10 +31,7 @@ function mccShowHelp( $command ) {
                $command = 'fullhelp';
        }
        if ( $command === 'fullhelp' ) {
-               $max_cmd_len = 0;
-               foreach( array_keys( $commandList ) as $cmd ) {
-                       $max_cmd_len = max( $max_cmd_len, strlen($cmd) );
-               }
+               $max_cmd_len = max( array_map( 'strlen', array_keys( $commandList ) ) );
                foreach ( $commandList as $cmd => $desc ) {
                        printf( "%-{$max_cmd_len}s: %s\n", $cmd, $desc );
                }