-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Fix merge direction #1571
Fix merge direction #1571
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.
Bonus points if you provide a test case for your change
@@ -91,9 +91,9 @@ public function fixFieldDescription(FieldDescriptionInterface $fieldDescription) | |||
ModelFilter::class === $fieldDescription->getType() && null === $fieldDescription->getOption('field_type') | |||
|| EntityType::class === $fieldDescription->getOption('field_type') | |||
) { | |||
$fieldDescription->mergeOption('field_options', [ | |||
$fieldDescription->setOption('field_options', array_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.
If these offsets are strings, we could use +
instead of array_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.
Do you prefer $a + $b over array_merge($b, $a) or do we merge like this ?
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.
IMO, avoiding a function call is better for performance reasons.
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.
I think array_merge is clearer and more descriptive.
Performance wise I've just found this: https://stackoverflow.com/questions/57192782/array-merge-vs-direct-array-injection-performance/57193666 which indicates that array_merge is faster.
Edit: Sorry, I've skipped a few lines. This doesn't compare with +.
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.
It's just a suggestion, not a blocker for the fix.
We could make performance improvements in a new PR.
For the records: https://gist.github.com/Ocramius/8399625.
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.
@phansys not sure it's still true, the comparison was done with PHP 5.4
Thanks |
Subject
This PR fixes an issue with non mapped filter made with
CallbackFilter
.I am targeting this branch, because this bug was introduced and isn't present in any other branch.
Closes #1568
Changelog