diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 8481dc78e7..5730807fac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -11,9 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; -use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser; /** * TemplateNameParser converts template names from the short notation @@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\KernelInterface; * * @author Fabien Potencier */ -class TemplateNameParser implements TemplateNameParserInterface +class TemplateNameParser extends BaseTemplateNameParser { protected $kernel; protected $cache = array(); @@ -56,7 +56,7 @@ class TemplateNameParser implements TemplateNameParserInterface } if (!preg_match('/^([^:]*):([^:]*):(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) { - throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name)); + return parent::parse($name); } $template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index 12747e6dc2..30bfc56a11 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -105,7 +105,8 @@ class AppKernel extends Kernel public function unserialize($str) { - call_user_func_array(array($this, '__construct'), unserialize($str)); + $a = unserialize($str); + $this->__construct($a[0], $a[1], $a[2], $a[3]); } protected function getKernelParameters() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 2a1544c91b..ca10c3a8fe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; +use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; class TemplateNameParserTest extends TestCase { @@ -63,25 +64,17 @@ class TemplateNameParserTest extends TestCase array(':Post:index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')), array('::index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('FooBundle:Post:foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), + array('/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), + array('name.twig', new BaseTemplateReference('name.twig', 'twig')), + array('name', new BaseTemplateReference('name')), ); } /** - * @dataProvider getInvalidLogicalNameProvider * @expectedException \InvalidArgumentException */ - public function testParseInvalidName($name) + public function testParseValidNameWithNotFoundBundle() { - $this->parser->parse($name); - } - - public function getInvalidLogicalNameProvider() - { - return array( - array('BarBundle:Post:index.html.php'), - array('FooBundle:Post:index'), - array('FooBundle:Post'), - array('FooBundle:Post:foo:bar'), - ); + $this->parser->parse('BarBundle:Post:index.html.php'); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index 57816ccef9..dfce6e4a6c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -105,7 +105,8 @@ class AppKernel extends Kernel public function unserialize($str) { - call_user_func_array(array($this, '__construct'), unserialize($str)); + $a = unserialize($str); + $this->__construct($a[0], $a[1], $a[2], $a[3]); } protected function getKernelParameters() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml index 69f934e53f..d9708f9c50 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml @@ -4,47 +4,47 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - + web_profiler.controller.profiler:homeAction - + web_profiler.controller.profiler:searchAction - + web_profiler.controller.profiler:searchBarAction - + web_profiler.controller.profiler:purgeAction - + web_profiler.controller.profiler:infoAction - + web_profiler.controller.profiler:phpinfoAction - + web_profiler.controller.profiler:searchResultsAction - + web_profiler.controller.profiler:panelAction - + web_profiler.controller.router:panelAction - + web_profiler.controller.exception:showAction - + web_profiler.controller.exception:cssAction diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml index 5f6851c9ff..1027ce42f6 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/wdt.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - + web_profiler.controller.profiler:toolbarAction diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 7cbddc6cf3..885863bbb6 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -225,8 +225,10 @@ class ExprBuilder { foreach ($expressions as $k => $expr) { if ($expr instanceof ExprBuilder) { - $expressions[$k] = function ($v) use ($expr) { - return call_user_func($expr->ifPart, $v) ? call_user_func($expr->thenPart, $v) : $v; + $if = $expr->ifPart; + $then = $expr->thenPart; + $expressions[$k] = function ($v) use ($if, $then) { + return $if($v) ? $then($v) : $v; }; } } diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index 61acc1821a..d253a00859 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -49,7 +49,9 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface */ public function getDefaultValue() { - return $this->defaultValue instanceof \Closure ? call_user_func($this->defaultValue) : $this->defaultValue; + $v = $this->defaultValue; + + return $v instanceof \Closure ? $v() : $v; } /** diff --git a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php index b1ad4420dc..6a3b01cfbe 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php @@ -22,6 +22,6 @@ class FileLoaderImportCircularReferenceException extends FileLoaderLoadException { $message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]); - call_user_func('Exception::__construct', $message, $code, $previous); + \Exception::__construct($message, $code, $previous); } } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 23dd7cecef..705d0b08fd 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -109,17 +109,19 @@ class PhpDumper extends Dumper ), $options); if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) { - // Build a regexp where the first two root dirs are mandatory, + // Build a regexp where the first root dirs are mandatory, // but every other sub-dir is optional up to the full path in $dir + // Mandate at least 2 root dirs and not more that 5 optional dirs. $dir = explode(DIRECTORY_SEPARATOR, realpath($dir)); $i = count($dir); if (3 <= $i) { $regex = ''; - $this->targetDirMaxMatches = $i - 3; + $lastOptionalDir = $i > 8 ? $i - 5 : 3; + $this->targetDirMaxMatches = $i - $lastOptionalDir; - while (2 < --$i) { + while (--$i >= $lastOptionalDir) { $regex = sprintf('(%s%s)?', preg_quote(DIRECTORY_SEPARATOR.$dir[$i], '#'), $regex); } @@ -786,6 +788,9 @@ $bagClass */ class $class extends $baseClass { + private \$parameters; + private \$targetDirs = array(); + EOF; } @@ -796,6 +801,7 @@ EOF; */ private function addConstructor() { + $targetDirs = $this->exportTargetDirs(); $arguments = $this->container->getParameterBag()->all() ? 'new ParameterBag($this->getDefaultParameters())' : null; $code = <<exportTargetDirs(); + $code = <<container->getParameterBag()->all()) { @@ -1405,6 +1413,17 @@ EOF; return $this->expressionLanguage; } + private function exportTargetDirs() + { + return null === $this->targetDirRegex ? '' : <<targetDirMaxMatches}; ++\$i) { + \$this->targetDirs[\$i] = \$dir = dirname(\$dir); + } +EOF; + } + private function export($value) { if (null !== $this->targetDirRegex && is_string($value) && preg_match($this->targetDirRegex, $value, $matches, PREG_OFFSET_CAPTURE)) { @@ -1413,8 +1432,8 @@ EOF; $suffix = isset($value[$suffix]) ? '.'.var_export(substr($value, $suffix), true) : ''; $dirname = '__DIR__'; - for ($i = $this->targetDirMaxMatches - count($matches); 0 <= $i; --$i) { - $dirname = sprintf('dirname(%s)', $dirname); + if (0 < $offset = 1 + $this->targetDirMaxMatches - count($matches)) { + $dirname = sprintf('$this->targetDirs[%d]', $offset); } if ($prefix || $suffix) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 2693cbd2b1..687ea468a7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -85,13 +85,14 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $definition = new Definition(); $definition->setClass('stdClass'); $definition->addArgument('%foo%'); - $definition->addArgument(array('%foo%' => '%foo%')); + $definition->addArgument(array('%foo%' => '%buz%/')); $container = new ContainerBuilder(); $container->setDefinition('test', $definition); $container->setParameter('foo', 'wiz'.dirname(dirname(__FILE__))); $container->setParameter('bar', dirname(__FILE__)); $container->setParameter('baz', '%bar%/PhpDumperTest.php'); + $container->setParameter('buz', dirname(dirname(__DIR__))); $container->compile(); $dumper = new PhpDumper($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index ca7a5c6a24..116d7dfe70 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -17,6 +17,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; */ class Container extends AbstractContainer { + private $parameters; + private $targetDirs = array(); + /** * Constructor. */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index 084e7891af..90b59ff4eb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -16,6 +16,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; */ class ProjectServiceContainer extends Container { + private $parameters; + private $targetDirs = array(); + /** * Constructor. */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index 2ccd9a07e4..43a56eec51 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; class ProjectServiceContainer extends Container { private $parameters; + private $targetDirs = array(); /** * Constructor. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php index 361b352c74..23bae47920 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; class ProjectServiceContainer extends Container { private $parameters; + private $targetDirs = array(); /** * Constructor. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 52d2702afd..3081abd6b0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -16,11 +16,18 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; */ class ProjectServiceContainer extends Container { + private $parameters; + private $targetDirs = array(); + /** * Constructor. */ public function __construct() { + $dir = __DIR__; + for ($i = 1; $i <= 5; ++$i) { + $this->targetDirs[$i] = $dir = dirname($dir); + } $this->parameters = $this->getDefaultParameters(); $this->services = @@ -48,7 +55,7 @@ class ProjectServiceContainer extends Container */ protected function getTestService() { - return $this->services['test'] = new \stdClass(('wiz'.dirname(__DIR__)), array(('wiz'.dirname(__DIR__)) => ('wiz'.dirname(__DIR__)))); + return $this->services['test'] = new \stdClass(('wiz'.$this->targetDirs[1]), array(('wiz'.$this->targetDirs[1]) => ($this->targetDirs[2].'/'))); } /** @@ -102,9 +109,10 @@ class ProjectServiceContainer extends Container protected function getDefaultParameters() { return array( - 'foo' => ('wiz'.dirname(__DIR__)), + 'foo' => ('wiz'.$this->targetDirs[1]), 'bar' => __DIR__, 'baz' => (__DIR__.'/PhpDumperTest.php'), + 'buz' => $this->targetDirs[2], ); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index f922d2000c..1b86dfc3f8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -16,6 +16,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; */ class ProjectServiceContainer extends Container { + private $parameters; + private $targetDirs = array(); + /** * Constructor. */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 8fe63d7056..876dc0eeb0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -16,6 +16,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; */ class ProjectServiceContainer extends Container { + private $parameters; + private $targetDirs = array(); + /** * Constructor. */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 8962b26398..4962a25880 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; class ProjectServiceContainer extends Container { private $parameters; + private $targetDirs = array(); /** * Constructor. diff --git a/src/Symfony/Component/Finder/Shell/Command.php b/src/Symfony/Component/Finder/Shell/Command.php index 78824d0df4..1f69afb2c7 100644 --- a/src/Symfony/Component/Finder/Shell/Command.php +++ b/src/Symfony/Component/Finder/Shell/Command.php @@ -246,14 +246,14 @@ class Command */ public function execute() { - if (null === $this->errorHandler) { + if (null === $errorHandler = $this->errorHandler) { exec($this->join(), $output); } else { $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY); if ($error = stream_get_contents($pipes[2])) { - call_user_func($this->errorHandler, $error); + $errorHandler($error); } proc_close($process); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php index da8c34c177..5546ba2ed8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php @@ -72,8 +72,8 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface $response = new Response($this->body, $this->status, $this->headers); - if (null !== $this->customizer) { - call_user_func($this->customizer, $request, $response); + if (null !== $customizer = $this->customizer) { + $customizer($request, $response); } return $response; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index c2f8641c56..526be032a7 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1371,11 +1371,12 @@ class Process $result = $this->processPipes->read($blocking); } + $callback = $this->callback; foreach ($result as $type => $data) { if (3 == $type) { $this->fallbackExitcode = (int) $data; } else { - call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data); + $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); } } } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 982a4d53de..521d4d960b 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -844,7 +844,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { $process = $this->getProcess('php -m'); $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method)); - call_user_func(array($process, $method)); + $process->{$method}(); } public function provideMethodsThatNeedARunningProcess() @@ -866,7 +866,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $process = $this->getProcess('php -r "sleep(1);"'); $process->start(); try { - call_user_func(array($process, $method)); + $process->{$method}(); $process->stop(0); $this->fail('A LogicException must have been thrown'); } catch (\Exception $e) { diff --git a/src/Symfony/Component/Routing/Loader/ClosureLoader.php b/src/Symfony/Component/Routing/Loader/ClosureLoader.php index 8212c2916d..9edab1e9e3 100644 --- a/src/Symfony/Component/Routing/Loader/ClosureLoader.php +++ b/src/Symfony/Component/Routing/Loader/ClosureLoader.php @@ -37,7 +37,7 @@ class ClosureLoader extends Loader */ public function load($closure, $type = null) { - return call_user_func($closure); + return $closure(); } /** diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index a6a29e7e6e..6f073c7d87 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -50,7 +50,9 @@ class CallbackValidator extends ConstraintValidator $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])); } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 5640c73317..460e463563 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -49,13 +49,12 @@ class ChoiceValidator extends ConstraintValidator } 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; } diff --git a/src/Symfony/Component/Validator/Constraints/TypeValidator.php b/src/Symfony/Component/Validator/Constraints/TypeValidator.php index ca6e5aa7ca..66217d0c39 100644 --- a/src/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -40,9 +40,9 @@ class TypeValidator extends ConstraintValidator $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;