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 throw new BadMethodCallException('Expectation value is not iterable.');
}
if (is_callable($callback)) {
foreach ($this->value as $key => $item) {
$callback(new self($item), $key);
}
<?php $matched = true;
if (is_callable($callback)) {
$callback(new self($this->value));
continue;
<?php public function unless(callable|bool $condition, callable $callback): Expectation
{
$condition = is_callable($condition)
? $condition
: static fn (): bool => $condition;
<?php public function when(callable|bool $condition, callable $callback): self
{
$condition = is_callable($condition)
? $condition
: static fn (): bool => $condition;
<?php public function throwsIf(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
{
$condition = is_callable($condition)
? $condition
: static fn (): bool => $condition;
<?php public function throwsUnless(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
{
$condition = is_callable($condition)
? $condition
: static fn (): bool => $condition;
<?php ? NullClosure::create()
: $conditionOrMessage;
$condition = is_callable($condition)
? $condition
: fn (): bool => $condition;
<?php $datasets[$index] = self::getScopedDataset($data, $currentTestFile);
}
if (is_callable($datasets[$index])) {
$datasets[$index] = call_user_func($datasets[$index]);
}
<?php public function call(object $target): mixed
{
if (is_callable($this->condition) && call_user_func(Closure::bind($this->condition, $target)) === false) {
return $target;
}
<?php return $object->__call($method, $args);
}
if (is_callable($method)) {
return self::bindCallable($method, $args);
}