r72836 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72835‎ | r72836 | r72837 >
Date:22:04, 11 September 2010
Author:platonides
Status:deferred
Tags:
Comment:
Empty statements detection
Changes in global variables
Modified paths:
  • /trunk/tools/code-utils/check-vars.php (modified) (history)

Diff [purge]

Index: trunk/tools/code-utils/check-vars.php
@@ -4,7 +4,7 @@
55 * Checks a number of syntax conventions on variables from a valid PHP file.
66 *
77 * Run as:
8 - * find phase3/ \( -name \*.php -or -name \*.inc \) -not \( -name importUseModWiki.php -o -name diffLanguage.php -o -name LocalSettings.php \) -exec php tools/code-utils/check-vars.php \{\} +
 8+ * find phase3/ \( -name \*.php -or -name \*.inc \) -not \( -name importUseModWiki.php -o -name diffLanguage.php -o -name LocalSettings.php -o -name Parser?????.php \) -exec php tools/code-utils/check-vars.php \{\} +
99 */
1010
1111 require_once( dirname( __FILE__ ) . "/../../phase3/includes/Defines.php" ); # Faster than parsing
@@ -77,12 +77,9 @@
7878 '$wgAutoloadLocalClasses', # AutoLoader.php, a couple of readers
7979 '$wgCanonicalNamespaceNames', # Namespace.php
8080 '$wgContLang', # Setup.php
81 - '$wgContLanguageCode', # Should probably be removed
82 - '$wgDBcataloged', # http://www.mediawiki.org/wiki/Special:Code/MediaWiki/45755#c7954
8381 '$wgDeferredUpdateList', # Setup.php
8482 '$wgExtModifiedFields', '$wgExtNewFields', '$wgExtNewIndexes', '$wgExtNewTables', # Updates
8583 '$wgFeedClasses', # Defines.php, many uses
86 - '$wgIP', # Setup.php
8784 '$wgLang', # Setup.php
8885 '$wgLanguageNames', # Language.php, read by others
8986 '$wgMemc', # Setup.php
@@ -122,7 +119,11 @@
123120 '$wgHtmlEntities' => array( 'Sanitizer.php' ),
124121 '$wgHtmlEntityAliases' => array( 'Sanitizer.php' ),
125122 '$wgFullyInitialised' => array( /* Set */ 'Setup.php', /* read */ 'Exception.php' ),
 123+ '$wgContLanguageCode' => array( 'Setup.php' ),
126124 '$wgUseLatin1' => array( 'FiveUpgrade.inc' ), # If you upgrade from MW < 1.5 it will be there
 125+ '$wgDatabase' => array( 'DatabaseUpdater.php' ),
 126+ '$wgExtPGNewFields' => array( 'DatabaseUpdater.php', 'PostgresUpdater.php' ),
 127+ '$wgExtPGAlteredFields' => array( 'DatabaseUpdater.php', 'PostgresUpdater.php' ),
127128 '$errs' => array( 'Installer.php' ),
128129 '$mainListOpened' => array( 'Installer.php' ),
129130 '$optionsWithArgs' => array( 'commandLine.inc' ),
@@ -194,8 +195,17 @@
195196
196197 if ( $lastMeaningfulToken[0] == T_OPEN_TAG && $token[0] == T_OPEN_TAG ) {
197198 # See r69767
198 - $this->warning( "$token[1] in line $token[2] after $lastMeaningfulToken[1] in line $lastMeaningfulToken[2]" );
 199+ $this->warning( "{$token[1]} in line {$token[2]} after {$lastMeaningfulToken[1]} in line {$lastMeaningfulToken[2]}" );
199200 }
 201+ if ( $token == ';' ) {
 202+ if ( $lastMeaningfulToken == ';' ) {
 203+ # See r72751, warn on ;;
 204+ $this->warning( "Empty statement" );
 205+ } elseif ( $lastMeaningfulToken[0] == T_FOR ) {
 206+ # But not on infinte for loops: for ( ; ; )
 207+ $currentToken = array(';', ';', $lastMeaningfulToken[2] );
 208+ }
 209+ }
200210
201211 if ( $lastMeaningfulToken[0] == T_DECLARE && $token[0] == T_STRING ) {
202212 $currentToken[0] = T_WHITESPACE; # Ignore the ticks or encoding

Status & tagging log