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

No way to specify that the shape of an array must be exactly the same #8397

Closed
danog opened this issue Aug 11, 2022 · 3 comments
Closed

No way to specify that the shape of an array must be exactly the same #8397

danog opened this issue Aug 11, 2022 · 3 comments

Comments

@danog
Copy link
Collaborator

danog commented Aug 11, 2022

See https://psalm.dev/r/1ce76391ab
#8395 is related, I thought explicitly specifying that a shape is sealed- would've helped, but it didn't: what even is the point of sealing a shape then?

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/1ce76391ab
<?php

/**
 * @param array{test: int} $i
 */
function test(array $i): int {
    return array_values($i)[0];
}

/**
 * @param array<string, string|int>&array{test: int} $i
 */
function test2(array $i): int {
    return test($i);
}

test(['a' => 'string', 'test' => 123]);
Psalm output (using commit ffc8c80):

No issues!

@AndrolGenhald
Copy link
Collaborator

I thought explicitly specifying that a shape is sealed- would've helped, but it didn't: what even is the point of sealing a shape then?

I don't think the type comparison properly checks it, since it's currently not possible to annotate a sealed- type anyway.

Duplicate of #5299.

@AndrolGenhald AndrolGenhald closed this as not planned Won't fix, can't repro, duplicate, stale Aug 11, 2022
@danog
Copy link
Collaborator Author

danog commented Aug 11, 2022

I meant in my PR, which does support annotating sealed shapes

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

No branches or pull requests

2 participants