https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106388
Revision: 106388
Author: platonides
Date: 2011-12-15 22:41:45 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Learn variable typing from function hints
Modified Paths:
--------------
trunk/tools/code-utils/check-vars.php
Modified: trunk/tools/code-utils/check-vars.php
===================================================================
--- trunk/tools/code-utils/check-vars.php 2011-12-15 22:26:16 UTC (rev
106387)
+++ trunk/tools/code-utils/check-vars.php 2011-12-15 22:41:45 UTC (rev
106388)
@@ -434,6 +434,7 @@
$this->mInProfilingFunction =
false;
$this->mAfterProfileOut = 0;
$this->mFunctionGlobals =
array();
+ $this->mLocalVariableTypes =
array();
$currentToken[0] =
self::FUNCTION_DEFINITION;
$this->mKnownFunctions[] =
$this->mClass ? $this->mClass . "::" . $this->mFunction : $this->mFunction;
@@ -513,6 +514,8 @@
if (
$lastMeaningfulToken[0] == T_PAAMAYIM_NEKUDOTAYIM ) {
/* Class
variable. No check for now */
+ } elseif (
$lastMeaningfulToken[0] == T_STRING ) {
+
$this->mLocalVariableTypes[ $token[1] ] = $lastMeaningfulToken[0];
} else {
if ( isset(
$this->mFunctionGlobals[ $token[1] ] ) ) {
$this->mFunctionGlobals[ $token[1] ][0] ++;
@@ -885,6 +888,10 @@
}
if ( $token[1] == '$this' )
return $this->mClass;
+
+ if ( isset( $this->mLocalVariableTypes[$token[1]] ) )
+ return $this->mLocalVariableTypes[$token[1]];
+
$name = substr( $token[1], 1 );
} elseif ( ( $token[0] == T_STRING ) || ( $token[0] ==
self::CLASS_MEMBER ) ) {
if ( ( $token[1] == 'self' ) && !isset( $token['base']
) )
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs