Value of type %s is not callable¶
Description¶
There was an attempt to call a function whose name was provided in a variable, but that value could not be related to a callable code.
null
: not a callabletrue
,false
: booleans are not callableint
: integers are not callablefloat
: float are not callablearray
: arrays are callable when they have two elements, with keys 0 and 1. First one is a class or an object of that class, the second is a string with a visible method name on that class. Otherwise, they are not valid callables.string
: strings are callable when they represent a function, with the leading backslash,\strlen
, or a method, with a class name, a double colon::
, and a visible method name. Otherwise, they are not valid callables.object
: object are callable when their class has a__invoke
method. This might be through a parent, likeClosure
. Otherwise, objects are not callable, although their method are.
All of these may be checked with a call to is_callable()
on the variable, before using it.
Example¶
<?php
$method = null;
$method();
?>
Literal Examples¶
Value of type int is not callable
Value of type bool is not callable
Value of type string is not callable
Value of type float is not callable
Solutions¶
Check the variable with
is_callable()
, before using it with the call syntax.Use one of the available format.