-
Notifications
You must be signed in to change notification settings - Fork 132
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
Property hooks can be marked final
- expose that in reflection API
#1474
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.
Looking good!
$modifiers = 0; | ||
|
||
if ($node instanceof MethodNode) { | ||
$modifiers += $node->isStatic() ? CoreReflectionMethod::IS_STATIC : 0; | ||
$modifiers += $node->isPublic() ? CoreReflectionMethod::IS_PUBLIC : 0; | ||
$modifiers += $node->isProtected() ? CoreReflectionMethod::IS_PROTECTED : 0; | ||
$modifiers += $node->isPrivate() ? CoreReflectionMethod::IS_PRIVATE : 0; | ||
$modifiers += $node->isAbstract() ? CoreReflectionMethod::IS_ABSTRACT : 0; | ||
} | ||
|
||
$modifiers += $node->isFinal() ? CoreReflectionMethod::IS_FINAL : 0; | ||
|
||
return $modifiers; |
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.
BTW, no idea how PHP optimizes this, but it's a giant cascade of ternaries D:
I wonder if this could be a single bitwise or operation:
$modifiers = $modifiers |
($node->isStatic() & CoreReflectionMethod::IS_STATIC) |
($node->isPublic() & CoreReflectionMethod::IS_PUBLIC) |
($node->isProtected() & CoreReflectionMethod::IS_PROTECTED) |
($node->isPrivate() & CoreReflectionMethod::IS_PRIVATE) |
($node->isAbstract() & CoreReflectionMethod::IS_ABSTRACT);
Not for this patch, just for future use-cases. The method calls here are still the biggest offender.
Promoted from bug to improvement, since this augments hooks, rather than fixing a regression. |
final
- expose that in reflection API
Thanks @kukulich! |
No description provided.