Oihana PHP

isCallable.php

Table of Contents

Functions

isCallable()  : bool
Checks whether a string can be resolved into a valid callable.

Functions

isCallable()

Checks whether a string can be resolved into a valid callable.

isCallable(string $callable) : bool

This is a convenience wrapper around resolveCallable() that returns a boolean instead of the callable itself. Useful for validation or conditional logic.

Supports the same callable formats as resolveCallable():

  • Fully qualified function names: 'oihana\core\normalize'
  • Static method notation: 'MyClass::method' or 'MyNamespace\MyClass::method'
Parameters
$callable : string

The callable as a string to check

Tags
see
resolveCallable()
example
use function oihana\core\callables\isCallable;

if (isCallable('oihana\core\normalize')) {
    // Safe to use the function
}

if (isCallable('MyClass::transform')) {
    // Safe to call the static method
}

if (!isCallable('nonexistent\function')) {
    // Handle missing function
}
author

Marc Alcaraz (ekameleon)

since
1.0.7
Return values
bool

True if the callable can be resolved, false otherwise


        
On this page

Search results