Skip to content

Undetected fatal error when using continue outside loop #794

@muglug

Description

@muglug

PHP fails in both

<?php
continue;

and more complicatedly

<?php
switch (rand(0, 2)) {
  case 0:
    $foo = 1;
    break;
  case 1:
    $foo = 2;
    break;
  default:
    continue 2;
}

but PHPStan doesn't warn about either: https://phpstan.org/r/94a628563f6b4262aa0983114fab4b5b
https://phpstan.org/r/6b2847d5ee5b49b3e96bc20ed5ad3d53

Slightly related to #651, where continue 2 is valid and actionable because it's equivalent to a regular continue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions