Skip to content

Commit 0e902fe

Browse files
phpstan-botclaude
andcommitted
Use array_last() in ClosureCallContextMatcher
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2aa8657 commit 0e902fe

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/Analyser/ClosureCallContextMatcher.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPStan\Type\Generic\TemplateType;
1010
use PHPStan\Type\Type;
1111
use PHPStan\Type\TypeTraverser;
12+
use function array_last;
1213
use function count;
1314
use function strtolower;
1415

@@ -36,13 +37,12 @@ public static function matches(array $askStack, array $positionStack): bool
3637
if ($askStack === $positionStack) {
3738
return true;
3839
}
39-
$depth = count($askStack);
40-
if ($depth === 0 || $depth !== count($positionStack)) {
40+
if ($askStack === [] || count($askStack) !== count($positionStack)) {
4141
return true;
4242
}
4343

44-
[, $askParameter] = $askStack[$depth - 1];
45-
[$callee, $positionParameter] = $positionStack[$depth - 1];
44+
[, $askParameter] = array_last($askStack);
45+
[$callee, $positionParameter] = array_last($positionStack);
4646
if ($askParameter === null || $askParameter === $positionParameter) {
4747
return true;
4848
}

0 commit comments

Comments
 (0)