TASK: Use regex instead of whitespace char

* To be more bulletproof.

Relates: #3
This commit is contained in:
Daniel Siepmann 2017-03-16 12:01:01 +01:00
parent c3358654fa
commit 6361db2eaf
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -56,11 +56,11 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff implements PHP_Code
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (substr($tokens[$stackPtr]['content'], 0, 9) !== '/* @var $') {
if (preg_match('/\/\*\s+@var\s+\$/', $tokens[$stackPtr]['content']) !== 1) {
return;
}
$commentParts = explode(' ', $tokens [$stackPtr ]['content']);
$commentParts = preg_split('/\s+/', $tokens[$stackPtr]['content']);
if (count($commentParts) !== 5) {
return;
}
@ -77,7 +77,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff implements PHP_Code
*/
protected function getTokenForReplacement($classname)
{
$token = explode(' ', $this->originalTokenContent);
$token = preg_split('/\s+/', $this->originalTokenContent);
$token[3] = $classname;
return implode(' ', $token);