Skip to content

Commit

Permalink
Merge branch '2.3' into 2.5
Browse files Browse the repository at this point in the history
* 2.3:
  Revert "[DependencyInjection] backport perf optim"
  [WebProfilerBundle] replaced pattern to path attribute in routes definitions.
  [FrameworkBundle][Template name] avoid  error message for the shortcut notation.
  [DependencyInjection] perf optim: call dirname() at most 5x
  [DependencyInjection] backport perf optim
  [2.3] Remove possible call_user_func()

Conflicts:
	src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
  • Loading branch information
fabpot committed Dec 11, 2014
2 parents d7be1a9 + 07255a8 commit 7b3d3a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Constraints/CallbackValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function validate($object, Constraint $constraint)
$methods = $constraint->methods ?: array($constraint->callback);

foreach ($methods as $method) {
if (is_array($method) || $method instanceof \Closure) {
if ($method instanceof \Closure) {
$method($object, $this->context);
} elseif (is_array($method)) {
if (!is_callable($method)) {
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
}
Expand Down
9 changes: 4 additions & 5 deletions Constraints/ChoiceValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ public function validate($value, Constraint $constraint)
}

if ($constraint->callback) {
if (is_callable(array($this->context->getClassName(), $constraint->callback))) {
$choices = call_user_func(array($this->context->getClassName(), $constraint->callback));
} elseif (is_callable($constraint->callback)) {
$choices = call_user_func($constraint->callback);
} else {
if (!is_callable($choices = array($this->context->getClassName(), $constraint->callback))
&& !is_callable($choices = $constraint->callback)
) {
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback');
}
$choices = call_user_func($choices);
} else {
$choices = $constraint->choices;
}
Expand Down
4 changes: 2 additions & 2 deletions Constraints/TypeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function validate($value, Constraint $constraint)
$isFunction = 'is_'.$type;
$ctypeFunction = 'ctype_'.$type;

if (function_exists($isFunction) && call_user_func($isFunction, $value)) {
if (function_exists($isFunction) && $isFunction($value)) {
return;
} elseif (function_exists($ctypeFunction) && call_user_func($ctypeFunction, $value)) {
} elseif (function_exists($ctypeFunction) && $ctypeFunction($value)) {
return;
} elseif ($value instanceof $constraint->type) {
return;
Expand Down

0 comments on commit 7b3d3a7

Please sign in to comment.