44use PHP_CodeSniffer \Sniffs \Sniff ;
55use PHP_CodeSniffer \Files \File ;
66
7- /**
8- * This file is part of the VariableAnalysis addon for PHP_CodeSniffer.
9- *
10- * PHP version 5
11- *
12- * @category PHP
13- * @package PHP_CodeSniffer
14- * @author Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
15- * @copyright 2011-2012 Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
16- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
17- * @link http://pear.php.net/package/PHP_CodeSniffer
18- */
19-
207/**
218 * Holds details of a scope.
22- *
23- * @category PHP
24- * @package PHP_CodeSniffer
25- * @author Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
26- * @copyright 2011-2012 Sam Graham <php-codesniffer-plugins BLAHBLAH illusori.co.uk>
27- * @link http://pear.php.net/package/PHP_CodeSniffer
289 */
2910class ScopeInfo {
3011 public $ owner ;
@@ -40,12 +21,6 @@ function __construct($currScope) {
4021
4122/**
4223 * Holds details of a variable within a scope.
43- *
44- * @category PHP
45- * @package PHP_CodeSniffer
46- * @author Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
47- * @copyright 2011 Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
48- * @link http://pear.php.net/package/PHP_CodeSniffer
4924 */
5025class VariableInfo {
5126 public $ name ;
@@ -66,24 +41,18 @@ class VariableInfo {
6641 'static ' => 'static variable ' ,
6742 'global ' => 'global variable ' ,
6843 'bound ' => 'bound variable ' ,
69- );
44+ );
7045
7146 function __construct ($ varName ) {
7247 $ this ->name = $ varName ;
7348 }
7449}
7550
7651/**
77- * Checks the for undefined function variables.
52+ * Checks the code for undefined function variables.
7853 *
7954 * This sniff checks that all function variables
8055 * are defined in the function body.
81- *
82- * @category PHP
83- * @package VariableAnalysis
84- * @author Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
85- * @copyright 2011 Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk>
86- * @link http://pear.php.net/package/PHP_CodeSniffer
8756 */
8857class VariableAnalysisSniff implements Sniff {
8958 /**
@@ -334,7 +303,7 @@ class VariableAnalysisSniff implements Sniff {
334303 'yaz_hits ' => array (2 ),
335304 'yaz_scan_result ' => array (2 ),
336305 'yaz_wait ' => array (1 ),
337- );
306+ );
338307
339308 /**
340309 * Allows an install to extend the list of known pass-by-reference functions
@@ -383,7 +352,7 @@ public function register() {
383352 T_HEREDOC ,
384353 T_CLOSE_CURLY_BRACKET ,
385354 T_STRING ,
386- );
355+ );
387356 }//end register()
388357
389358 /**
@@ -491,8 +460,8 @@ function markVariableDeclaration($varName, $scopeType, $typeHint, $stackPtr, $cu
491460 VariableInfo::$ scopeTypeDescriptions [$ varInfo ->scopeType ],
492461 "\${$ varName }" ,
493462 VariableInfo::$ scopeTypeDescriptions [$ scopeType ],
494- )
495- );
463+ )
464+ );
496465 }
497466 }
498467 $ varInfo ->scopeType = $ scopeType ;
@@ -750,7 +719,7 @@ protected function checkForFunctionPrototype(
750719 $ openPtr - 1 , null , true , null , true );
751720 if (($ functionPtr !== false ) &&
752721 (($ tokens [$ functionPtr ]['code ' ] === T_FUNCTION ) ||
753- ($ tokens [$ functionPtr ]['code ' ] === T_CLOSURE ))) {
722+ ($ tokens [$ functionPtr ]['code ' ] === T_CLOSURE ))) {
754723 // TODO: typeHint
755724 $ this ->markVariableDeclaration ($ varName , 'param ' , null , $ stackPtr , $ functionPtr );
756725 // Are we pass-by-reference?
@@ -875,7 +844,7 @@ protected function checkForSuperGlobal(
875844 '_ENV ' ,
876845 'argv ' ,
877846 'argc ' ,
878- ))) {
847+ ))) {
879848 return true ;
880849 }
881850
@@ -1051,7 +1020,7 @@ protected function checkForStaticDeclaration(
10511020 T_DOUBLE_COLON ,
10521021 T_START_HEREDOC , T_HEREDOC , T_END_HEREDOC ,
10531022 T_START_NOWDOC , T_NOWDOC , T_END_NOWDOC ,
1054- ),
1023+ ),
10551024 $ stackPtr - 1 , null , true , null , true );
10561025 if (($ staticPtr === false ) || ($ tokens [$ staticPtr ]['code ' ] !== T_STATIC )) {
10571026 //if ($varName == 'static4') {
@@ -1481,8 +1450,8 @@ protected function processScopeClose(
14811450 array (
14821451 VariableInfo::$ scopeTypeDescriptions [$ varInfo ->scopeType ],
14831452 "\${$ varInfo ->name }" ,
1484- )
1485- );
1453+ )
1454+ );
14861455 }
14871456 if (isset ($ varInfo ->firstInitialized )) {
14881457 $ phpcsFile ->addWarning (
@@ -1492,8 +1461,8 @@ protected function processScopeClose(
14921461 array (
14931462 VariableInfo::$ scopeTypeDescriptions [$ varInfo ->scopeType ],
14941463 "\${$ varInfo ->name }" ,
1495- )
1496- );
1464+ )
1465+ );
14971466 }
14981467 }
14991468 }
0 commit comments