Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lint:
--exclude tests/PHPStan/Levels/data/namedArguments.php \
--exclude tests/PHPStan/Rules/Keywords/data/continue-break.php \
--exclude tests/PHPStan/Rules/Keywords/data/continue-break-property-hook.php \
--exclude tests/PHPStan/Rules/Keywords/data/bug-13790.php \
--exclude tests/PHPStan/Rules/Properties/data/invalid-callable-property-type.php \
--exclude tests/PHPStan/Rules/Properties/data/properties-in-interface.php \
--exclude tests/PHPStan/Rules/Properties/data/read-only-property.php \
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Keywords/ContinueBreakInLoopRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array
$value = $node->num->value;
}

$parentStmtTypes = array_reverse($node->getAttribute(ParentStmtTypesVisitor::ATTRIBUTE_NAME));
$parentStmtTypes = array_reverse($node->getAttribute(ParentStmtTypesVisitor::ATTRIBUTE_NAME, []));
foreach ($parentStmtTypes as $parentStmtType) {
if ($parentStmtType === Stmt\Case_::class) {
continue;
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Keywords/ContinueBreakInLoopRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ public function testPropertyHooks(): void
]);
}

public function testBug13790(): void
{
$this->analyse([__DIR__ . '/data/bug-13790.php'], [
[
'Keyword break used outside of a loop or a switch statement.',
2,
],
]);
}

}
2 changes: 2 additions & 0 deletions tests/PHPStan/Rules/Keywords/data/bug-13790.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
break;
Loading