Skip to content

Document #[\Deprecated] #3894

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 6 commits into from
Oct 22, 2024
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
1 change: 1 addition & 0 deletions language/predefined/attributes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

&language.predefined.attributes.attribute;
&language.predefined.attributes.allowdynamicproperties;
&language.predefined.attributes.deprecated;
&language.predefined.attributes.override;
&language.predefined.attributes.returntypewillchange;
&language.predefined.attributes.sensitiveparameter;
Expand Down
138 changes: 138 additions & 0 deletions language/predefined/attributes/deprecated.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<reference xml:id="class.deprecated" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Deprecated attribute</title>
<titleabbrev>Deprecated</titleabbrev>

<partintro>

<section xml:id="deprecated.intro">
&reftitle.intro;
<simpara>
This attribute is used to mark functionality as deprecated.
Using deprecated functionality will cause an <constant>E_USER_DEPRECATED</constant> error to be emitted.
</simpara>
</section>

<section xml:id="deprecated.synopsis">
&reftitle.classsynopsis;

<classsynopsis class="class">
<ooclass>
<modifier>final</modifier>
<classname>Deprecated</classname>
</ooclass>

<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
<fieldsynopsis>
<modifier>public</modifier>
<modifier>readonly</modifier>
<type class="union"><type>string</type><type>null</type></type>
<varname linkend="deprecated.props.message">message</varname>
</fieldsynopsis>
<fieldsynopsis>
<modifier>public</modifier>
<modifier>readonly</modifier>
<type class="union"><type>string</type><type>null</type></type>
<varname linkend="deprecated.props.since">since</varname>
</fieldsynopsis>

<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.deprecated')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='Deprecated'])">
<xi:fallback/>
</xi:include>
</classsynopsis>
</section>

<section xml:id="deprecated.props">
&reftitle.properties;
<variablelist>
<varlistentry xml:id="deprecated.props.message">
<term><varname>message</varname></term>
<listitem>
<para>
An optional message explaining the reason for the deprecation and possible replacement functionality.
Will be included in the emitted deprecation message.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="deprecated.props.since">
<term><varname>since</varname></term>
<listitem>
<para>
An optional string indicating since when the functionality is deprecated.
The contents are not validated by PHP and may contain a version number,
a date or any other value that is considered appropriate.
Will be included in the emitted deprecation message.
</para>
<para>
Functionality that is part of PHP will use Major.Minor as the <varname>since</varname> value,
for example <literal>'8.4'</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>

<section>
&reftitle.examples;
<informalexample>
<programlisting role="php">
<![CDATA[
<?php

#[\Deprecated(message: "use safe_replacement() instead", since: "1.5")]
function unsafe_function()
{
echo "This is unsafe", PHP_EOL;
}

unsafe_function();

?>
]]>
</programlisting>
&example.outputs.84.similar;
<screen>
<![CDATA[
Deprecated: Function unsafe_function() is deprecated since 1.5, use safe_replacement() instead in example.php on line 9
This is unsafe
]]>
</screen>
</informalexample>
</section>

<section xml:id="deprecated.seealso">
&reftitle.seealso;
<simplelist>
<member><link linkend="language.attributes">Attributes overview</link></member>
<member><methodname>ReflectionFunctionAbstract::isDeprecated</methodname></member>
<member><methodname>ReflectionClassConstant::isDeprecated</methodname></member>
<member><constant>E_USER_DEPRECATED</constant></member>
</simplelist>
</section>

</partintro>

&language.predefined.attributes.deprecated.construct;

</reference>
<!-- 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
-->
61 changes: 61 additions & 0 deletions language/predefined/attributes/deprecated/construct.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="deprecated.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Deprecated::__construct</refname>
<refpurpose>Construct a new Deprecated attribute instance</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<constructorsynopsis role="Deprecated">
<modifier>public</modifier> <methodname>Deprecated::__construct</methodname>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>message</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>since</parameter><initializer>&null;</initializer></methodparam>
</constructorsynopsis>
<simpara>
Constructs a new <classname>Deprecated</classname> instance.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>message</parameter></term>
<listitem>
<para>
The value of the <property linkend="deprecated.props.message">message</property> property.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>since</parameter></term>
<listitem>
<para>
The value of the <property linkend="deprecated.props.since">since</property> property.
</para>
</listitem>
</varlistentry>
</variablelist>
</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 language/predefined/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
<function name="SensitiveParameterValue::getValue" from="PHP 8 &gt;= 8.2.0"/>
<function name="Override" from="PHP 8 &gt;= 8.3.0"/>
<function name="Override::__construct" from="PHP 8 &gt;= 8.3.0"/>
<function name="Deprecated" from="PHP 8 &gt;= 8.4.0"/>
<function name="Deprecated::__construct" from="PHP 8 &gt;= 8.4.0"/>
<function name="__PHP_Incomplete_Class" from="PHP 4 &gt;=4.0.1, PHP 5, PHP 7, PHP 8"/>
</versions>
<!-- Keep this comment at the end of the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ bool(true)
&reftitle.seealso;
<para>
<simplelist>
<member><classname>Deprecated</classname></member>
<member><methodname>ReflectionFunctionAbstract::getDocComment</methodname></member>
</simplelist>
</para>
Expand Down