[PHP 8.1] Add get/hasTentativeReturnType functions (#1615)

Closes #1614

Co-authored-by: Máté Kocsis <kocsismate@woohoolabs.com>
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
This commit is contained in:
Sergey Panteleev 2022-06-06 16:07:48 +03:00 committed by GitHub
parent 4586854a24
commit 38f5bb6cc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 175 additions and 0 deletions

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="reflectionfunctionabstract.gettentativereturntype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionFunctionAbstract::getTentativeReturnType</refname>
<refpurpose>Returns the tentative return type associated with the function</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type class="union"><type>ReflectionType</type><type>null</type></type><methodname>ReflectionFunctionAbstract::getTentativeReturnType</methodname>
<void/>
</methodsynopsis>
<para>
Returns the tentative return type associated with the function.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a <classname>ReflectionType</classname> object if a tentative return type is
specified, &null; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunctionAbstract::getTentativeReturnType</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
$method = new ReflectionMethod(\ArrayAccess::class, 'offsetGet');
var_dump($method->getTentativeReturnType());
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
object(ReflectionNamedType)#2 (0) {
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>ReflectionFunctionAbstract::getReturnType</methodname></member>
<member><methodname>ReflectionFunctionAbstract::hasTentativeReturnType</methodname></member>
<member><link linkend="language.oop5.inheritance.internal-classes">Return Type Compatibility with Internal Classes</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
-->

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="reflectionfunctionabstract.hastentativereturntype" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>ReflectionFunctionAbstract::hasTentativeReturnType</refname>
<refpurpose>Returns whether the function has a tentative return type</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>bool</type><methodname>ReflectionFunctionAbstract::hasTentativeReturnType</methodname>
<void />
</methodsynopsis>
<para>
Returns whether the function has a tentative return type.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if the function has a tentative return type, otherwise &false;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionFunctionAbstract::hasTentativeReturnType</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
$method = new ReflectionMethod(\ArrayAccess::class, 'offsetGet');
var_dump($method->hasTentativeReturnType());
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>ReflectionFunctionAbstract::getTentativeReturnType</methodname></member>
<member><methodname>ReflectionFunctionAbstract::hasReturnType</methodname></member>
<member><link linkend="language.oop5.inheritance.internal-classes">Return Type Compatibility with Internal Classes</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
-->

View file

@ -53,7 +53,9 @@
<function name="reflectionfunctionabstract::getshortname" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="reflectionfunctionabstract::getstartline" from="PHP 5 &gt;= 5.2.0, PHP 7, PHP 8"/>
<function name="reflectionfunctionabstract::getstaticvariables" from="PHP 5 &gt;= 5.2.0, PHP 7, PHP 8"/>
<function name="reflectionfunctionabstract::gettentativereturntype" from="PHP 8 &gt;= 8.1.0"/>
<function name="reflectionfunctionabstract::returnsreference" from="PHP 5 &gt;= 5.2.0, PHP 7, PHP 8"/>
<function name="reflectionfunctionabstract::hastentativereturntype" from="PHP 8 &gt;= 8.1.0"/>
<function name="reflectionfunctionabstract::hasreturntype" from="PHP 7, PHP 8"/>
<function name="reflectionfunctionabstract::getreturntype" from="PHP 7, PHP 8"/>
<function name="reflectionfunctionabstract::getattributes" from="PHP 8"/>