Skip to content

Commit 0695077

Browse files
committed
minor #29309 Optimize perf by replacing call_user_func with dynamic variables (ostrolucky)
This PR was merged into the 4.1 branch. Discussion ---------- Optimize perf by replacing call_user_func with dynamic variables | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This provides similar boost as in symfony/symfony#29245, but on more places and without complexity increase. Check eg. https://github.com/fab2s/call_user_func for proof Fabpot failure unrelated Commits ------- 0c6ef01713 Optimize perf by replacing call_user_func with dynamic vars
2 parents 5e3bcec + 0f0f887 commit 0695077

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Constraints/CallbackValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function validate($object, Constraint $constraint)
4343
throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method)));
4444
}
4545

46-
\call_user_func($method, $object, $this->context, $constraint->payload);
46+
$method($object, $this->context, $constraint->payload);
4747
} elseif (null !== $object) {
4848
if (!method_exists($object, $method)) {
4949
throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class %s', $method, \get_class($object)));

Constraints/ChoiceValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function validate($value, Constraint $constraint)
5353
) {
5454
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback');
5555
}
56-
$choices = \call_user_func($choices);
56+
$choices = $choices();
5757
} else {
5858
$choices = $constraint->choices;
5959
}

0 commit comments

Comments
 (0)