Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not intersect two array shapes #7909

Closed
klimick opened this issue Apr 28, 2022 · 5 comments
Closed

Could not intersect two array shapes #7909

klimick opened this issue Apr 28, 2022 · 5 comments

Comments

@klimick
Copy link
Contributor

klimick commented Apr 28, 2022

https://psalm.dev/r/c2e2af5818

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/c2e2af5818
<?php

/**
 * @psalm-type GenericUserWhere = array{
 *     id: list<string>,
 * }
 */
final class GenericUserCriteria
{
}

/**
 * @psalm-import-type GenericUserWhere from GenericUserCriteria
 *
 * @psalm-type NonGenericUserWhere = GenericUserWhere & array{
 *     otherId: list<string>,
 * }
 */
final class NonGenericUserCriteria
{
}
Psalm output (using commit f960d71):

ERROR: InvalidDocblock - 19:1 - Intersection types must be all objects, Psalm\Type\Atomic\TKeyedArray provided

@klimick
Copy link
Contributor Author

klimick commented Apr 28, 2022

May be intersection doesn't work only with psalm-alias.
https://psalm.dev/r/3af7cbf3d7

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/3af7cbf3d7
<?php

/**
 * @param array{id: list<string>} & array{otherId: list<string>} $_
 */
function test(array $_): void {}

test([]);
Psalm output (using commit f960d71):

ERROR: InvalidArgument - 8:6 - Argument 1 of test expects array{id: list<string>, otherId: list<string>}, array<never, never> provided

@orklah
Copy link
Collaborator

orklah commented Apr 28, 2022

Yeah, we're missing something to support that. I believe we already have an issue for this

@AndrolGenhald
Copy link
Collaborator

Duplicate of #5148.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants