Skip to content

Commit 9ac95f5

Browse files
Merge branch '2.5' into 2.6
* 2.5: [Form] fixed a maxlength overring on a guessing [Debug] Show only unique class candidates [SecurityBundle] Firewall providers building - code cleaning [Filesystem] symlink use RealPath instead LinkTarget [DependencyInjection] Remove duplicate declaration in PhpDumper terminals are not interactive on Travis Revert "[DependencyInjection] backport perf optim" [WebProfilerBundle] replaced pattern to path attribute in routes definitions. fix phpdoc's alignment Fixed the AuthenticationProviderInterface alignment Fixed the proxy-manager version constraint [FrameworkBundle][Template name] avoid error message for the shortcut notation. [DependencyInjection] perf optim: call dirname() at most 5x [DependencyInjection] backport perf optim Fixed #12845 adding a listener to an event that is currently being dispatched will not result into a fatal error in TraceableEventDispatcher [EventDispatcher] [2.5] Remove possible call_user_func() [2.3] Remove possible call_user_func() Conflicts: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php
2 parents 8f51500 + 7b3d3a7 commit 9ac95f5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Constraints/CallbackValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public function validate($object, Constraint $constraint)
5050
$methods = $constraint->methods ?: array($constraint->callback);
5151

5252
foreach ($methods as $method) {
53-
if (is_array($method) || $method instanceof \Closure) {
53+
if ($method instanceof \Closure) {
54+
$method($object, $this->context);
55+
} elseif (is_array($method)) {
5456
if (!is_callable($method)) {
5557
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
5658
}

Constraints/ChoiceValidator.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ public function validate($value, Constraint $constraint)
4949
}
5050

5151
if ($constraint->callback) {
52-
if (is_callable(array($this->context->getClassName(), $constraint->callback))) {
53-
$choices = call_user_func(array($this->context->getClassName(), $constraint->callback));
54-
} elseif (is_callable($constraint->callback)) {
55-
$choices = call_user_func($constraint->callback);
56-
} else {
52+
if (!is_callable($choices = array($this->context->getClassName(), $constraint->callback))
53+
&& !is_callable($choices = $constraint->callback)
54+
) {
5755
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback');
5856
}
57+
$choices = call_user_func($choices);
5958
} else {
6059
$choices = $constraint->choices;
6160
}

Constraints/TypeValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function validate($value, Constraint $constraint)
4040
$isFunction = 'is_'.$type;
4141
$ctypeFunction = 'ctype_'.$type;
4242

43-
if (function_exists($isFunction) && call_user_func($isFunction, $value)) {
43+
if (function_exists($isFunction) && $isFunction($value)) {
4444
return;
45-
} elseif (function_exists($ctypeFunction) && call_user_func($ctypeFunction, $value)) {
45+
} elseif (function_exists($ctypeFunction) && $ctypeFunction($value)) {
4646
return;
4747
} elseif ($value instanceof $constraint->type) {
4848
return;

0 commit comments

Comments
 (0)