r63719 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63718‎ | r63719 | r63720 >
Date:00:46, 14 March 2010
Author:jeroendedauw
Status:ok (Comments)
Tags:
Comment:
Stylized stylize.php :D
Modified paths:
  • /trunk/tools/code-utils/lint.php (modified) (history)
  • /trunk/tools/code-utils/stylize.php (modified) (history)

Diff [purge]

Index: trunk/tools/code-utils/stylize.php
@@ -29,7 +29,7 @@
3030 }
3131
3232 function stylize_recursivly( $dir ) {
33 - foreach ( glob("$dir/*") as $dirOrFile ) {
 33+ foreach ( glob( "$dir/*" ) as $dirOrFile ) {
3434 if ( is_dir( $dirOrFile ) ) { // It's a directory, so call this function again.
3535 stylize_recursivly( $dirOrFile );
3636 } elseif ( is_file( $dirOrFile ) ) { // It's a file, so let's stylize it.
@@ -38,7 +38,7 @@
3939 stylize_file( $dirOrFile, false );
4040 }
4141 }
42 - }
 42+ }
4343 }
4444
4545 function stylize_file( $filename, $backup = true ) {
@@ -69,7 +69,7 @@
7070 static $tablesInitialised = false;
7171 static $xSpaceBefore, $xSpaceAfter;
7272
73 - static $space = array(
 73+ static $space = array(
7474 T_WHITESPACE,
7575 'START',
7676 'END',
@@ -121,7 +121,7 @@
122122 '=',
123123 '+',
124124 '|',
125 - //':', can be a case label
 125+ // ':', can be a case label
126126 '.',
127127 '<',
128128 '>',
@@ -156,11 +156,11 @@
157157 $s = str_replace( "\r\n", "\n", $s );
158158 $this->tokens = token_get_all( $s );
159159 if ( !self::$tablesInitialised ) {
160 - self::$xSpaceBefore = array_combine(
 160+ self::$xSpaceBefore = array_combine(
161161 array_merge( self::$spaceBefore, self::$spaceBothSides ),
162162 array_fill( 0, count( self::$spaceBefore ) + count( self::$spaceBothSides ), true )
163163 );
164 - self::$xSpaceAfter = array_combine(
 164+ self::$xSpaceAfter = array_combine(
165165 array_merge( self::$spaceAfter, self::$spaceBothSides ),
166166 array_fill( 0, count( self::$spaceAfter ) + count( self::$spaceBothSides ), true )
167167 );
@@ -170,7 +170,7 @@
171171 function get( $i ) {
172172 if ( $i < 0 ) {
173173 return array( 'START', '' );
174 - } elseif( $i >= count( $this->tokens ) ) {
 174+ } elseif ( $i >= count( $this->tokens ) ) {
175175 return array( 'END', '' );
176176 } else {
177177 $token = $this->tokens[$i];
@@ -245,14 +245,14 @@
246246 }
247247
248248 // Detect close pairs like ()
249 - $closePairBefore = isset( self::$closePairs[$prevType] )
 249+ $closePairBefore = isset( self::$closePairs[$prevType] )
250250 && $curType == self::$closePairs[$prevType];
251 - $closePairAfter = isset( self::$closePairs[$curType] )
 251+ $closePairAfter = isset( self::$closePairs[$curType] )
252252 && $nextType == self::$closePairs[$curType];
253253
254254 // Add space before
255 - if ( $this->isSpaceBefore( $curToken )
256 - && !$this->isSpace( $prevToken )
 255+ if ( $this->isSpaceBefore( $curToken )
 256+ && !$this->isSpace( $prevToken )
257257 && !$closePairBefore
258258 ) {
259259 $out .= ' ';
@@ -274,7 +274,7 @@
275275 }
276276
277277 // Add space after
278 - if ( $wantSpaceAfter
 278+ if ( $wantSpaceAfter
279279 && !$closePairAfter
280280 && !$this->isSpace( $nextToken )
281281 && !$this->isSpaceBefore( $nextToken )
Index: trunk/tools/code-utils/lint.php
@@ -16,7 +16,7 @@
1717 $dir = '.';
1818 }
1919
20 -if ( !check_dir( $dir ) ){
 20+if ( !check_dir( $dir ) ) {
2121 exit( 1 );
2222 } else {
2323 exit( 0 );
@@ -34,7 +34,7 @@
3535 }
3636 if ( is_dir( "$dir/$fileName" ) ) {
3737 $ret = check_dir( "$dir/$fileName" );
38 - } elseif ( substr( $fileName, -4 ) == '.php' ) {
 38+ } elseif ( substr( $fileName, - 4 ) == '.php' ) {
3939 $ret = check_file( "$dir/$fileName" );
4040 } else {
4141 $ret = true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r63736Fix r63718 and r63719: correct spelling of "stylize_recursivly()", fix syntax...catrope12:44, 14 March 2010

Comments

#Comment by Siebrand (talk | contribs)   11:55, 14 March 2010

Heh ;)

- } elseif ( substr( $fileName, -4 ) == '.php' ) { + } elseif ( substr( $fileName, - 4 ) == '.php' ) {

#Comment by Jeroen De Dauw (talk | contribs)   16:51, 14 March 2010

Yeah, that's odd. Is it supposed to happen? If not, it's a bug in the stylize script...

#Comment by Siebrand (talk | contribs)   19:01, 14 March 2010

It's a bug. For negative parameters the minus sign should not be separated from the number.

Status & tagging log