comparison vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractVariableSniff.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
62 62
63 }//end __construct() 63 }//end __construct()
64 64
65 65
66 /** 66 /**
67 * Processes the token in the specified PHP_CodeSniffer_File. 67 * Processes the token in the specified PHP_CodeSniffer\Files\File.
68 * 68 *
69 * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this 69 * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this
70 * token was found. 70 * token was found.
71 * @param int $stackPtr The position where the token was found. 71 * @param int $stackPtr The position where the token was found.
72 * @param int $currScope The current scope opener token. 72 * @param int $currScope The current scope opener token.
90 } 90 }
91 91
92 return; 92 return;
93 } 93 }
94 94
95 // If this token is inside nested inside a function at a deeper 95 // If this token is nested inside a function at a deeper
96 // level than the current OO scope that was found, it's a normal 96 // level than the current OO scope that was found, it's a normal
97 // variable and not a member var. 97 // variable and not a member var.
98 $conditions = array_reverse($tokens[$stackPtr]['conditions'], true); 98 $conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
99 $inFunction = false; 99 $inFunction = false;
100 foreach ($conditions as $scope => $code) { 100 foreach ($conditions as $scope => $code) {
117 117
118 // Just make sure this isn't a variable in a function declaration. 118 // Just make sure this isn't a variable in a function declaration.
119 if ($inFunction === false && isset($tokens[$stackPtr]['nested_parenthesis']) === true) { 119 if ($inFunction === false && isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
120 foreach ($tokens[$stackPtr]['nested_parenthesis'] as $opener => $closer) { 120 foreach ($tokens[$stackPtr]['nested_parenthesis'] as $opener => $closer) {
121 if (isset($tokens[$opener]['parenthesis_owner']) === false) { 121 if (isset($tokens[$opener]['parenthesis_owner']) === false) {
122 // Check if this is a USE statement in a closure. 122 // Check if this is a USE statement for a closure.
123 $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true); 123 $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
124 if ($tokens[$prev]['code'] === T_USE) { 124 if ($tokens[$prev]['code'] === T_USE) {
125 $inFunction = true; 125 $inFunction = true;
126 break; 126 break;
127 } 127 }