reference/var/functions/is-callable.xml
83a17a7324c2597bd6385148abf19f76127229f5
...
...
@@ -4,7 +4,7 @@
4
4
<refnamediv>
5
5
<refname>is_callable</refname>
6
6
<refpurpose>
7
-
Verify that the contents of a variable can be called as a function
7
+
Verify that a value can be called as a function from the current scope.
8
8
</refpurpose>
9
9
</refnamediv>
10
10

...
...
@@ -12,15 +12,12 @@
12
12
&reftitle.description;
13
13
<methodsynopsis>
14
14
<type>bool</type><methodname>is_callable</methodname>
15
-
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
15
+
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
16
16
<methodparam choice="opt"><type>bool</type><parameter>syntax_only</parameter><initializer>&false;</initializer></methodparam>
17
-
<methodparam choice="opt"><type>string</type><parameter role="reference">callable_name</parameter></methodparam>
17
+
<methodparam choice="opt"><type>string</type><parameter role="reference">callable_name</parameter><initializer>&null;</initializer></methodparam>
18
18
</methodsynopsis>
19
19
<para>
20
-
Verify that the contents of a variable can be called as a function.
21
-
This can check that a simple variable contains the name of a valid
22
-
function, or that an array contains a properly encoded object and
23
-
function name.
20
+
Verify that a value is a <type>callable</type>.
24
21
</para>
25
22
</refsect1>
26
23

...
...
@@ -29,7 +26,7 @@
29
26
<para>
30
27
<variablelist>
31
28
<varlistentry>
32
-
<term><parameter>var</parameter></term>
29
+
<term><parameter>value</parameter></term>
33
30
<listitem>
34
31
<para>
35
32
The value to check
...
...
@@ -41,7 +38,7 @@
41
38
<listitem>
42
39
<para>
43
40
If set to &true; the function only verifies that
44
-
<parameter>name</parameter> might be a function or method. It will only
41
+
<parameter>value</parameter> might be a function or method. It will only
45
42
reject simple variables that are not strings, or an array that does
46
43
not have a valid structure to be used as a callback. The valid ones
47
44
are supposed to have only 2 entries, the first of which is an object
...
...
@@ -67,7 +64,7 @@
67
64
<refsect1 role="returnvalues">
68
65
&reftitle.returnvalues;
69
66
<para>
70
-
Returns &true; if <parameter>var</parameter> is callable, &false;
67
+
Returns &true; if <parameter>value</parameter> is callable, &false;
71
68
otherwise.
72
69
</para>
73
70
</refsect1>
...
...
@@ -124,11 +121,8 @@ echo $callable_name, "\n"; // someClass::someMethod
124
121
<example>
125
122
<title><function>is_callable</function> and constructors</title>
126
123
<simpara>
127
-
As of PHP 5.3.0 <function>is_callable</function> reports constructors as
128
-
not being callable. This affects PHP 5 style constructors
129
-
(<literal>__construct</literal>) as well as PHP 4 style constructors (i.e.
130
-
methods with the same name as the class). Formerly, both cases have been
131
-
considered callable.
124
+
<function>is_callable</function> reports constructors as
125
+
not being callable.
132
126
</simpara>
133
127
<programlisting role="php">
134
128
<![CDATA[
...
...
@@ -157,6 +151,26 @@ bool(false)
157
151
</para>
158
152
</refsect1>
159
153

154
+
<refsect1 role="notes">
155
+
&reftitle.notes;
156
+
<simplelist>
157
+
<member>
158
+
An object is always callable if it implements <link linkend="object.invoke">__invoke()</link>,
159
+
and that method is visible in the current scope.
160
+
</member>
161
+
<member>
162
+
A class name is callable if it implements <link linkend="object.callstatic">__callStatic()</link>.
163
+
</member>
164
+
<member>
165
+
If an object implements <link linkend="object.call">__call()</link>, then this function will
166
+
return &true; for any method on that object, even if the method is not defined.
167
+
</member>
168
+
<member>
169
+
This function may trigger autoloading if called with the name of a class.
170
+
</member>
171
+
</simplelist>
172
+
</refsect1>
173
+

160
174
<refsect1 role="seealso">
161
175
&reftitle.seealso;
162
176
<para>
...
...
@@ -168,7 +182,6 @@ bool(false)
168
182
</refsect1>
169
183

170
184
</refentry>
171
-

172
185
<!-- Keep this comment at the end of the file
173
186
Local variables:
174
187
mode: sgml
175
188