Skip to content

Switch statements that cover all possibilities should not need default #1016

@muglug

Description

@muglug

With value types, everything is known absolutely

foreach ([1, 2, 3] as $i) {
  switch ($i) {
    case 1:
      $a = "hello";
      break;
    case 2:
      $a = "goodbye";
      break;
    case 3:
      $a = "hello again";
      break;
  }

  echo $a;
}

Expected: No issue
Actual: Variable $a might not be defined.

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