project_analyzer->getCodebase()->reportUnusedVariables(); } public function providerValidCodeParse(): array { return [ 'arrayOffset' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [ 'PossiblyUndefinedVariable', 'MixedArrayAccess', 'MixedOperand', 'MixedAssignment', 'InvalidStringClass', ], ], 'varDefinedInIfWithReference' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $arr */ function foo(array $arr) : void { $a = false; foreach ($arr as $b) { $a = true; echo $b; } echo $a; }', ], 'doWhileReassigned' => [ 'code' => ' 3);', ], 'loopTypeChangedInIfAndContinueWithReference' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getMessage(); } }', ], 'throwWithMessageCallAndAssignmentAndReference' => [ 'code' => 'getMessage(); } if ($s !== null) {} }', ], 'throwWithMessageCallAndAssignmentInCatchAndReference' => [ 'code' => 'getMessage(); $s = "hello"; } if ($s) {} }', ], 'throwWithMessageCallAndAssignmentInTryAndCatchAndReference' => [ 'code' => 'getMessage(); $s = "hello"; } if ($s) {} }', ], 'throwWithMessageCallAndNestedAssignmentInTryAndCatchAndReference' => [ 'code' => 'getMessage(); $t = "hello"; } if ($t) { $s = $t; } } if ($s) {} }', ], 'throwWithReturnInOneCatch' => [ 'code' => 'getMessage(); $s = false; } catch (Exception $e) { return; } if ($s) {} }', ], 'loopWithIfRedefinition' => [ 'code' => ' [ 'code' => 'passedByRef($b); }', ], 'usedMethodCallVariable' => [ 'code' => '$methodName()] = true; } return $ret; }', 'assertions' => [], 'ignored_issues' => [ 'MixedAssignment', 'MixedMethodCall', 'MixedArrayOffset', ], ], 'globalVariableUsage' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 0) { return "value"; } throw new Exception("fail"); } function main() : void { try { $s = example_string(); if (!$s) { echo "Failed to get string\n"; } } catch (Exception $e) { $s = "fallback"; } printf("s is %s\n", $s); }', ], 'loopTypeChangedInIfAndBreakWithReference' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $arr */ function far(array $arr): void { foreach ($arr as [$a, $b]) { echo $a; echo $b; } }', ], 'arraySubAppend' => [ 'code' => ' []]; foreach ($rules as $rule) { $report["runs"][] = $rule; } echo(count($report));', ], 'arrayAssignmentInFunctionCoerced' => [ 'code' => 'a = (int) $a; $this->b = (int) $b; } } ', ], 'varCheckAfterNestedAssignmentAndBreak' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $options */ public function __construct(array $options) { $this->setOptions($options); } /** * @param array $options */ protected function setOptions(array $options): void { foreach ($options as $key => $value) { $normalized = ucfirst($key); $method = "set" . $normalized; if (method_exists($this, $method)) { $this->$method($value); } } } } new A(["bar" => "bat"]);', ], 'instanceofVarUse' => [ 'code' => ' [ 'code' => ' 0); echo $i;', ], 'callableReferencesItself' => [ 'code' => ' [ 'code' => ' $type */ function bar(string $type) : ArrayObject { $data = [["foo"], ["bar"]]; /** @psalm-suppress UnsafeInstantiation */ return new $type($data[0]); }', ], 'byRefVariableUsedInAddition' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'bar([$b]); }', ], 'paramUsedInsideLoop' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.3', ], 'usedAsEnumFetch' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.3', ], 'usedAsStaticPropertyAssign' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $a */ function getLastNum(array $a): int { foreach ($a as $num) { $last = $num; } return $last; }', ], 'usedStrtolowerInArray' => [ 'code' => ' $row */ function foo(array $row, string $s) : array { $row["a" . strtolower($s)] += 1; return $row; }', ], 'pureWithReflectionMethodSetValue' => [ 'code' => 'setValue([get_class($mock) => "hello"]); }', ], 'defineBeforeAssignmentInConditional' => [ 'code' => ' [ 'code' => ' [ 'code' => 'bar($i); }', ], 'noUnusedVariableAfterRedeclaredInCatch' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $test */ function foo(array $test) : void { foreach($test as $key => $_testValue) { echo $key; } }', ], 'usedAfterMixedVariableAssignment' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo(new Exception($mixed_or_null)); }', ], 'validMixedAnnotation' => [ 'code' => ' [ 'code' => ' [ 'code' => 'value; $update = $value; } }', 'assertions' => [], 'ignored_issues' => ['UnsupportedPropertyReferenceUsage'], ], 'createdAndUsedInCondition' => [ 'code' => 'foo()) {} return; } if (!($a = getA()) || $a->foo()) {}', ], 'usedInUndefinedFunction' => [ 'code' => ' [ 'code' => ' "b", "c" => "d"]; foreach ($variables as $name => $value) { ${$name} = $value; }', ], 'usedLoopVariable' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 0; $i--) { echo $i . "\n"; } }', ], 'usedForVariablePlusString' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [1], "b" => [2] ]; foreach (["a"] as $e){ takes_ref($a[$e]); } /** @param array $p */ function takes_ref(array &$p): void { echo implode(",", $p); }', ], 'doWhileWithBreak' => [ 'code' => ' [ 'code' => ' [ 'code' => '= $index = nextNumber($index)) { // ... } } function nextNumber(int $eee): int { return $eee + 1; }', ], 'usedParamInWhileIndirectly' => [ 'code' => '= $index = nextNumber($index)) { // ... } } function nextNumber(int $i): int { return $i + 1; }', ], 'doArrayIncrement' => [ 'code' => ' $keys * @param int $key */ function error2(array $keys, int $key): int { if ($key === 1) {} do { $nextKey = $keys[++$key] ?? null; } while ($nextKey === null); return $nextKey; }', ], 'variableUsedIndirectly' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' */ public $b = []; } function foo(Clause $c, int $var): void { $new_b = $c->b; if (isset($c->b[0])) { $new_b[$var] = 0; } if ($new_b) {} }', ], 'arrayAssignOpAdditionInsideLoop' => [ 'code' => ' $arr0 * @param array $arr1 * @param array $arr2 * @return void */ function parp(array $arr0, array $arr1, array $arr2) { $arr3 = $arr0; foreach ($arr1 as $a) { echo $a; $arr3 += $arr2; } if ($arr3) {} }', ], 'arrayAdditionInsideLoop' => [ 'code' => ' $arr0 * @param array $arr1 * @param array $arr2 * @return void */ function parp(array $arr0, array $arr1, array $arr2) { $arr3 = $arr0; foreach ($arr1 as $a) { echo $a; $arr3 = $arr3 + $arr2; } if ($arr3) {} }', ], 'checkValueBeforeAdding' => [ 'code' => 'b) {} }', ], 'loopOverUnknown' => [ 'code' => ' [ 'code' => ' */ $diff_call_map = require($delta_file); foreach ($diff_call_map as $key => $_) { $cased_key = strtolower($key); echo $cased_key; } } }', ], 'loopAgain' => [ 'code' => ' $lines */ function parse(array $lines) : array { $last = 0; foreach ($lines as $k => $line) { if (rand(0, 1)) { $last = $k; } elseif (rand(0, 1)) { $last = 0; } elseif ($last !== 0) { $lines[$last] .= $line; } } return $lines; }', ], 'necessaryVarAnnotation' => [ 'code' => ' $_) { echo $key; } }', ], 'continuingEducation' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo($hue); }', ], 'usedAsArrayKey' => [ 'code' => ' $lightness]; return $arr; }', ], 'assignToGlobalVar' => [ 'code' => ' $value) { $_GET[$key] = $value; } }', ], 'assignToArrayTwice' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => '> $arr * @param-out non-empty-list> $arr */ function foo(array &$arr): void { $b = 5; $arr[0][0] = $b; }', ], 'nestedReferencesToByRefParam' => [ 'code' => '> $arr * @param-out non-empty-list> $arr */ function foo(array &$arr): void { $a = &$arr[0]; $b = &$a[0]; $b = 5; }', ], 'byRefNestedArrayInForeach' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $keys */ function foo(iterable $keys, int $colno) : void { $i = 0; $key = 0; $index = 0; foreach ($keys as $index => $key) { if ($key === $colno) { $i = $index; break; } elseif ($key > $colno) { $i = $index; break; } } echo $i; echo $index; echo $key; }', ], 'whileLoopVarUpdatedInWhileLoop' => [ 'code' => ' $arr */ function foo(array $arr) : void { while ($a = array_pop($arr)) { if ($a === 4) { $arr = array_merge($arr, ["a", "b", "c"]); continue; } echo "here"; } }', ], 'usedThroughParamByRef' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $e->getMessage(); }', ], 'useImmutableGetIteratorInForeach' => [ 'code' => ' */ public function getIterator() { yield from [1, 2, 3]; } } $a = new A(); foreach ($a as $v) { echo $v; }', ], 'castToBoolAndDouble' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => '= 5 ? true : false; $b = (int) $a; return $b; } ', ], 'promotedPropertiesAreNeverMarkedAsUnusedParams' => [ 'code' => ' [ 'code' => 'validate()) && ($result = $this->save())) { return 0; } elseif (is_string($result)) { return 1; } else { return 2; } } }', 'assertions' => [], 'ignored_issues' => ['RiskyTruthyFalsyComparison'], 'php_version' => '8.0', ], 'concatWithUnknownProperty' => [ 'code' => ' $key */ function foo(object $a, string $k) : string { $sortA = ""; /** @psalm-suppress MixedOperand */ $sortA .= $a->$k; return $sortA; }', ], 'varDocblockVariableIsUsedByRef' => [ 'code' => ' $arr */ function foo(array $arr) : string { /** @var string $val */ foreach ($arr as &$val) { $val = urlencode($val); } return implode("/", $arr); }', ], 'initVariableInOffset' => [ 'code' => ' $b, ]; foreach ($a as $key => $value) { echo $key . " " . $value; }', ], 'intAndBitwiseNotOperator' => [ 'code' => ' [ 'code' => '> 1); $randomBytes = random_bytes(1); $randomBytes[0] = $randomBytes[0] & $bitmask; return $randomBytes; }', ], 'globalChangeValue' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' */ $arr = [1]; $arr[1] = &$arr[0]; takesArray($arr); function takesArray(array $_arr): void {} ', ], 'arrayWithVariableOffsetAssignedToReferenceUsesVariableOffset' => [ 'code' => ' */ $arr = [1]; $int = 1; $arr[$int] = &$arr[0]; takesArray($arr); function takesArray(array $_arr): void {} ', ], 'usedPlusInAddition' => [ 'code' => ' 10) { break; } else {} } }', ], 'usedPlusInUnaryAddition' => [ 'code' => ' 10) { break; } else {} } }', ], 'referenceInPropertyIsNotUnused' => [ 'code' => 'bar = &$ref; } } ', ], 'requiredClosureArgumentMustNotGetReported' => [ 'code' => ' [ 'code' => ' 'UnusedVariable', ], 'unusedVarWithAdditionOp' => [ 'code' => ' 'UnusedVariable', ], 'unusedVarWithConditionalAdditionOp' => [ 'code' => ' 'UnusedVariable', ], 'unusedVarWithConditionalAddition' => [ 'code' => ' 'UnusedVariable', ], 'unusedVarWithIncrement' => [ 'code' => ' 'UnusedVariable', ], 'unusedVarWithConditionalIncrement' => [ 'code' => ' 'UnusedVariable', ], 'ifInBothBranchesWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'varInNestedAssignmentWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'varInSecondNestedAssignmentWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'varReassignedInBothBranchesOfIf' => [ 'code' => ' 'UnusedVariable', ], 'varReassignedInNestedBranchesOfIf' => [ 'code' => ' 'UnusedVariable', ], 'ifVarReassignedInBranchWithNoUse' => [ 'code' => ' 'UnusedVariable', ], 'elseVarReassignedInBranchAndNoReference' => [ 'code' => ' 'UnusedVariable', ], 'switchVarReassignedInBranch' => [ 'code' => ' 'UnusedVariable', ], 'switchVarReassignedInBranchWithDefault' => [ 'code' => ' 'UnusedVariable', ], 'switchVarReassignedInAllBranches' => [ 'code' => ' 'UnusedVariable', ], 'unusedListVar' => [ 'code' => ' 'UnusedVariable', ], 'unusedPreForVar' => [ 'code' => ' 'UnusedVariable', ], 'unusedIfInReturnBlock' => [ 'code' => ' 'UnusedVariable', ], 'unusedIfVarInBranch' => [ 'code' => ' 'UnusedVariable', ], 'throwWithMessageCallAndAssignmentAndNoReference' => [ 'code' => 'getMessage(); } }', 'error_message' => 'UnusedVariable', ], 'throwWithMessageCallAndAssignmentInCatchAndNoReference' => [ 'code' => 'getMessage(); $s = "hello"; } }', 'error_message' => 'UnusedVariable', ], 'throwWithMessageCallAndNestedAssignmentInTryAndCatchAndNoReference' => [ 'code' => 'getMessage(); $t = "hello"; } if ($t) { $s = $t; } } }', 'error_message' => 'UnusedVariable', ], 'throwWithReturnInOneCatchAndNoReference' => [ 'code' => 'getMessage(); $s = false; } catch (Exception $e) { return; } }', 'error_message' => 'UnusedVariable', ], 'loopTypeChangedInIfWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'loopTypeChangedInIfAndContinueWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'loopReassignedInIfAndContinueWithoutReferenceAfter' => [ 'code' => ' 'UnusedVariable', ], 'loopReassignedInIfAndContinueWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'unusedConditionalCode' => [ 'code' => ' 'UnusedVariable', ], 'varDefinedInIfWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'SKIPPED-byrefInForeachLoopWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'loopSetIfNullWithBreakWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'loopSetIfNullWithBreakWithoutReference2' => [ 'code' => ' 'UnusedVariable', ], 'loopSetIfNullWithContinueWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'loopAssignmentAfterReferenceWithBreak' => [ 'code' => ' 'UnusedVariable', ], 'loopAssignmentAfterReferenceWithBreakInIf' => [ 'code' => ' 'UnusedVariable', ], 'switchVarConditionalAssignmentWithoutReference' => [ 'code' => ' 'UnusedVariable', ], 'switchInIf' => [ 'code' => ' 'UnusedVariable', ], 'reusedKeyVar' => [ 'code' => ' "foo.foo"]; foreach ($arr as $key => $v) { list($key) = explode(".", $v); echo $key; }', 'error_message' => 'UnusedVariable', ], 'detectUnusedVarBeforeTryInsideForeach' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableInsideIfLoop' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableInsideIfElseLoop' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableInsideIfElseifLoop' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableInsideIfLoopWithEchoInside' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableInsideLoopAfterAssignment' => [ 'code' => ' 'UnusedForeachValue', ], 'detectUnusedVariableInsideLoopAfterAssignmentWithAddition' => [ 'code' => ' 'UnusedForeachValue', ], 'detectUnusedVariableInsideLoopCalledInFunction' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableReassignedInIfFollowedByTryInsideForLoop' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedVariableReassignedInIfFollowedByTryInsideForeachLoop' => [ 'code' => ' 'UnusedVariable', ], 'detectUselessArrayAssignment' => [ 'code' => ' 'UnusedVariable', ], 'detectUnusedSecondAssignmentBeforeTry' => [ 'code' => ' 'UnusedVariable', ], 'detectRedundancyAfterLoopWithContinue' => [ 'code' => ' 'UnusedVariable', ], 'setInLoopThatsAlwaysEnteredButNotReferenced' => [ 'code' => ' $a */ function getLastNum(array $a): int { foreach ($a as $num) { $last = $num; } return 4; }', 'error_message' => 'UnusedForeachValue', ], 'conditionalForeachWithUnusedValue' => [ 'code' => ' 0) { foreach ([1, 2, 3] as $val) {} } ', 'error_message' => 'UnusedForeachValue', ], 'doubleForeachWithInnerUnusedValue' => [ 'code' => '> $arr * @return list */ function f(array $arr): array { foreach ($arr as $elt) { foreach ($elt as $subelt) {} } return $elt; } ', 'error_message' => 'UnusedForeachValue', ], 'defineInBothBranchesOfConditional' => [ 'code' => ' 'UnusedVariable', ], 'knownVarType' => [ 'code' => ' 'UnnecessaryVarAnnotation', ], 'knownVarTypeWithName' => [ 'code' => ' 'UnnecessaryVarAnnotation', ], 'knownForeachVarType' => [ 'code' => ' 'UnnecessaryVarAnnotation', ], 'arrowFunctionUnusedVariable' => [ 'code' => ' ++$p );', 'error_message' => 'UnusedVariable', ], 'arrowFunctionUnusedParam' => [ 'code' => ' 0 );', 'error_message' => 'UnusedClosureParam', ], 'unusedFunctionParamWithDefault' => [ 'code' => ' 'UnusedParam', ], 'arrayMapClosureWithParamTypeNoUse' => [ 'code' => ' 'UnusedClosureParam', ], 'noUseOfInstantArrayAssignment' => [ 'code' => ' 'UnusedVariable', ], 'expectsNonNullAndPassedPossiblyNull' => [ 'code' => ' 'PossiblyNullArgument', ], 'useArrayAssignmentNeverUsed' => [ 'code' => ' 'UnusedVariable', ], 'warnAboutOriginalBadArray' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:47', ], 'warnAboutOriginalBadFunctionCall' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutOriginalBadStaticCall' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:62', ], 'warnAboutOriginalBadInstanceCall' => [ 'code' => 'makeArray(); foreach ($arr as $a) { echo $a; }', 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:55', ], 'warnAboutDocblockReturnType' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:47 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:33', ], 'warnAboutMixedArgument' => [ 'code' => ' 'MixedArgument - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:30 - Argument 1 of echo cannot be mixed, expecting string. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutMixedMethodCall' => [ 'code' => 'foo(); }', 'error_message' => 'MixedMethodCall - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:29 - Cannot determine the type of $a when calling method foo. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutMixedReturnStatement' => [ 'code' => ' 'MixedReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:36 - Could not infer a return type. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutIterableKeySource' => [ 'code' => ' $_) {} }', 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:43', ], 'warnAboutMixedKeySource' => [ 'code' => ' $_) {} }', 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:4:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:34', ], 'warnAboutMixedArgumentTypeCoercionSource' => [ 'code' => ' $arr */ function takesArrayOfString(array $arr) : void { foreach ($arr as $a) { echo $a; } } /** @param mixed $a */ function takesArray($a) : void { $arr = [$a]; takesArrayOfString($arr); }', 'error_message' => 'MixedArgumentTypeCoercion - src' . DIRECTORY_SEPARATOR . 'somefile.php:12:44 - Argument 1 of takesArrayOfString expects array, but parent type list{mixed} provided. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:10:41', ], 'warnAboutUnusedVariableInTryReassignedInCatch' => [ 'code' => ' 'UnusedVariable', ], 'warnAboutUnusedVariableInTryReassignedInFinally' => [ 'code' => ' 'UnusedVariable', ], 'SKIPPED-warnAboutVariableUsedInNestedTryNotUsedInOuterTry' => [ 'code' => ' 'UnusedVariable', ], 'referenceReassignmentUnusedVariable' => [ 'code' => ' 'UnusedVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:21 - $c', ], 'referenceAssignmentIsNotUsed' => [ 'code' => ' 'UnusedVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:2:21 - $a', ], 'unusedReferenceToPreviouslyUsedVariable' => [ 'code' => ' 'UnusedVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:4:21 - $b', ], 'SKIPPED-unusedReferenceToSubsequentlyUsedVariable' => [ // Not easy to do the way it's currently set up 'code' => ' 'UnusedVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:21 - $b', ], 'unusedReferenceInForeach' => [ 'code' => ' 'UnusedForeachValue', ], 'SKIPPED-unusedReferenceInDestructuredForeach' => [ 'code' => ' 'UnusedForeachValue', ], 'unusedReturnByReference' => [ 'code' => ' 'UnusedVariable', ], 'unusedPassByReference' => [ 'code' => ' 'UnusedParam', ], 'SKIPPED-unusedGlobalVariable' => [ 'code' => ' 'UnusedVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:2:21 - $a', ], 'unusedUndeclaredGlobalVariable' => [ 'code' => ' 'UnusedVariable', ], 'reportWillReportFloatAsItIsAfterRequiredParameterAndUnused' => [ 'code' => ' 'Param float is never referenced in this method', ], ]; } }