,ignored_issues?:list,php_version?:string}> */ public function providerValidCodeParse(): iterable { return [ 'keyOfListClassConstant' => [ 'code' => ' */ public function getKey() { return 0; } } ' ], 'keyOfAssociativeArrayClassConstant' => [ 'code' => ' 42 ]; /** @return key-of */ public function getKey() { return "bar"; } } ' ], 'allKeysOfAssociativeArrayPossible' => [ 'code' => ' 42, "adams" => 43, ]; /** @return key-of */ public function getKey(bool $adams) { if ($adams) { return "adams"; } return "bar"; } } ' ], 'keyOfAsArray' => [ 'code' => ' 42, "adams" => 43, ]; /** @return key-of[] */ public function getKey() { return array_keys(self::FOO); } } ' ], 'keyOfArrayLiteral' => [ 'code' => '> */ function getKey() { return 32; } ' ], 'keyOfUnionArrayLiteral' => [ 'code' => '|array> */ function getKey(bool $asFloat) { if ($asFloat) { return 42.0; } return 42; } ' ], 'keyOfUnionListAndKeyedArray' => [ 'code' => '|array{a: int, b: int}> */ function getKey(bool $asInt) { if ($asInt) { return 42; } return "a"; } ', ], 'keyOfListArrayLiteral' => [ 'code' => '> */ function getKey() { return 42; } ' ], 'keyOfStringArrayConformsToString' => [ 'code' => '>[] */ $keys2 = ["foo"]; return $keys2[0]; } ' ], ]; } /** * @return iterable,php_version?:string}> */ public function providerInvalidCodeParse(): iterable { return [ 'onlyDefinedKeysOfAssociativeArray' => [ 'code' => ' 42 ]; /** @return key-of */ public function getKey() { return "adams"; } } ', 'error_message' => 'InvalidReturnStatement' ], 'keyOfArrayLiteral' => [ 'code' => '> */ public function getKey() { return "foo"; } } ', 'error_message' => 'InvalidReturnStatement' ], 'onlyIntAllowedForKeyOfList' => [ 'code' => '> */ public function getKey() { return "42"; } } ', 'error_message' => 'InvalidReturnStatement' ], 'noStringAllowedInKeyOfIntFloatArray' => [ 'code' => '|array> */ function getKey(bool $asFloat) { if ($asFloat) { return 42.0; } return "42"; } ', 'error_message' => 'InvalidReturnStatement' ], 'noLiteralCAllowedInKeyOfUnionListAndKeyedArray' => [ 'code' => '|array{a: int, b: int}> */ function getKey() { return "c"; } ', 'error_message' => 'InvalidReturnStatement' ], ]; } }