,error_levels?:string[]}> */ public function providerValidCodeParse() { return [ 'constantInFunction' => [ ' [ ' [ ' [ ' [ '$a' => 'int', '$b' => 'string', ], ], 'getClassConstantValue' => [ ' [ ' [], 'error_levels' => ['MixedArgument'], ], 'undefinedConstant' => [ ' [], 'error_levels' => ['UndefinedConstant'], ], 'suppressUndefinedClassConstant' => [ ' [], 'error_levels' => ['MixedAssignment'], ], 'hardToDefineClassConstant' => [ ' 4, "name" => 3 ]; const B = 4; } echo A::C[4];', ], 'sameNamedConstInOtherClass' => [ ' "one", ]; } echo A::C[4];', ], 'onlyMatchingConstantOffset' => [ ' 1, "two" => 2 ]; } foreach (A::KEYS as $key) { if (isset(A::ARR[$key])) { echo A::ARR[$key]; } }', ], 'noExceptionsOnMixedArrayKey' => [ ' A::class, "type2" => B::class, ]; public function bar(array $data): void { if (!isset(self::TYPES[$data["type"]])) { throw new \InvalidArgumentException("Unknown type"); } $class = self::TYPES[$data["type"]]; $ret = finder($data["id"]); if (!$ret || !$ret instanceof $class) { throw new \InvalidArgumentException; } } }', 'assertions' => [], 'error_levels' => ['MixedArgument', 'MixedArrayOffset', 'MixedAssignment'], ], 'lateConstantResolution' => [ ' [ '$a' => 'string', '$b' => 'string', ], ], 'allowConstCheckForDifferentPlatforms' => [ ' [ ' [ ' 1, B::class => 2, ]; /** * @param class-string $s */ function foo(string $s) : void { if (isset(C[$s])) {} }', ], 'resolveClassConstToCurrentClass' => [ ' [ ' [], 'error_levels' => ['MixedArgument'], ], 'arrayAccessAfterIsset' => [ ' ["c" => false], "c" => ["c" => true], "d" => ["c" => true] ]; } /** @var string */ $s = "b"; if (isset(C::A[$s]["c"]) && C::A[$s]["c"] === false) {}', ], 'namespacedConstantInsideClosure' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' */ public function providerInvalidCodeParse() { return [ 'constantDefinedInFunctionButNotCalled' => [ ' 'UndefinedConstant', ], 'undefinedClassConstantInParamDefault' => [ ' 'UndefinedConstant', ], 'nonMatchingConstantOffset' => [ ' 1, "two" => 2 ]; const ARR2 = [ "three" => 3, "four" => 4 ]; } foreach (A::KEYS as $key) { if (isset(A::ARR[$key])) { echo A::ARR2[$key]; } }', 'error_message' => 'InvalidArrayOffset', ], 'objectLikeConstArrays' => [ ' "zero", self::B => "two", ]; } if (C::ARR[C::A] === "two") {}', 'error_message' => 'TypeDoesNotContainType', ], 'missingClassConstInArray' => [ ' 'UndefinedConstant', ], 'resolveConstToCurrentClassWithBadReturn' => [ ' 'InvalidReturnStatement', ], 'outOfScopeDefinedConstant' => [ ' 'UndefinedConstant', ], 'preventStaticClassConstWithoutRef' => [ ' 'UndefinedConstant', ], ]; } }