-
Notifications
You must be signed in to change notification settings - Fork 452
chore: Remove @deprecated annotation from config array fields
#8689
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
chore: Remove @deprecated annotation from config array fields
#8689
Conversation
bdbabbf to
ac4ee40
Compare
Well that's unfortunate. I checked using IntelliPHPence, and didn't have this issue. I wonder if there's a way to fix this for PHPStan without removing it, as i really would like to keep it there.
PHPStan is only one standardization around documenting PHP methods/array shapes, and at the time this library was written, the documentation standard being used here ( |
| * Only valid for requests sent over REST. | ||
| * @type array $keyFile [DEPRECATED] | ||
| * @deprecated This option is being deprecated because of a potential security risk. | ||
| * This option is being deprecated because of a potential security risk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try using this syntax and see if it works (prefixing @deprecated with //)? This should tell PHPStan to ignore that line (e.g. treat it as a comment rather than parse the tag)
| * This option is being deprecated because of a potential security risk. | |
| * // @deprecated | |
| * This option is being deprecated because of a potential security risk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this didn't change the report (I think because it's just™ a comment within a comment).
In a project, you can add this to silence the error:
/* @phpstan-ignore method.deprecated */
$client = new FirestoreClient($config);(only when they use https://github.com/phpstan/phpstan-deprecation-rules )
It's only when using https://github.com/phpstan/phpstan-deprecation-rules - "vanilla" PHPStan doesn't report this. People can still ignore this specific error in their own projects, they'd have to add a But aside from PHPStan, my IDE shows the constructor as deprecated as well (see screenshot above) - do you know if other IDEs/Doc tools can parse the docblock as intendend and only deprecate the array key? Otherwise I'd still like to suggest removing it and keeping only the /**
* @deprecated
*/ |
ac4ee40 to
0b0c628
Compare
0b0c628 to
8874e02
Compare
The deprecation error has been introduced with the changes in googleapis/google-cloud-php#8617. Until/Unless googleapis/google-cloud-php#8689 or something similar is implemented, we need to ignore the error here.
The deprecation error has been introduced with the changes in googleapis/google-cloud-php#8617. Until/Unless googleapis/google-cloud-php#8689 or something similar is implemented, we need to ignore the error here.
Ahh you're right, I missed that. I don't like that at all
This seems like a good idea |
|
Makes perfect sense. I wish there was a better way to really alert the end user with the deprecated parameter, but I feel like this is a weakness of using untyped arrays for the options. Leaving the DEPRECATED message seems like a good compromise to me. |
When running PHPStan with the https://github.com/phpstan/phpstan-deprecation-rules/ extension installed, the whole method is seen as deprecated, leading to violations like in https://github.com/kreait/firebase-php/actions/runs/18822790410/job/53700886141
When hovering about the constructor in PHPStorm, the constructor itself is marked as deprecated as well (here in the
FirestoreClient):I don't know if this an authoritative source, but https://docs.phpdoc.org/guide/references/phpdoc/tags/deprecated.html mentions that
@deprecatedapplies to structural elements - I'm not aware that one is supposed to use it to deprecate fields in an array with this.PS: I couldn't find a source for
@type"being a thing" 🙈