[2.3] Remove possible call_user_func()
This commit is contained in:
parent
580de75249
commit
fad7aba3ba
@ -105,7 +105,8 @@ class AppKernel extends Kernel
|
|||||||
|
|
||||||
public function unserialize($str)
|
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()
|
protected function getKernelParameters()
|
||||||
|
@ -105,7 +105,8 @@ class AppKernel extends Kernel
|
|||||||
|
|
||||||
public function unserialize($str)
|
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()
|
protected function getKernelParameters()
|
||||||
|
@ -225,8 +225,10 @@ class ExprBuilder
|
|||||||
{
|
{
|
||||||
foreach ($expressions as $k => $expr) {
|
foreach ($expressions as $k => $expr) {
|
||||||
if ($expr instanceof ExprBuilder) {
|
if ($expr instanceof ExprBuilder) {
|
||||||
$expressions[$k] = function ($v) use ($expr) {
|
$if = $expr->ifPart;
|
||||||
return call_user_func($expr->ifPart, $v) ? call_user_func($expr->thenPart, $v) : $v;
|
$then = $expr->thenPart;
|
||||||
|
$expressions[$k] = function ($v) use ($if, $then) {
|
||||||
|
return $if($v) ? $then($v) : $v;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,9 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
*/
|
*/
|
||||||
public function getDefaultValue()
|
public function getDefaultValue()
|
||||||
{
|
{
|
||||||
return $this->defaultValue instanceof \Closure ? call_user_func($this->defaultValue) : $this->defaultValue;
|
$v = $this->defaultValue;
|
||||||
|
|
||||||
|
return $v instanceof \Closure ? $v() : $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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]);
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,14 +248,14 @@ class Command
|
|||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
if (null === $this->errorHandler) {
|
if (null === $errorHandler = $this->errorHandler) {
|
||||||
exec($this->join(), $output);
|
exec($this->join(), $output);
|
||||||
} else {
|
} else {
|
||||||
$process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
|
$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);
|
$output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
if ($error = stream_get_contents($pipes[2])) {
|
if ($error = stream_get_contents($pipes[2])) {
|
||||||
call_user_func($this->errorHandler, $error);
|
$errorHandler($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_close($process);
|
proc_close($process);
|
||||||
|
@ -74,8 +74,8 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
|
|||||||
|
|
||||||
$response = new Response($this->body, $this->status, $this->headers);
|
$response = new Response($this->body, $this->status, $this->headers);
|
||||||
|
|
||||||
if (null !== $this->customizer) {
|
if (null !== $customizer = $this->customizer) {
|
||||||
call_user_func($this->customizer, $request, $response);
|
$customizer($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -1102,11 +1102,12 @@ class Process
|
|||||||
$result = $this->processPipes->read($blocking);
|
$result = $this->processPipes->read($blocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$callback = $this->callback;
|
||||||
foreach ($result as $type => $data) {
|
foreach ($result as $type => $data) {
|
||||||
if (3 == $type) {
|
if (3 == $type) {
|
||||||
$this->fallbackExitcode = (int) $data;
|
$this->fallbackExitcode = (int) $data;
|
||||||
} else {
|
} else {
|
||||||
call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data);
|
$callback($type === self::STDOUT ? self::OUT : self::ERR, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -747,7 +747,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$process = $this->getProcess('php -m');
|
$process = $this->getProcess('php -m');
|
||||||
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
|
$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()
|
public function provideMethodsThatNeedARunningProcess()
|
||||||
@ -769,7 +769,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
|||||||
$process = $this->getProcess('php -r "sleep(1);"');
|
$process = $this->getProcess('php -r "sleep(1);"');
|
||||||
$process->start();
|
$process->start();
|
||||||
try {
|
try {
|
||||||
call_user_func(array($process, $method));
|
$process->{$method}();
|
||||||
$process->stop(0);
|
$process->stop(0);
|
||||||
$this->fail('A LogicException must have been thrown');
|
$this->fail('A LogicException must have been thrown');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -37,7 +37,7 @@ class ClosureLoader extends Loader
|
|||||||
*/
|
*/
|
||||||
public function load($closure, $type = null)
|
public function load($closure, $type = null)
|
||||||
{
|
{
|
||||||
return call_user_func($closure);
|
return $closure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +43,9 @@ class CallbackValidator extends ConstraintValidator
|
|||||||
$methods = $constraint->methods;
|
$methods = $constraint->methods;
|
||||||
|
|
||||||
foreach ($methods as $method) {
|
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)) {
|
if (!is_callable($method)) {
|
||||||
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
|
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,12 @@ class ChoiceValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($constraint->callback) {
|
if ($constraint->callback) {
|
||||||
if (is_callable(array($this->context->getClassName(), $constraint->callback))) {
|
if (!is_callable($choices = array($this->context->getClassName(), $constraint->callback))
|
||||||
$choices = call_user_func(array($this->context->getClassName(), $constraint->callback));
|
&& !is_callable($choices = $constraint->callback)
|
||||||
} elseif (is_callable($constraint->callback)) {
|
) {
|
||||||
$choices = call_user_func($constraint->callback);
|
|
||||||
} else {
|
|
||||||
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback');
|
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback');
|
||||||
}
|
}
|
||||||
|
$choices = call_user_func($choices);
|
||||||
} else {
|
} else {
|
||||||
$choices = $constraint->choices;
|
$choices = $constraint->choices;
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ class TypeValidator extends ConstraintValidator
|
|||||||
$isFunction = 'is_'.$type;
|
$isFunction = 'is_'.$type;
|
||||||
$ctypeFunction = 'ctype_'.$type;
|
$ctypeFunction = 'ctype_'.$type;
|
||||||
|
|
||||||
if (function_exists($isFunction) && call_user_func($isFunction, $value)) {
|
if (function_exists($isFunction) && $isFunction($value)) {
|
||||||
return;
|
return;
|
||||||
} elseif (function_exists($ctypeFunction) && call_user_func($ctypeFunction, $value)) {
|
} elseif (function_exists($ctypeFunction) && $ctypeFunction($value)) {
|
||||||
return;
|
return;
|
||||||
} elseif ($value instanceof $constraint->type) {
|
} elseif ($value instanceof $constraint->type) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user