Skip to content

Commit 607f58c

Browse files
committed
[PHP 8.2] Add ReflectionFunction::isAnonymous and ReflectionMethod::hasPrototype methods
1 parent b9ba390 commit 607f58c

File tree

4 files changed

+190
-2
lines changed

4 files changed

+190
-2
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="reflectionfunction.isanonymous" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<refnamediv>
4+
<refname>ReflectionFunction::isAnonymous</refname>
5+
<refpurpose>Checks if function is anonymous</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis>
11+
<modifier>public</modifier> <type>bool</type><methodname>ReflectionFunction::isAnonymous</methodname>
12+
<void />
13+
</methodsynopsis>
14+
<para>
15+
Checks if function is <link linkend="functions.anonymous">anonymous</link>.
16+
</para>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
&no.function.parameters;
22+
</refsect1>
23+
24+
<refsect1 role="returnvalues">
25+
&reftitle.returnvalues;
26+
<para>
27+
Returns &true; if function is anonymous, otherwise &false;.
28+
</para>
29+
</refsect1>
30+
31+
<refsect1 role="examples">
32+
&reftitle.examples;
33+
<para>
34+
<example>
35+
<title><methodname>ReflectionMethod::getPrototype</methodname> example</title>
36+
<programlisting role="php">
37+
<![CDATA[
38+
<?php
39+
40+
$rf = new ReflectionFunction(function() {});
41+
var_dump($rf->isAnonymous());
42+
43+
$rf = new ReflectionFunction('strlen');
44+
var_dump($rf->isAnonymous());
45+
?>
46+
]]>
47+
</programlisting>
48+
&example.outputs;
49+
<screen>
50+
<![CDATA[
51+
bool(true)
52+
bool(false)
53+
]]>
54+
</screen>
55+
</example>
56+
</para>
57+
</refsect1>
58+
59+
<refsect1 role="seealso">
60+
&reftitle.seealso;
61+
<para>
62+
<simplelist>
63+
<member><link linkend="functions.anonymous">Anonymous functions</link></member>
64+
</simplelist>
65+
</para>
66+
</refsect1>
67+
68+
</refentry>
69+
<!-- Keep this comment at the end of the file
70+
Local variables:
71+
mode: sgml
72+
sgml-omittag:t
73+
sgml-shorttag:t
74+
sgml-minimize-attributes:nil
75+
sgml-always-quote-attributes:t
76+
sgml-indent-step:1
77+
sgml-indent-data:t
78+
indent-tabs-mode:nil
79+
sgml-parent-document:nil
80+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
81+
sgml-exposed-tags:nil
82+
sgml-local-catalogs:nil
83+
sgml-local-ecat-files:nil
84+
End:
85+
vim600: syn=xml fen fdm=syntax fdl=2 si
86+
vim: et tw=78 syn=sgml
87+
vi: ts=1 sw=1
88+
-->

reference/reflection/reflectionmethod/getprototype.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
43
<refentry xml:id="reflectionmethod.getprototype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
54
<refnamediv>
65
<refname>ReflectionMethod::getPrototype</refname>
@@ -87,12 +86,12 @@ object(ReflectionMethod)#2 (2) {
8786
<para>
8887
<simplelist>
8988
<member><methodname>ReflectionMethod::getModifiers</methodname></member>
89+
<member><methodname>ReflectionMethod::hasPrototype</methodname></member>
9090
</simplelist>
9191
</para>
9292
</refsect1>
9393

