-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat(security): Add PHP \Attribute for remaining security annotations #37905
feat(security): Add PHP \Attribute for remaining security annotations #37905
Conversation
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.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
4f53919
to
a64daa3
Compare
a64daa3
to
203f182
Compare
Signed-off-by: Joas Schilling <coding@schilljs.com>
203f182
to
ecb8b55
Compare
Comment for #37039 on merge:
|
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.
Only suggestions, not blocking points.
if ($this->reflector->hasAnnotation($annotationName)) { | ||
return true; | ||
} | ||
|
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.
@@ -114,23 +141,25 @@ public function beforeController($controller, $methodName) { | |||
* @throws SecurityException | |||
*/ | |||
public function afterController($controller, $methodName, Response $response) { |
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.
This will impact a lot of classes but would be good create a followup issue to do this fix return type and others from Middleware
abstract class:
public function afterController($controller, $methodName, Response $response) { | |
public function afterController($controller, $methodName, Response $response): void { |
* @param class-string<T> $attributeClass | ||
* @return boolean | ||
*/ | ||
protected function hasAnnotationOrAttribute(ReflectionMethod $reflectionMethod, string $annotationName, string $attributeClass): bool { |
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.
This method occur 3 times at this PR with the same signature.
Maybe will be good to move to parent class.
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.
This ia only temporary until we drop the annotations and its 2 if statements. I don't really feel like creating an abstract parent class for 4 operational lines
* @return boolean | ||
*/ | ||
protected function hasAnnotationOrAttribute(ReflectionMethod $reflectionMethod, string $annotationName, string $attributeClass): bool { | ||
if ($this->reflector->hasAnnotation($annotationName)) { |
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.
At other implements of this method on this PR you used the follow code. Make any difference or only was about wrote more times the same method without doing a copy paste?
if ($this->reflector->hasAnnotation($annotationName)) { | |
if (!empty($reflectionMethod->getAttributes($attributeClass))) { |
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.
For AuthorizedAdminSetting
we need the values, so i changed it there but then went for an independent approach, so that's why after that attempt some might diverge, but as mentioned above they are just 2 ifs so it doesn't really matter
Summary
Allowing the remaining annotations of the security middlewares as Attributes
TODO
Checklist