本文整理汇总了PHP中Webmozart\Assert\Assert::isCallable方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isCallable方法的具体用法?PHP Assert::isCallable怎么用?PHP Assert::isCallable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::isCallable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoke
/**
* Handle the callback.
*
* @param array|callable $callback Callback as Contao array notation or as PHP callable.
* @param array $arguments List of arguments being passed to the callback.
*
* @return mixed
* @throws InvalidArgumentException On callback is not callable.
*/
public function invoke($callback, array $arguments = [])
{
if (is_array($callback)) {
$callback[0] = \System::importStatic($callback[0]);
}
Assert::isCallable($callback);
return call_user_func_array($callback, $arguments);
}
示例2: addListener
/**
* @param callable $listener
*/
public function addListener($listener)
{
Assert::isCallable($listener, '$listener expected a callable in NativeEventDispatcher::addListener(). Got: %s');
$this->listeners[] = $listener;
}
示例3: __construct
/**
* Creates the command handler.
*
* The passed callback receives three arguments:
*
* * {@link Args} `$args`: The console arguments.
* * {@link IO} `$io`: The I/O.
* * {@link Command} `$command`: The executed command.
*
* The callable should return 0 on success and a positive integer on error.
*
* @param callable $callback The callback to execute when handling a
* command.
*/
public function __construct($callback)
{
Assert::isCallable($callback);
$this->callback = $callback;
}
示例4: register
/**
* Registers a command handler for the given name.
*
* @param string $name The handler name.
* @param object|callable $handler The handler or a factory callback that
* creates the handler.
*/
public function register($name, $handler)
{
Assert::string($name, 'The handler name must be a string. Got: %s');
Assert::notEmpty($name, 'The handler name must not be empty.');
if (!is_object($handler)) {
Assert::isCallable($handler, 'The handler must be a callable or an object. Got: %s');
}
$this->handlers[$name] = $handler;
if (!$this->selectedHandler) {
$this->selectedHandler = $name;
}
}