Skip to content

Commit 92425a0

Browse files
committed
SlevomatCodingStandard.Functions.StaticClosure: Fixed false positive when $this is the last token
1 parent a4cef98 commit 92425a0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

SlevomatCodingStandard/Sniffs/Functions/StaticClosureSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function process(File $phpcsFile, $closurePointer): void
6363
T_VARIABLE,
6464
'$this',
6565
$closureScopeOpenerPointer + 1,
66-
$closureScopeCloserPointer,
66+
$closureScopeCloserPointer + 1,
6767
);
6868
if ($thisPointer !== null) {
6969
return;

tests/Sniffs/Functions/data/staticClosureNoErrors.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public function arrayFilterEtc($list)
4242
return count(array_filter($list->call('something'), fn (object $object): bool => $object->getAnything() === $this->anything)) === 1;
4343
}
4444

45+
public function thisIsTheLastToken()
46+
{
47+
return array_values(array_filter(self::getAvailableEnums(), fn (self $state): bool => $state->getParent() === $this));
48+
}
49+
4550
}
4651

4752
Closure::bind(function ($instance, $value) {

0 commit comments

Comments
 (0)