9494
</refentry>
95-
9695
<!-- Keep this comment at the end of the file
9796
Local variables:
9897
mode: sgml
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="reflectionmethod.hasprototype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<refnamediv>
4+
<refname>ReflectionMethod::hasPrototype</refname>
5+
<refpurpose>Returns whether method has a prototype</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis>
11+
<modifier>public</modifier> <type>bool</type><methodname>ReflectionMethod::hasPrototype</methodname>
12+
<void />
13+
</methodsynopsis>
14+
<para>
15+
Returns whether method has a prototype.
16+
</para>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
&no.function.parameters;
22+
</refsect1>
23+
24+
<refsect1 role="returnvalues">
25+
&reftitle.returnvalues;
26+
<para>
27+
Returns &true; if method has a prototype, otherwise &false;.
28+
</para>
29+
</refsect1>
30+
31+
<refsect1 role="examples">
32+
&reftitle.examples;
33+
<para>
34+
<example>
35+
<title><methodname>ReflectionMethod::hasPrototype</methodname> example</title>
36+
<programlisting role="php">
37+
<![CDATA[
38+
<?php
39+
40+
class Hello
41+
{
42+
public function sayHelloTo($name)
43+
{
44+
return 'Hello '.$name;
45+
}
46+
}
47+
48+
class HelloWorld extends Hello
49+
{
50+
public function sayHelloTo($name)
51+
{
52+
return 'Hello world: '.$name;
53+
}
54+
}
55+
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
56+
var_dump($reflectionMethod->hasPrototype());
57+
?>
58+
]]>
59+
</programlisting>
60+
&example.outputs;
61+
<screen>
62+
<![CDATA[
63+
bool(true)
64+
]]>
65+
</screen>
66+
</example>
67+
</para>
68+
</refsect1>
69+
70+
<refsect1 role="seealso">
71+
&reftitle.seealso;
72+
<para>
73+
<simplelist>
74+
<member><methodname>ReflectionMethod::getPrototype</methodname></member>
75+
</simplelist>
76+
</para>
77+
</refsect1>
78+
79+
</refentry>
80+
<!-- Keep this comment at the end of the file
81+
Local variables:
82+
mode: sgml
83+
sgml-omittag:t
84+
sgml-shorttag:t
85+
sgml-minimize-attributes:nil
86+
sgml-always-quote-attributes:t
87+
sgml-indent-step:1
88+
sgml-indent-data:t
89+
indent-tabs-mode:nil
90+
sgml-parent-document:nil
91+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
92+
sgml-exposed-tags:nil
93+
sgml-local-catalogs:nil
94+
sgml-local-ecat-files:nil
95+
End:
96+
vim600: syn=xml fen fdm=syntax fdl=2 si
97+
vim: et tw=78 syn=sgml
98+
vi: ts=1 sw=1
99+
-->

reference/reflection/versions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<function name="reflectionfunction::invoke" from="PHP 5, PHP 7, PHP 8"/>
7171
<function name="reflectionfunction::invokeargs" from="PHP 5 &gt;= 5.1.2, PHP 7, PHP 8"/>
7272
<function name="reflectionfunction::innamespace" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
73+
<function name="reflectionfunction::isanonymous" from="PHP 8 &gt;= 8.2.0"/>
7374
<function name="reflectionfunction::isclosure" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
7475
<function name="reflectionfunction::isdeprecated" from="PHP 5 &gt;= 5.1.3, PHP 7, PHP 8"/>
7576
<function name="reflectionfunction::isinternal" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
@@ -135,6 +136,7 @@
135136
<function name="reflectionmethod::invokeargs" from="PHP 5 &gt;= 5.1.2, PHP 7, PHP 8"/>
136137
<function name="reflectionmethod::getdeclaringclass" from="PHP 5, PHP 7, PHP 8"/>
137138
<function name="reflectionmethod::getprototype" from="PHP 5 &gt;= 5.1.2, PHP 7, PHP 8"/>
139+
<function name="reflectionmethod::hasprototype" from="PHP 8 &gt;= 8.2.0"/>
138140
<function name="reflectionmethod::innamespace" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
139141
<function name="reflectionmethod::isclosure" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
140142
<function name="reflectionmethod::isdeprecated" from="PHP 5, PHP 7, PHP 8"/>

0 commit comments

Comments
 (0)