Skip to content

Add #[SensitiveParameter] attribute. #285

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

donquixote
Copy link

These are all I could find.

I like to do this kind of change in a separate PR, to reduce noise in the main PR.

@GhaziTriki
Copy link
Member

SensitiveParameter is a PHP >=8.2 feature. The develop branch still allows PHP 8.1. What happens if this metadata us ran in a PHP 8.1 env?

@donquixote
Copy link
Author

It is fine until somebody actually attempts to instantiate the attribute:

$parameter = `(new ReflectionMethod(****))->getParameters()[0];
$attributes = $parameter->getAttributes();
$attributes[0]->newInstance();  // Fatal error: Uncaught Error: Attribute class "SensitiveParameter" not found

Note that it's fine if you pass a class or interface name to ->getAttributes():

$parameter = `(new ReflectionMethod(****))->getParameters()[0];
$attributes = $parameter->getAttributes(MyClass);
$attributes[0]->newInstance();  // Fatal error: Uncaught Error: Attribute class "SensitiveParameter" not found

Here is some more context.
https://3v4l.org/I9AZh#v8.1.32

This said, if you want, we can postpone this and remove this change from the other PRs.

@GhaziTriki GhaziTriki self-requested a review June 15, 2025 05:57
@GhaziTriki
Copy link
Member

Good but needs the library to be on PHP 8.2+ to merge it. Let's keep this one on the waiting queue.

@donquixote
Copy link
Author

Good but needs the library to be on PHP 8.2+ to merge it. Let's keep this one on the waiting queue.

What I meant is that it will be generally fine in PHP 8.1, except the case mentioned above, which is not likely to happen.
(most people don't just randomly instantiate attributes in vendor packages).

This said, I will omit this from the other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants