for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SmartWeb\ModuleTesting\ExpressionLanguage\Functions;
use Closure;
use SmartWeb\ModuleTesting\Contracts\ExpressionLanguage\Validator;
use SmartWeb\ModuleTesting\ExpressionLanguage\CallbackValidator;
use function call_user_func_array;
/**
* Expression function for invoking custom callbacks
*
* @package SmartWeb\ModuleTesting\ExpressionLanguage\Functions
*/
class Call extends BaseExpressionFunction
{
* @var Validator
private $callbackValidator;
* @inheritDoc
protected function init()
$this->callbackValidator = new CallbackValidator("ExpressionFunction '{$this->getName()}' expects parameter 1 to be a valid callback");
}
protected function provideCompiler() : callable
return function (...$args) : string
return sprintf('call_user_func(%s)', implode(', ', $args));
};
protected function provideEvaluator() : callable
* @param array $arguments
* @param callable|Closure $callback
* @return mixed
$evaluator = function (array $arguments, $callback)
$this->callbackValidator->validate($callback);
return call_user_func_array($callback, $arguments['params']);
return $evaluator;