expectException(CodeException::class); // $this->expectExceptionMessage("PossiblyUndefinedIntArrayOffset"); // $this->testConfig->ensure_array_int_offsets_exist = true; // $file_path = getcwd() . '/src/somefile.php'; // $this->addFile( // $file_path, // ' */ // public const CONST = [1, 2, 3]; // /** // * @param key-of $key // */ // public function bar(int $key): int // { // return static::CONST[$key]; // } // } // ' // ); // $this->analyzeFile($file_path, new Context()); // } public function testUseObjectConstant(): void { $file1 = getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'file1.php'; $file2 = getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'file2.php'; $this->addFile( $file1, 'addFile( $file2, 'analyzeFile($file1, new Context()); $this->analyzeFile($file2, new Context()); } public function providerValidCodeParse(): iterable { return [ 'constantInFunction' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$a' => 'int<1, max>', '$b' => 'string', ], ], 'getClassConstantValue' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => ['MixedArgument'], ], 'undefinedConstant' => [ 'code' => ' [], 'ignored_issues' => ['UndefinedConstant'], ], 'suppressUndefinedClassConstant' => [ 'code' => ' [], 'ignored_issues' => ['MixedAssignment'], ], 'hardToDefineClassConstant' => [ 'code' => ' 4, "name" => 3 ]; const B = 4; } echo A::C[4];', ], 'sameNamedConstInOtherClass' => [ 'code' => ' "one", ]; } echo A::C[4];', ], 'onlyMatchingConstantOffset' => [ 'code' => ' 1, "two" => 2 ]; } foreach (A::KEYS as $key) { if (isset(A::ARR[$key])) { echo A::ARR[$key]; } }', ], 'stringArrayOffset' => [ 'code' => ' 1, "b" => 2, ]; } function foo(string $s) : void { if (!isset(A::C[$s])) { return; } if ($s === "Hello") {} }', ], 'noExceptionsOnMixedArrayKey' => [ 'code' => ' 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' => [], 'ignored_issues' => ['MixedArgument', 'MixedArrayOffset', 'MixedAssignment'], ], 'lateConstantResolution' => [ 'code' => ' [ '$a' => 'string', '$b' => 'string', ], ], 'lateConstantResolutionParentArrayPlus' => [ 'code' => ' true]; } class B extends A { /** @var array{a: true, b: true, ...} */ public const ARR = parent::ARR + ["b" => true]; } class C extends B { public const ARR = parent::ARR + ["c" => true]; } /** @param array{a: true, b: true, c: true} $arg */ function foo(array $arg): void {} foo(C::ARR); ', ], 'lateConstantResolutionParentArraySpread' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $arg */ function foo(array $arg): void {} foo(C::ARR); ', ], 'classConstConcatEol' => [ 'code' => ' ['$foo' => 'string'], ], 'dynamicClassConstFetch' => [ 'code' => ' ['$_trace===' => "'bar'"], ], 'unsafeInferenceClassConstFetch' => [ 'code' => ' ['$_trace' => 'mixed'], ], 'FinalInferenceClassConstFetch' => [ 'code' => ' ['$_trace===' => "'bar'"], ], 'dynamicClassConstFetchClassString' => [ 'code' => ' ['$d===' => '1'], ], 'allowConstCheckForDifferentPlatforms' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 1, B::class => 2, ]; /** * @param class-string $s */ function foo(string $s) : void { if (isset(C[$s])) {} }', ], 'resolveClassConstToCurrentClass' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'resolveCalculatedConstant' => [ 'code' => ' [], 'ignored_issues' => ['MixedArgument'], ], 'arrayAccessAfterIsset' => [ 'code' => ' ["c" => false], "c" => ["c" => true], "d" => ["c" => true] ]; } /** @var string */ $s = "b"; if (isset(C::A[$s]["c"]) && C::A[$s]["c"] === false) {}', ], 'namespacedConstantInsideClosure' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' */ function getMap(): array { return Mapper::MAP; } class Mapper { public const MAP = [ Foo::class => self::A, Foo::BAR => self::A, ]; private const A = 5; } class Foo { public const BAR = "bar"; }', ], 'resolveConstArrayAsList' => [ 'code' => ' $value */ function test($value): void { print_r($value); } test(Test1::VALUES); test(Test2::VALUES);', ], 'resolveConstantFetchViaFunction' => [ 'code' => ' [ 'code' => ' null, "A01" => null, "A02" => null, "A03" => null, "A04" => null, "A05" => null, "A06" => null, "A07" => null, "A010" => null, "A011" => null, "A012" => null, "A013" => null, "A014" => null, "A015" => null, "A016" => null, "A017" => null, "A020" => null, "A021" => null, "A022" => null, "A023" => null, "A024" => null, "A025" => null, "A026" => null, "A027" => null, "A030" => null, "A031" => null, "A032" => null, "A033" => null, "A034" => null, "A035" => null, "A036" => null, "A037" => null, "A040" => null, "A041" => null, "A042" => null, "A043" => null, "A044" => null, "A045" => null, "A046" => null, "A047" => null, "A050" => null, "A051" => null, "A052" => null, "A053" => null, "A054" => null, "A055" => null, "A056" => null, "A057" => null, "A060" => null, "A061" => null, "A062" => null, "A063" => null, "A064" => self::SUCCEED, "A065" => self::FAIL, ]; const SUCCEED = "SUCCEED"; const FAIL = "FAIL"; /** * @param string $code */ public static function will_succeed($code) : bool { // False positive TypeDoesNotContainType - string(SUCCEED) cannot be identical to null // This seems to happen because the array has a lot of entries. return (self::LOOKUP[strtoupper($code)] ?? null) === self::SUCCEED; } }', ], 'keyOf' => [ 'code' => ' "a", 2 => "b", 3 => "c" ]; /** * @param key-of $i */ public static function foo(int $i) : void {} } A::foo(1); A::foo(2); A::foo(3);', ], 'valueOf' => [ 'code' => ' "a", 2 => "b", 3 => "c" ]; /** * @param value-of $j */ public static function bar(string $j) : void {} } A::bar("a"); A::bar("b"); A::bar("c");', ], 'valueOfDefault' => [ 'code' => ' "a", 2 => "b", 3 => "c" ]; /** * @var value-of */ public $foo = "a"; }', ], 'wildcardEnum' => [ 'code' => ' [ 'code' => ' [ 'code' => ' */ class A implements AInterface { const C_1 = 1; const C_2 = 2; const C_3 = 3; const D_4 = 4; public function foo($i) { return $i; } } $a = new A(); $a->foo(1); $a->foo(2); $a->foo(3); $a->foo(A::D_4);', ], 'wildcardVarAndReturn' => [ 'code' => 'number = $number; } /** * @return Numbers::* */ public function get(): int { return $this->number; } }', ], 'lowercaseStringAccessClassConstant' => [ 'code' => ' 1, "b" => 2, "c" => 3 ]; } /** * @param lowercase-string $s */ function foo(string $s, string $t) : void { echo A::C[$t]; echo A::C[$s]; }', ], 'getClassConstantOffset' => [ 'code' => ' "string" ]; private const B = self::A[0]; public function foo(): string { return self::B; } }', ], 'bitwiseOrClassConstant' => [ 'code' => ' [ '$c' => 'int', ], ], 'bitwiseAndClassConstant' => [ 'code' => ' [ '$c' => 'int', ], ], 'bitwiseXorClassConstant' => [ 'code' => ' [ '$c' => 'int', ], ], 'bitwiseNotClassConstant' => [ 'code' => ' [ '$a' => 'int', '$b' => 'string', ], ], 'booleanNotClassConstant' => [ 'code' => ' [ '$a' => 'false', '$b' => 'true', ], ], 'protectedClassConstantAccessibilitySameNameInChild' => [ 'code' => ' */ protected const A = 1; public static function test(): void { echo B::A; } } class B extends A { protected const A = 2; } A::test();', ], 'referenceClassConstantWithSelf' => [ 'code' => ' */ public const KEYS = []; /** @var array */ public const VALUES = []; } class B extends A { public const VALUES = [\'there\' => self::KEYS[\'hi\']]; public const KEYS = [\'hi\' => CONSTANTS::THERE]; } class CONSTANTS { public const THERE = \'there\'; } echo B::VALUES["there"];', ], 'internalConstWildcard' => [ 'code' => ' [ 'code' => 'level = $level; } /** * @psalm-return self */ public static function readUncommitted(): self { return new self(self::READ_UNCOMMITTED); } /** * @psalm-return self */ public static function readCommitted(): self { return new self(self::READ_COMMITTED); } /** * @psalm-return self */ public static function repeatableRead(): self { return new self(self::REPEATABLE_READ); } /** * @psalm-return self */ public static function serializable(): self { return new self(self::SERIALIZABLE); } /** * @psalm-return T */ public function toString(): string { return $this->level; } }', ], 'dirAndFileInConstInitializersAreNonEmptyString' => [ 'code' => ' [ '$dir===' => 'non-empty-string', '$file===' => 'non-empty-string', ], ], 'lineInConstInitializersIsInt' => [ 'code' => ' [ '$line' => 'int<1, max>', ], ], 'classMethodTraitAndFunctionInConstInitializersAreStrings' => [ 'code' => ' [ '$cls' => 'string', '$mtd' => 'string', '$trt' => 'string', '$fcn' => 'string', ], ], 'concatWithMagicInConstInitializersIsNoEmptyString' => [ 'code' => ' [ '$dir===' => 'non-empty-string', '$file===' => 'non-empty-string', ], ], 'noCrashWithStaticInDocblock' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$arr===' => 'list{1, 2}', ], ], 'keysInUnpackedArrayAreReset' => [ 'code' => ' 2]]; } $arr = C::A; ', 'assertions' => [ '$arr===' => 'list{2}', ], ], 'arrayKeysSequenceContinuesAfterExplicitIntKey' => [ 'code' => ' "a", "z", 10 => "aa", "zz"]; } $arr = C::A; ', 'assertions' => [ '$arr===' => "array{10: 'aa', 11: 'zz', 5: 'a', 6: 'z'}", ], ], 'arrayKeysSequenceContinuesAfterNonIntKey' => [ 'code' => ' "a", "zz" => "z", "aa"]; } $arr = C::A; ', 'assertions' => [ '$arr===' => "array{5: 'a', 6: 'aa', zz: 'z'}", ], ], 'unresolvedConstWithUnaryMinus' => [ 'code' => ' -1, K => 6, ]; /** * @param int $k */ public static function f(int $k): void { $a = self::M; print_r($a); } }', ], 'classConstantReferencingEnumCase' => [ 'code' => ' [ '$c===' => 'enum(E::Z)', ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'classConstantArrayWithEnumCaseKey' => [ 'code' => 'value => "e", BEI::K4->value => 5, E::K1->name => "c", E::K2->name => 3, BEI::K3->name => "d", BEI::K4->name => 4, BES::K5->name => "f", BES::K6->name => 6, BES::K5->value => "g", BES::K6->value => 7, ]; } $c = A::C; ', 'assertions' => [ '$c===' => "array{1: 'e', 2: 5, K1: 'c', K2: 3, K3: 'd', K4: 4, K5: 'f', K6: 6, a: 'g', b: 7}", ], 'ignored_issues' => [], 'php_version' => '8.2', ], 'classConstantArrayWithEnumCaseKeyEnumDefinedAfterClass' => [ 'code' => 'value => "e", BEI::K4->value => 5, E::K1->name => "c", E::K2->name => 3, BEI::K3->name => "d", BEI::K4->name => 4, BES::K5->name => "f", BES::K6->name => 6, BES::K5->value => "g", BES::K6->value => 7, ]; } enum E { case K1; case K2; } enum BEI: int { case K3 = 1; case K4 = 2; } enum BES: string { case K5 = "a"; case K6 = "b"; } $c = A::C; ', 'assertions' => [ '$c===' => "array{1: 'e', 2: 5, K1: 'c', K2: 3, K3: 'd', K4: 4, K5: 'f', K6: 6, a: 'g', b: 7}", ], 'ignored_issues' => [], 'php_version' => '8.2', ], 'classConstantArrayWithEnumCaseKeyNamespaced' => [ 'code' => 'name => "a", \OtherNamespace\E::K2->name => 10, \OtherNamespace\E::K1->value => "b", \OtherNamespace\E::K2->value => 11, E::K3->name => "c", E::K4->name => 12, E::K3->value => "d", E::K4->value => 13, E2::K5->name => "e", E2::K6->name => 14, E2::K5->value => "f", E2::K6->value => 15, E3::K7->name => "g", E3::K8->name => 16, E3::K7->value => "h", E3::K8->value => 17, ]; } $c = A::C; ', 'assertions' => [ '$c===' => "array{1: 'b', 2: 11, 3: 'd', 4: 13, 5: 'f', 6: 15, 7: 'h', 8: 17, K1: 'a', K2: 10, K3: 'c', K4: 12, K5: 'e', K6: 14, K7: 'g', K8: 16}", ], 'ignored_issues' => [], 'php_version' => '8.2', ], 'classConstantArrayWithEnumCaseKeyDirectAccess' => [ 'code' => 'name => "c", E::K2->name => 3, BEI::K3->name => "d", BEI::K4->name => 4, BEI::K3->value => "e", BEI::K4->value => 5, BES::K5->name => "f", BES::K6->name => 6, BES::K5->value => "g", BES::K6->value => 7, ]; } $a = A::C[E::K1->name]; $b = A::C[E::K2->name]; $c = A::C[BEI::K3->name]; $d = A::C[BEI::K4->name]; $e = A::C[BEI::K3->value]; $f = A::C[BEI::K4->value]; $g = A::C[BES::K5->name]; $h = A::C[BES::K6->name]; $i = A::C[BES::K5->value]; $j = A::C[BES::K6->value]; $k = A::C["K1"]; $l = A::C["K2"]; $m = A::C["K3"]; $n = A::C["K4"]; $o = A::C[1]; $p = A::C[2]; $q = A::C["K5"]; $r = A::C["K6"]; $s = A::C["a"]; $t = A::C["b"]; ', 'assertions' => [ '$a===' => "'c'", '$b===' => '3', '$c===' => "'d'", '$d===' => '4', '$e===' => "'e'", '$f===' => '5', '$g===' => "'f'", '$h===' => '6', '$i===' => "'g'", '$j===' => '7', '$k===' => "'c'", '$l===' => '3', '$m===' => "'d'", '$n===' => '4', '$o===' => "'e'", '$p===' => '5', '$q===' => "'f'", '$r===' => '6', '$s===' => "'g'", '$t===' => '7', ], 'ignored_issues' => [], 'php_version' => '8.2', ], 'classConstantNestedArrayWithEnumCaseKey' => [ 'code' => 'name => [ E::K2->name => [ E::K3->name => "h", E::K4->name => "i", ], E::K5->name => [ E::K6->name => "j", E::K7->name => "k", ], ], E::K1->value => [ E::K2->value => [ E::K3->value => "l", E::K4->value => "m", ], E::K5->value => [ E::K6->value => "n", E::K7->value => "o", ], ] ]; } $c = A::C; ', 'assertions' => [ '$c===' => "array{K1: array{K2: array{K3: 'h', K4: 'i'}, K5: array{K6: 'j', K7: 'k'}}, a: array{b: array{c: 'l', d: 'm'}, e: array{f: 'n', g: 'o'}}}", ], 'ignored_issues' => [], 'php_version' => '8.2', ], 'constantArrayWithEnumCaseKey' => [ 'code' => 'name => "c", E::K2->name => 3, BEI::K3->name => "d", BEI::K4->name => 4, BEI::K3->value => "e", BEI::K4->value => 5, BES::K5->name => "f", BES::K6->name => 6, BES::K5->value => "g", BES::K6->value => 7, ]; $a = C[E::K1->name]; $b = C[E::K2->name]; $c = C[BEI::K3->name]; $d = C[BEI::K4->name]; $e = C[BEI::K3->value]; $f = C[BEI::K4->value]; $g = C[BES::K5->name]; $h = C[BES::K6->name]; $i = C[BES::K5->value]; $j = C[BES::K6->value]; $k = C["K1"]; $l = C["K2"]; $m = C["K3"]; $n = C["K4"]; $o = C[1]; $p = C[2]; $q = C["K5"]; $r = C["K6"]; $s = C["a"]; $t = C["b"]; ', 'assertions' => [ '$a===' => "'c'", '$b===' => '3', '$c===' => "'d'", '$d===' => '4', '$e===' => "'e'", '$f===' => '5', '$g===' => "'f'", '$h===' => '6', '$i===' => "'g'", '$j===' => '7', '$k===' => "'c'", '$l===' => '3', '$m===' => "'d'", '$n===' => '4', '$o===' => "'e'", '$p===' => '5', '$q===' => "'f'", '$r===' => '6', '$s===' => "'g'", '$t===' => '7', ], 'ignored_issues' => [], 'php_version' => '8.2', ], 'constantEnumSelfReference' => [ 'code' => 'value . self::B->value; } class Foo { public const CONCAT_STR = "a" . Bar::STR . "e"; } ', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.2', ], 'classConstWithParamOut' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $arg */ function foo(array $arg): void {} foo([...A::ARR]); ', ], 'classConstCovariant' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.1', ], 'inheritedConstDoesNotOverride' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$a===' => "'baz'", ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'finalConstInterface' => [ 'code' => ' [ '$a===' => "'baz'", ], 'ignored_issues' => [], 'php_version' => '8.1', ], 'constantTypeRespectsLiteralStringLimit' => [ 'code' => <<<'PHP' A::T, 'b' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ]; } $z = B::ARRAY['b']; PHP, ], 'maxIntegerInArrayKey' => [ 'code' => <<<'PHP' 1]; public const I = [9223372036854775807 => 1]; // PHP_INT_MAX + 1 public const SO = ['9223372036854775808' => 1]; } $s = A::S; $i = A::I; $so = A::SO; PHP, 'assertions' => [ '$s===' => 'array{9223372036854775807: 1}', '$i===' => 'array{9223372036854775807: 1}', '$so===' => "array{'9223372036854775808': 1}", ], ], 'autoincrementAlmostOverflow' => [ 'code' => <<<'PHP' 0, 1, // expected key = PHP_INT_MAX ]; } $s = A::I; PHP, 'assertions' => [ '$s===' => 'array{9223372036854775806: 0, 9223372036854775807: 1}', ], ], 'inheritedConstantIsNotAmbiguous' => [ 'code' => <<<'PHP' [ 'code' => ' 'UndefinedConstant', ], 'undefinedClassConstantInParamDefault' => [ 'code' => ' 'UndefinedConstant', ], 'nonMatchingConstantOffset' => [ 'code' => ' 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' => [ 'code' => ' "zero", self::B => "two", ]; } if (C::ARR[C::A] === "two") {}', 'error_message' => 'TypeDoesNotContainType', ], 'missingClassConstInArray' => [ 'code' => ' 'UndefinedConstant', ], 'resolveConstToCurrentClassWithBadReturn' => [ 'code' => ' 'InvalidReturnStatement', 'ignored_issues' => [], 'php_version' => '8.1', ], 'outOfScopeDefinedConstant' => [ 'code' => ' 'UndefinedConstant', ], 'preventStaticClassConstWithoutRef' => [ 'code' => ' 'UndefinedConstant', ], 'noCyclicConstReferences' => [ 'code' => ' 'CircularReference', ], 'keyOfBadValue' => [ 'code' => ' "a", 2 => "b", 3 => "c" ]; /** * @param key-of $i */ public static function foo(int $i) : void {} } A::foo(4);', 'error_message' => 'InvalidArgument', ], 'valueOfBadValue' => [ 'code' => ' "a", 2 => "b", 3 => "c" ]; /** * @param value-of $j */ public static function bar(string $j) : void {} } A::bar("d");', 'error_message' => 'InvalidArgument', ], 'wildcardEnumBadValue' => [ 'code' => ' 'InvalidArgument', ], 'wildcardEnumAnyTemplateExtendConstantBadValue' => [ 'code' => ' */ class A implements AInterface { const C_1 = 1; const C_2 = 2; const C_3 = 3; const D_4 = 4; public function foo($i) { return $i; } } $a = new A(); $a->foo(5); ', 'error_message' => 'InvalidArgument', ], 'correctMessage' => [ 'code' => ' "a", 2 => "b"][$s]; }', 'error_message' => "offset value of '0|1", ], 'constantWithMissingClass' => [ 'code' => ' 'UndefinedClass', ], 'duplicateConstants' => [ 'code' => ' 'DuplicateConstant', ], 'constantDuplicatesEnumCase' => [ 'code' => ' 'DuplicateConstant', 'ignored_issues' => [], 'php_version' => '8.1', ], 'enumCaseDuplicatesConstant' => [ 'code' => ' 'DuplicateConstant', 'ignored_issues' => [], 'php_version' => '8.1', ], 'returnValueofNonExistantConstant' => [ 'code' => ' */ public function bar(): string { return self::BAR[0]; } } ', 'error_message' => 'UnresolvableConstant', ], 'returnValueofStaticConstant' => [ 'code' => ' */ public function bar(): string { return static::BAR[0]; } } ', 'error_message' => 'UnresolvableConstant', ], 'takeKeyofNonExistantConstant' => [ 'code' => ' $key */ public function bar(int $key): string { return static::BAR[$key]; } } ', 'error_message' => 'UnresolvableConstant', ], 'takeKeyofStaticConstant' => [ 'code' => ' $key */ public function bar(int $key): string { return static::BAR[$key]; } } ', 'error_message' => 'UnresolvableConstant', ], 'invalidConstantAssignmentType' => [ 'code' => ' "InvalidConstantAssignmentValue", ], 'invalidConstantAssignmentTypeResolvedLate' => [ 'code' => ' "InvalidConstantAssignmentValue", ], 'classConstContravariant' => [ 'code' => ' "LessSpecificClassConstantType", ], 'classConstAmbiguousInherit' => [ 'code' => ' 'AmbiguousConstantInheritance', ], 'overrideClassConstFromInterface' => [ 'code' => ' 'OverriddenInterfaceConstant', ], 'overrideClassConstFromInterfaceWithInterface' => [ 'code' => ' 'OverriddenInterfaceConstant', ], 'overrideClassConstFromInterfaceWithExtraIrrelevantInterface' => [ 'code' => ' "InvalidClassConstantType", 'ignored_issues' => [], 'php_version' => '8.1', ], 'overrideFinalClassConstFromExtendedClass' => [ 'code' => ' "OverriddenFinalConstant", 'ignored_issues' => [], 'php_version' => '8.1', ], 'overrideFinalClassConstFromImplementedInterface' => [ 'code' => ' "OverriddenFinalConstant", 'ignored_issues' => [], 'php_version' => '8.1', ], 'finalConstantIsIllegalBefore8.1' => [ 'code' => ' 'ParseError - src' . DIRECTORY_SEPARATOR . 'somefile.php:5:44', 'ignored_issues' => [], 'php_version' => '8.0', ], 'classStringIsRequiredToAccessClassConstant' => [ 'code' => ' 'InvalidStringClass', ], 'integerOverflowInArrayKey' => [ 'code' => <<<'PHP' 1]; } PHP, 'error_message' => 'InvalidArrayOffset', ], 'autoincrementOverflow' => [ 'code' => <<<'PHP' 0, 1, // this is a fatal error ]; } PHP, 'error_message' => 'InvalidArrayOffset', ], 'autoincrementOverflowWithUnpack' => [ 'code' => <<<'PHP' 0, ...[1], // this is a fatal error ]; } PHP, 'error_message' => 'InvalidArrayOffset', ], 'unsupportedDynamicFetch' => [ 'code' => ' 'ParseError', 'error_levels' => [], 'php_version' => '8.2', ], ]; } }