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
Attribute class does not have the parameter target for promoted properties #10385
Comments
Promoted property is a parameter and property at the same time. This is expected behaviour. |
I've opened the issue because I've got the error while using Symfony's constraints alongside promoted properties. For example, the Uuid constraint only applies to property or method as docs explain. With this definition: #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Uuid extends Constraint
{
} The following code works but PHPStan now reports an error: class Author
{
public function __construct(
#[Assert\Uuid]
private string $id
) {}
} I could open an issue in Symfony repo but I doubt they will be willing to add Do you think the issue is on Symfony side? |
The behaviour is going to change back in 1.10.54. The conclusion in PHP internals is that this should not be reported: https://externals.io/message/111942#112021 |
Thanks @ondrejmirtes |
@ondrejmirtes does this mean you reverted the behavior introduced following #10298 ? And doesn't that mean that the issue I reported in that ticket is a valid issue? (for which there is the closed / unmerged PR phpstan/phpstan-src#2825) |
@RobertMe After seeing your PR with a fresh set of eyes and the newly aquired knowledge I decided to merge it: phpstan/phpstan-src@2e08c9f Thank you. |
@ondrejmirtes thank you 👍🏻 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Version affected: 1.10.51 with bleeding edge
Given an attribute with property target
When the attribute is applied to a promoted property
Then PHPStan reports the attribute does not have parameter target
It seems PHPStan doesn't recognise the attribute is applied to a promoted property but instead it thinks it's function parameter.
Code snippet that reproduces the problem
https://phpstan.org/r/b407f06b-e3c6-419a-9d32-aca23a616fef
Expected output
PHPStan should not report any issues.
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: