Skip to content

Commit

Permalink
Fixed notice
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Aug 1, 2017
1 parent e67db7d commit 34ee67f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Expand Up @@ -157,11 +157,15 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $classPointer)
$newTokenPointer = TokenHelper::findPreviousEffective($phpcsFile, $tokenPointer - 1);
if ($tokens[$newTokenPointer]['code'] === T_NEW) {
$variableTokenPointer = TokenHelper::findPreviousLocal($phpcsFile, T_VARIABLE, $newTokenPointer - 1);
$scopeMethodPointer = TokenHelper::findPrevious($phpcsFile, T_FUNCTION, $variableTokenPointer - 1);
for ($i = $tokens[$scopeMethodPointer]['scope_opener']; $i < $tokens[$scopeMethodPointer]['scope_closer']; $i++) {
if ($tokens[$i]['content'] === $tokens[$variableTokenPointer]['content']) {
$findUsagesStartTokenPointer = $checkVariable($i);
if ($variableTokenPointer !== null) {
$scopeMethodPointer = TokenHelper::findPrevious($phpcsFile, T_FUNCTION, $variableTokenPointer - 1);
for ($i = $tokens[$scopeMethodPointer]['scope_opener']; $i < $tokens[$scopeMethodPointer]['scope_closer']; $i++) {
if ($tokens[$i]['content'] === $tokens[$variableTokenPointer]['content']) {
$findUsagesStartTokenPointer = $checkVariable($i);
}
}
} else {
$findUsagesStartTokenPointer = $tokenPointer + 1;
}
} else {
$doubleColonTokenPointer = TokenHelper::findNextEffective($phpcsFile, $tokenPointer + 1);
Expand Down
Expand Up @@ -15,4 +15,9 @@ private function setUp()
{
}

public static function foo()
{
return new self();
}

}
Expand Up @@ -5,7 +5,7 @@ class ClassWithPrivateMethodCalledOnSelfInstance

public static function create()
{
$self = new self();
$self = new static();
$self->setUp();

return $self;
Expand All @@ -15,4 +15,9 @@ private function setUp()
{
}

public static function foo()
{
return new static();
}

}

0 comments on commit 34ee67f

Please sign in to comment.