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

157
174
<refsect1 role="seealso">
158
175
&reftitle.seealso;
159
176
<para>
...
...
@@ -165,7 +182,6 @@ bool(false)
165
182
</refsect1>
166
183

167
184
</refentry>
168
-

169
185
<!-- Keep this comment at the end of the file
170
186
Local variables:
171
187
mode: sgml
172
188