[ 'code' => '[] */ function getKey($array) { return array_keys($array); } ', ], 'acceptsArrayKeyFirstFn' => [ 'code' => '|null */ function getKey($array) { return array_key_first($array); } ', ], 'acceptsArrayKeyLastFn' => [ 'code' => '|null */ function getKey($array) { return array_key_last($array); } ', ], 'SKIPPED-acceptsIfArrayKeyExistsFn' => [ 'code' => '|null */ function getKey(string $key, $array) { if (array_key_exists($key, $array)) { return $key; } return null; } ', ], 'keyOfUnreplacedTemplateParam' => [ 'code' => ' */ abstract class Foo { /** * @return key-of */ abstract public function getRandomKey(): string; } ', ], 'keyOfNestedTemplates' => [ 'code' => ' * @param TArray $array * @return list */ function toListOfKeys(array $array): array { return array_keys($array); }', ], ]; } public function providerInvalidCodeParse(): iterable { return [ 'keyOfTemplateNotIncludesString' => [ 'code' => ' */ function getKey($array) { return "foo"; } ', 'error_message' => 'InvalidReturnStatement', ], 'keyOfTemplateNotIncludesInt' => [ 'code' => ' */ function getKey($array) { return 0; } ', 'error_message' => 'InvalidReturnStatement', ], 'keyOfUnresolvedTemplateParamIsStillChecked' => [ 'code' => ' */ abstract class Foo { /** * @return key-of */ abstract public function getRandomKey(): string; } ', 'error_message' => 'MismatchingDocblockReturnType', ], ]; } }