-
Notifications
You must be signed in to change notification settings - Fork 698
Recursive array type not validated #1892
Copy link
Copy link
Closed
Description
Code:
<?php
/**
* @psalm-type recursiveData array<string, string|recursiveData>
*
* @return recursiveData
*/
function foo(): array {
return ['id' => 'bar', 'key' => ['baz' => 'fred']];
}Actual output at https://psalm.dev/r/d19ae42a39
Psalm output (using commit 5c76b3c):
ERROR: InvalidReturnStatement - 8:12 - The type 'array{id: string(bar), key: array{baz: string(fred)}}' does not match the declared return type 'array<string, string|recursiveData>' for foo
ERROR: InvalidReturnType - 5:13 - The declared return type 'array<string, string|recursiveData>' for foo is incorrect, got 'array{id: string, key: array{baz: string}}'
Expected output:
No issues!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels