Property hooks can be marked final - expose that in reflection API#1474
Merged
Ocramius merged 2 commits intoRoave:6.50.xfrom Dec 30, 2024
Merged
Property hooks can be marked final - expose that in reflection API#1474Ocramius merged 2 commits intoRoave:6.50.xfrom
final - expose that in reflection API#1474Ocramius merged 2 commits intoRoave:6.50.xfrom
Conversation
Ocramius
approved these changes
Dec 30, 2024
Comment on lines
+310
to
322
| $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; |
Member
There was a problem hiding this comment.
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.
Member
|
Promoted from bug to improvement, since this augments hooks, rather than fixing a regression. |
final - expose that in reflection API
Member
|
Thanks @kukulich! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.