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.
Made changes to the default field resolver:
1. Replace
self
withstatic
for a better extensibility2. Add checking of getters that start with
has
prefix (like in PropertyAccess)3. Reduce function calls (micro-optimisation):
This call:
is equal to this:
Additionally, PHP method names are case-insensitive, which means it is not required to call
ucwords
. In other words these 2 calls are equal:$object->getMyParentPosts()
and$object->getmyparentposts()
. So it can be reduced to a single function call:Also successive calls to
guessObjectMethod
were replaced with a foreach loop, which is faster.Result
As a result it saves unnecessary function calls (on each type's field):
If user requests a collection of 200 objects with 10 fields each:
get
prefixes): 200 objects x 10 fields x 3 functions = 6000 calls saved