[ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ '$b' => 'bool', ], ], 'assignInsideForeachWithBreak' => [ ' [ '$b' => 'bool', ], ], 'nullCheckInsideForeachWithContinue' => [ ' */ public static function loadMultiple() { return [new A, null]; } /** @return void */ public function barBar() { } } foreach (A::loadMultiple() as $a) { if ($a === null) { continue; } $a->barBar(); }', ], 'loopWithArrayKey' => [ '>> $args * @return array[] */ function get_merged_dict(array $args) { $merged = array(); foreach ($args as $group) { foreach ($group as $key => $value) { if (isset($merged[$key])) { $merged[$key] = array_merge($merged[$key], $value); } else { $merged[$key] = $value; } } } return $merged; }', ], 'loopWithIfElseNoParadox' => [ ' 5; foreach ([1, 2, 3] as $i) { if (rand(0, 5)) { $a[] = 5; continue; } if ($b) { continue; // if this is removed, no failure } else {} // if else is removed, no failure } if ($a) {}', ], 'bleedVarIntoOuterContextWithEmptyLoop' => [ ' [ '$tag' => 'string|null', ], ], 'bleedVarIntoOuterContextWithRedefinedAsNull' => [ ' [ '$tag' => 'null', ], ], 'bleedVarIntoOuterContextWithRedefinedAsNullAndBreak' => [ ' [ '$tag' => 'null', ], ], 'bleedVarIntoOuterContextWithBreakInElse' => [ ' [ '$tag' => 'string|null', ], ], 'bleedVarIntoOuterContextWithBreakInIf' => [ ' [ '$tag' => 'string|null', ], ], 'bleedVarIntoOuterContextWithBreakInElseAndIntSet' => [ ' [ '$tag' => 'string|int|null', ], ], 'bleedVarIntoOuterContextWithRedefineAndBreak' => [ ' [ '$tag' => 'null', ], ], 'nullToMixedWithNullCheckNoContinue' => [ ' [ '$a' => 'mixed', ], 'error_levels' => [ 'MixedAssignment', ], ], 'nullToMixedWithNullCheckAndContinue' => [ ' [ '$a' => 'mixed', ], 'error_levels' => [ 'MixedAssignment', ], ], 'falseToBoolExplicitBreak' => [ ' [ '$a' => 'bool', ], ], 'falseToBoolExplicitContinue' => [ ' [ '$a' => 'bool', ], ], 'falseToBoolInBreak' => [ ' [ '$a' => 'bool', ], ], 'falseToBoolInContinue' => [ ' [ '$a' => 'bool', ], ], 'falseToBoolInBreakAndContinue' => [ ' [ '$a' => 'bool', ], ], 'falseToBoolInNestedForeach' => [ ' [ '$a' => 'bool', ], ], 'falseToBoolAfterContinueAndBreak' => [ ' 0) { $a = true; continue; } break; }', 'assignments' => [ '$a' => 'bool', ], ], 'variableDefinedInForeachAndIf' => [ ' [ ' [ ' $value) { if ($value["foo"]) {} $r[] = $key; } }', 'assignments' => [], 'error_levels' => [ 'MixedAssignment', 'MixedArrayAccess', ], ], 'foreachLoopWithOKManipulation' => [ ' [ ' [ ' [ ' [ ' 'PossiblyUndefinedGlobalVariable', ], 'possiblyUndefinedArrayInForeach' => [ ' 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:3 - Possibly undefined ' . 'global variable $array, first seen on line 3', ], 'possiblyUndefinedVariableInForeach' => [ ' 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:6 - Possibly undefined ' . 'global variable $car, first seen on line 3', ], 'possibleUndefinedVariableInForeachAndIfWithBreak' => [ ' 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:9 - Possibly undefined ' . 'global variable $a, first seen on line 4', ], 'possibleUndefinedVariableInForeachAndIf' => [ ' 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:7 - Possibly undefined ' . 'global variable $a, first seen on line 4', ], 'implicitFourthLoopWithBadReturnType' => [ ' 'InvalidReturnStatement', ], 'possiblyNullCheckInsideForeachWithNoLeaveStatement' => [ ' */ public static function loadMultiple() { return [new A, null]; } /** @return void */ public function barBar() { } } foreach (A::loadMultiple() as $a) { if ($a === null) { // do nothing } $a->barBar(); }', 'error_message' => 'PossiblyNullReference', ], 'redundantConditionInForeachIf' => [ ' 'RedundantCondition', ], 'redundantConditionInForeachWithIfElse' => [ ' 'RedundantCondition', ], 'foreachLoopInvalidation' => [ ' 'LoopInvalidation', ], ]; } }