-
Notifications
You must be signed in to change notification settings - Fork 669
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
Assertion issue with arrays #11248
Comments
I found these snippets: https://psalm.dev/r/bc9418bc3e<?php
class Obj
{
public function __toString(): string
{
return 'obj';
}
}
function f1(array $context): void
{
f2($context);
echo (string) $context['obj'];
}
/**
* @psalm-assert Obj $context['obj']
*/
function f2(array $context): void
{
if(!isset($context['obj'])) {
throw new \InvalidArgumentException('Object is not set');
}
}
|
There is nothing wrong here, use array shapes to specify an exact shape for parameters. |
But I don't want that. I want to assert it. And why isn't there something wrong with my snippet? It doesn't do what I believe everyone would expect |
Nvm, misread |
Ah, okay :) Thank you |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the code:
https://psalm.dev/r/bc9418bc3e
I would not expect any errors.
The text was updated successfully, but these errors were encountered: