,error_levels?:string[]}> */ public function providerValidCodeParse() { return [ 'ifNotUndefinedAndEmpty' => [ ' [ '$a' => 'mixed|null', ], 'error_levels' => ['MixedAssignment'], ], 'emptyArrayVar' => [ ' [], 'error_levels' => ['MixedAssignment', 'MixedArrayAccess'], ], 'removeEmptyArray' => [ ' [ ' [ ' [ 'getMessage() === "hello") { return "hello"; } elseif (empty($a)) { return "goodbye"; } return $a->getMessage(); }', ], 'noFalsyLeak' => [ ' [ ' [], 'error_levels' => ['MixedAssignment', 'MixedArrayAccess'], ], 'dontBleedEmptyAfterExtract' => [ ' [], 'error_levels' => ['MixedAssignment', 'MixedArgument'], ], 'emptyObjectLike' => [ ' [ "foo" => "bar", ], "groups" => [ "foo" => "bar", "hide" => rand(0, 5), ], ]; foreach ($arr as $item) { if (empty($item["hide"]) || $item["hide"] === 3) {} }', ], 'alwaysBoolResult' => [ ' [ ' [ ' [], 'error_levels' => ['MixedAssignment', 'MissingParamType'], ], 'canBeNonEmptyArray' => [ ' [], 'error_levels' => ['MixedAssignment', 'MissingParamType', 'MixedArgument'], ], 'multipleEmptiesInCondition' => [ ' $o */ function foo(array $o) : void { if (empty($o[0]) && empty($o[1])) {} }', ], 'multipleEmptiesInConditionWithMixedOffset' => [ ' [ ' [ ' [], 'error_levels' => ['MixedAssignment', 'MissingParamType', 'MixedArgument', 'MixedArrayOffset', 'MixedArrayAccess'], ], 'possiblyEmptyIterable' => [ ' [ ' $data */ function bat(array $data) : void { if (!empty($data["foo"])) { if (empty($data[Foo::BAR])) {} } } /** * @param array $data */ function baz(array $data) : void { if (!empty($data[0])) { if (empty($data[Foo::ONE])) {} } }', ], 'doubleEmptyCheckTwoArrays' => [ ' [ ' [ ' [ ' [ 'b)) {} }', ], 'allowNumericEmpty' => [ ' [ ' */ public function providerInvalidCodeParse() { return [ 'preventImpossibleEmpty' => [ ' 'UndefinedVariable', ], 'reconciliationForMixed' => [ ' 'RedundantCondition', 'error_levels' => ['MixedAssignment', 'MissingParamType'], ], 'preventEmptyOnBool' => [ ' 'InvalidArgument', ], 'preventEmptyCreatingArray' => [ ' 'MixedReturnTypeCoercion' ], 'preventEmptyEquivalentCreatingArray' => [ ' 'MixedReturnTypeCoercion' ], 'secondEmptyTwice' => [ ' 'RedundantCondition' ], ]; } }