-
Notifications
You must be signed in to change notification settings - Fork 653
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
InvalidAttribute error for ReturnTypeWillChange on PHP 8.1 #6731
Comments
Hey @ramsey, can you reproduce the issue on https://psalm.dev ? |
On psalm.dev, the error is different, I suspect because it's not updated to run 8.1 code yet. https://psalm.dev/r/52f0cbb033 |
I found these snippets: https://psalm.dev/r/52f0cbb033<?php
declare(strict_types=1);
namespace Acme;
class Foo implements \JsonSerializable
{
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [];
}
}
|
For reference, here is the RFC that introduced |
Thanks for the report. I don't use attributes much myself, is it the first core attribute in PHP? EDIT: and does this one require specific treatment in Psalm? |
This is not the first core attribute in PHP. Others were added in PHP 8.0. This attribute is required to suppress a deprecation notice for classes that implement I don't know if it requires specific treatment in Psalm. |
Do you know the names of the other attributes? I'm trying to locate them in Psalm's code |
I thought there were others, but I can't find them, so it's possible this is the first one that affects core behavior. I know others are in discussion on the PHP wiki. So far, it looks like there's the The PHP manual has a section about how attributes work: https://www.php.net/attributes |
On PHP 8.1, Psalm responds with an
InvalidAttribute
error when using theReturnTypeWillChange
attribute. However, it should recognizeReturnTypeWillChange
as a valid PHP 8 attribute.To reproduce, save the following to
Foo.php
in an empty directory.Execute the following shell commands to download Composer and use Docker to run Psalm on PHP 8.1.
You will see the following output:
The text was updated successfully, but these errors were encountered: