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

Report undefined key when array shape is used #8145

Closed
zmitic opened this issue Jun 22, 2022 · 2 comments
Closed

Report undefined key when array shape is used #8145

zmitic opened this issue Jun 22, 2022 · 2 comments

Comments

@zmitic
Copy link

zmitic commented Jun 22, 2022

Reproducer: https://psalm.dev/r/db0313ec1b


Use case:

function expects array{name?: string} but doesn't report any errors when undefined key is sent. Is this by design?

@psalm-github-bot
Copy link

I found these snippets:

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

/**
 * @param array{name?: string} $data
 */
function test(array $data): void {
    print_r($data);
}

$data = [
    'undefined_key' => 'test',    
];

test($data);
Psalm output (using commit 29a2162):

No issues!

@AndrolGenhald
Copy link
Collaborator

This is by design, but something we hope to improve. See #5299.

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