-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Rely on reflection to access null properties #4425
Open
nicolas-grekas
wants to merge
1
commit into
twigphp:3.x
Choose a base branch
from
nicolas-grekas:array-cast-less
base: 3.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
nicolas-grekas
changed the title
Rely on reflection to access properties
Rely on reflection to access null properties
Oct 29, 2024
nicolas-grekas
force-pushed
the
array-cast-less
branch
from
October 29, 2024 16:56
940ea01
to
f023cec
Compare
stof
reviewed
Oct 29, 2024
nicolas-grekas
force-pushed
the
array-cast-less
branch
from
October 29, 2024 17:05
f023cec
to
5e793c3
Compare
stof
reviewed
Oct 29, 2024
nicolas-grekas
force-pushed
the
array-cast-less
branch
from
October 29, 2024 17:17
5e793c3
to
e4eb3ce
Compare
fabpot
reviewed
Oct 29, 2024
nicolas-grekas
force-pushed
the
array-cast-less
branch
2 times, most recently
from
October 31, 2024 12:02
c186115
to
d8f39e6
Compare
PR updated with a simpler and more performant approach, that makes DateTimeInterface a special case (because it is). |
GromNaN
reviewed
Oct 31, 2024
nicolas-grekas
force-pushed
the
array-cast-less
branch
from
October 31, 2024 13:11
d8f39e6
to
aca2914
Compare
stof
reviewed
Oct 31, 2024
nicolas-grekas
force-pushed
the
array-cast-less
branch
from
October 31, 2024 13:50
aca2914
to
5e1b6fe
Compare
nicolas-grekas
force-pushed
the
array-cast-less
branch
from
October 31, 2024 13:52
5e1b6fe
to
ca54737
Compare
fabpot
reviewed
Nov 1, 2024
@@ -1720,6 +1738,8 @@ public static function getAttribute(Environment $env, Source $source, $object, $ | |||
|
|||
return \constant($object::class.'::'.$item); | |||
} | |||
} else { | |||
$item = (string) $item; |
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 we cast before the if
?
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.
Benchmark like https://gist.github.com/arnaud-lb/c4235164fb41e11672aa670da8fa4fc7 (which were done for another use case but is still relevant here) prove that using reflection instead of array-casts is significantly faster for accessing properties.
Checking for dynamic properties is done with property_exists.