r68063 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68062‎ | r68063 | r68064 >
Date:12:04, 15 June 2010
Author:reedy
Status:ok
Tags:
Comment:
Minor refactoring to stylize.php to reduce code duplication

Remove some whitespace
Modified paths:
  • /trunk/tools/code-utils/stylize.php (modified) (history)

Diff [purge]

Index: trunk/tools/code-utils/stylize.php
@@ -43,23 +43,24 @@
4444
4545 function stylize_file( $filename, $backup = true ) {
4646 echo "Stylizing file $filename\n";
 47+
 48+ $s = ( $filename == '-' )
 49+ ? file_get_contents( '/dev/stdin' )
 50+ : file_get_contents( $filename );
 51+
 52+ if ( $s === false ) {
 53+ return;
 54+ }
 55+
 56+ $stylizer = new Stylizer( $s );
 57+ $s = $stylizer->stylize();
 58+
4759 if ( $filename == '-' ) {
48 - $s = file_get_contents( '/dev/stdin' );
49 - if ( $s === false ) {
50 - return;
51 - }
52 - $stylizer = new Stylizer( $s );
53 - $s = $stylizer->stylize();
5460 echo $s;
5561 } else {
56 - $s = file_get_contents( $filename );
57 - if ( $s === false ) {
58 - return;
59 - }
60 - $stylizer = new Stylizer( $s );
61 - $s = $stylizer->stylize();
62 - if ( $backup )
 62+ if ( $backup ) {
6363 rename( $filename, "$filename~" );
 64+ }
6465 file_put_contents( $filename, $s );
6566 }
6667 }
@@ -152,7 +153,6 @@
153154 var $endl = "
154155 ";
155156
156 -
157157 function __construct( $s ) {
158158 $s = str_replace( "\r\n", "\n", $s );
159159 $this->tokens = token_get_all( $s );
@@ -299,5 +299,4 @@
300300 // Fix whitespace at the line end
301301 return preg_replace( '!^([\t ]+)(\n.*)$!s', '\2', $s, 1 );
302302 }
303 -
304303 }

Status & tagging log