Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ protected function checkForThisWithinClass(
}

foreach (array_reverse($token['conditions'], true) as $scopePtr => $scopeCode) {
// $this within a closure is invalid
// $this within a closure is valid
// Note: have to fetch code from $tokens, T_CLOSURE isn't set for conditions codes.
if ($tokens[$scopePtr]['code'] === T_CLOSURE) {
return false;
return true;
}
if ($scopeCode === T_CLASS) {
return true;
Expand Down
2 changes: 0 additions & 2 deletions VariableAnalysis/Tests/CodeAnalysis/VariableAnalysisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ public function testFunctionWithClosureWarnings() {
26,
27,
28,
36,
37,
35,
];
$this->assertEquals($expectedWarnings, $lines);
Expand Down