Skip to content

[PHP 8.2] Add ReflectionFunction::isAnonymous and ReflectionMethod::hasPrototype methods #1742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions reference/reflection/reflectionfunction/isanonymous.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="reflectionfunction.isanonymous" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionFunction::isAnonymous</refname>
<refpurpose>Checks if a function is anonymous</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>bool</type><methodname>ReflectionFunction::isAnonymous</methodname>
<void />
</methodsynopsis>
<para>
Checks if a function is <link linkend="functions.anonymous">anonymous</link>.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if the function is anonymous, otherwise &false;.
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunction::isAnonymous</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php

$rf = new ReflectionFunction(function() {});
var_dump($rf->isAnonymous());

$rf = new ReflectionFunction('strlen');
var_dump($rf->isAnonymous());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
]]>
</screen>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="functions.anonymous">Anonymous functions</link></member>
</simplelist>
</para>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
3 changes: 1 addition & 2 deletions reference/reflection/reflectionmethod/getprototype.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="reflectionmethod.getprototype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::getPrototype</refname>
Expand Down Expand Up @@ -87,12 +86,12 @@ object(ReflectionMethod)#2 (2) {
<para>
<simplelist>
<member><methodname>ReflectionMethod::getModifiers</methodname></member>
<member><methodname>ReflectionMethod::hasPrototype</methodname></member>
</simplelist>
</para>
</refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
99 changes: 99 additions & 0 deletions reference/reflection/reflectionmethod/hasprototype.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="reflectionmethod.hasprototype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionMethod::hasPrototype</refname>
<refpurpose>Returns whether a method has a prototype</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>bool</type><methodname>ReflectionMethod::hasPrototype</methodname>
<void/>
</methodsynopsis>
<para>
Returns whether a method has a prototype.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if the method has a prototype, otherwise &false;.
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionMethod::hasPrototype</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php

class Hello
{
public function sayHelloTo($name)
{
return 'Hello '.$name;
}
}

class HelloWorld extends Hello
{
public function sayHelloTo($name)
{
return 'Hello world: '.$name;
}
}
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
var_dump($reflectionMethod->hasPrototype());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>ReflectionMethod::getPrototype</methodname></member>
</simplelist>
</para>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
2 changes: 2 additions & 0 deletions reference/reflection/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<function name="reflectionfunction::invoke" from="PHP 5, PHP 7, PHP 8"/>
<function name="reflectionfunction::invokeargs" from="PHP 5 &gt;= 5.1.2, PHP 7, PHP 8"/>
<function name="reflectionfunction::innamespace" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="reflectionfunction::isanonymous" from="PHP 8 &gt;= 8.2.0"/>
<function name="reflectionfunction::isclosure" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="reflectionfunction::isdeprecated" from="PHP 5 &gt;= 5.1.3, PHP 7, PHP 8"/>
<function name="reflectionfunction::isinternal" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
Expand Down Expand Up @@ -135,6 +136,7 @@
<function name="reflectionmethod::invokeargs" from="PHP 5 &gt;= 5.1.2, PHP 7, PHP 8"/>
<function name="reflectionmethod::getdeclaringclass" from="PHP 5, PHP 7, PHP 8"/>
<function name="reflectionmethod::getprototype" from="PHP 5 &gt;= 5.1.2, PHP 7, PHP 8"/>
<function name="reflectionmethod::hasprototype" from="PHP 8 &gt;= 8.2.0"/>
<function name="reflectionmethod::innamespace" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="reflectionmethod::isclosure" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="reflectionmethod::isdeprecated" from="PHP 5, PHP 7, PHP 8"/>
Expand Down