BUGFIX: Look for argument only in current statement

* Just check T_STRING as this are all function calls.
* Remove unused line of code.
* Limit position to current statement to not return later classname
  multiple times.

Relates: #44
This commit is contained in:
Daniel Siepmann 2017-05-09 12:05:54 +02:00
parent 2894784978
commit e3dd6013ba
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -34,7 +34,7 @@ class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends Ab
*/
public function register()
{
return Tokens::$functionNameTokens;
return [T_STRING];
}
/**
@ -57,13 +57,12 @@ class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends Ab
return;
}
$classnamePosition = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr);
$classnamePosition = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stackPtr, null, false, null, true);
if ($classnamePosition === false) {
return;
}
$classname = $tokens[$classnamePosition]['content'];
$this->originalTokenContent = $tokens[$classnamePosition]['content'];
$this->processFeatures($phpcsFile, $classnamePosition, $classname);
}
}