-
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
Error not reported for list<key-of<properties-of<self>>> #11254
Comments
I found these snippets: https://psalm.dev/r/bbd2bcc7b2<?php
class A
{
public string $foo = 'foo!';
public int $bar = 42;
/**
* @return list<key-of<properties-of<self>>>
*/
public function attributeNames(): array
{
return ['not_existing_property_1', 'not_existing_property_2'];
}
}
$a = new A();
$b = $a->attributeNames();
/** @psalm-trace $b */
|
The class is non-final, making it final fixes the issue (though since here we're explicitly specifying |
Thanks, this helped a lot. I can't make the class final because of Doctrine, but I can make phpdoc version of it and now it works: https://psalm.dev/r/91ef7f5c23 |
I found these snippets: https://psalm.dev/r/91ef7f5c23<?php
/** @final */
class A
{
public string $foo = 'foo!';
public int $bar = 42;
/**
* @return list<key-of<properties-of<self>>>
*/
public function attributeNames(): array
{
return ['not_existing_property_1', 'not_existing_property_2'];
}
}
$a = new A();
$b = $a->attributeNames();
/** @psalm-trace $b */
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on documentation, the following code should report problems for
attributeNames
method but it doesn't: https://psalm.dev/r/bbd2bcc7b2Use-case: this type is perfect for Doctrine PreUpdate event when we need to do something, but only when specified properties are updated and not all.
The text was updated successfully, but these errors were encountered: