[ 'fooFoo(); break; case "B": $a->barBar(); break; }', ], 'getClassConstArg' => [ 'fooFoo(); break; case B::class: $a->barBar(); break; }', ], 'getClassExteriorArgClassConsts' => [ 'getMessage(); break; case LogicException::class: $e->getMessage(); break; } } ', ], 'getClassExteriorArg' => [ 'getMessage(); break; case "LogicException": $e->getMessage(); break; } }', ], 'switchGetClassVar' => [ 'foo(); break; } }', ], 'getTypeArg' => [ ' [ 'a !== null: return $obj->a; // definitely not null case !is_null($obj->b): return $obj->b; // definitely not null default: throw new \InvalidArgumentException("$obj->a or $obj->b must be set"); } }', ], 'switchMoTruthy' => [ 'a: return $obj->a; // definitely not null case $obj->b: return $obj->b; // definitely not null default: throw new \InvalidArgumentException("$obj->a or $obj->b must be set"); } }', ], 'switchWithBadBreak' => [ ' [ ' [ ' [ '$x' => 'bool', '$y' => 'bool', ], ], 'continueIsBreak' => [ ' [ ' [ 'maybeReturnsDT(); if (!is_null($dt)) { $dt = $dt->format(\DateTime::ISO8601); } break; } class A { public function maybeReturnsDT(): ?\DateTimeInterface { return rand(0,1) ? new \DateTime("now") : null; } }', ], 'issetInFallthrough' => [ ' 2) { echo "$x is large"; } break; } }', ], 'switchManyGetClass' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ '$a' => 'bool', '$b' => 'int', ], ], 'switchVarConditionalReAssignment' => [ ' [ '$a' => 'bool', ], ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'switchReturnTypeWithFallthroughAndBreak' => [ ' 'InvalidNullableReturnType', ], 'switchReturnTypeWithFallthroughAndConditionalBreak' => [ ' 'InvalidNullableReturnType', ], 'switchReturnTypeWithNoDefault' => [ ' 'InvalidNullableReturnType', ], 'getClassArgWrongClass' => [ 'barBar(); break; }', 'error_message' => 'UndefinedMethod', ], 'getClassMissingClass' => [ ' 'UndefinedClass', ], 'getTypeNotAType' => [ ' 'UnevaluatedCode', ], 'getTypeArgWrongArgs' => [ ' 'InvalidScalarArgument', ], 'switchBadMethodCallInCase' => [ ' 'InvalidScalarArgument', ], 'continueIsNotBreak' => [ ' 'ContinueOutsideLoop', ], 'defaultAboveCaseThatBreaks' => [ ' 'InvalidReturnType', ], 'SKIPPED-switchManyGetClassWithRepetitionWithProperLineNumber' => [ ' 'RedundantCondition - src/somefile.php:10', 'error_levels' => ['ParadoxicalCondition'], ], 'repeatedCaseValue' => [ ' 'ParadoxicalCondition - src/somefile.php:7', ], 'impossibleCaseValue' => [ ' 'TypeDoesNotContainType - src/somefile.php:11', ], 'impossibleCaseDefault' => [ ' 'ParadoxicalCondition - src/somefile.php:11', ], ]; } }