Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Verify that a value can be called as a function from the current scope.
<?php is_callable(mixed $value, bool $syntax_only = false, string &$callable_name = null): bool
<?php $callback = $callback[0].'@'.$callback[1];
}
if (is_callable($callback)) {
$this->abilities[$ability] = $callback;
} elseif (is_string($callback)) {
$this->stringCallbacks[$ability] = $callback;
<?php protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
{
if (! is_callable([$policy, $this->formatAbilityToMethod($ability)])) {
return false;
}
<?php array_shift($arguments);
}
if (! is_callable([$policy, $method])) {
return;
}
<?php protected function extractParameters($callback)
{
if (is_callable($callback)) {
return (new ReflectionFunction($callback))->getParameters();
} elseif (is_string($callback)) {
return $this->extractParametersFromClass($callback);
<?php protected function normalizeChannelHandlerToCallable($callback)
{
return is_callable($callback) ? $callback : function (...$args) use ($callback) {
return Container::getInstance()
->make($callback)
->join(...$args);
<?php {
$result = $this->acquire();
if ($result && is_callable($callback)) {
try {
return $callback();
} finally {
<?php }
}
if (is_callable($callback)) {
try {
return $callback();
} finally {
<?php return Arr::random($this->items);
}
if (is_callable($number)) {
return new static(Arr::random($this->items, $number($this), $preserveKeys));
}
<?php {
$items = $this->items;
$callback && is_callable($callback)
? uasort($items, $callback)
: asort($items, $callback ?? SORT_REGULAR);
<?php public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
{
if (is_array($callback) && ! is_callable($callback)) {
return $this->sortByMany($callback, $options);
}
<?php $ascending = Arr::get($comparison, 1, true) === true ||
Arr::get($comparison, 1, true) === 'asc';
if (! is_string($prop) && is_callable($prop)) {
$result = $prop($a, $b);
} else {
$values = [data_get($a, $prop), data_get($b, $prop)];
<?php public function sortByDesc($callback, $options = SORT_REGULAR)
{
if (is_array($callback) && ! is_callable($callback)) {
foreach ($callback as $index => $key) {
$comparison = Arr::wrap($key);
<?php return new ArrayIterator($source);
}
if (is_callable($source)) {
$maybeTraversable = $source();
return $maybeTraversable instanceof Traversable
<?php protected function useAsCallable($value)
{
return ! is_string($value) && is_callable($value);
}
<?php }
}
$error = is_callable($validate) ? $validate($result) : $this->validatePrompt($result, $validate);
if (is_string($error) && strlen($error) > 0) {
$this->components->error($error);