isCallableWithParams.php
Table of Contents
Functions
- isCallableWithParams() : bool
- Check if an array represents a callable with parameters in simplified syntax.
Functions
isCallableWithParams()
Check if an array represents a callable with parameters in simplified syntax.
isCallableWithParams(array<string|int, mixed> $array[, array<string|int, mixed>|null $validNames = null ]) : bool
Distinguishes between:
- ['substring', 0, 3] → callable with params (true)
- ['trim', 'lower'] → chain of callables (false)
- [['trim', 1], 'lower'] → chain of callables (false)
- ['lower'] → single callable without params (false)
This is useful for supporting simplified syntax in configurations:
- Simplified: ['functionName', param1, param2]
- Explicit: [['functionName', param1, param2]]
Detection Rules:
- Must have at least 2 elements (callable name + at least one param)
- First element must be a string (callable name)
- Optionally validate against a list of known callable names
- If second element is also a known callable name → it's a chain (false)
- If second element is an array → it's a chain (false)
- Otherwise → it's a callable with params (true)
Parameters
- $array : array<string|int, mixed>
-
Array to check
- $validNames : array<string|int, mixed>|null = null
-
Optional list of valid callable names to validate against. If provided, both the first element and second element (if string) will be checked against this list.
Tags
Return values
bool —True if it's a single callable with parameters