[doc-en] master: PHP 8.6: Document SortDirection enum (#6095)
| From: | Jordi Kroon via GitHub | Date: | Mon, 16 Nov 2026 20:46:01 +0000 |
| Subject: | [doc-en] master: PHP 8.6: Document SortDirection enum (#6095) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23967@lists.php.net to get a copy of this message | ||
Author: Jordi Kroon (jordikroon)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-11-16T21:45:58+01:00
Commit: https://github.com/php/doc-en/commit/c67cecc4b6f71010084869cecd7560bc5c8494a7
Raw diff: https://github.com/php/doc-en/commit/c67cecc4b6f71010084869cecd7560bc5c8494a7.diff
PHP 8.6: Document SortDirection enum (#6095)
Changed paths:
A language/predefined/sortdirection.xml
M language/predefined/interfaces.xml
M language/predefined/versions.xml
Diff:
diff --git a/language/predefined/interfaces.xml b/language/predefined/interfaces.xml
index 614ce57b5cb0..6b3c84a7f4ca 100644
--- a/language/predefined/interfaces.xml
+++ b/language/predefined/interfaces.xml
@@ -29,6 +29,7 @@
&language.predefined.stringable;
&language.predefined.unitenum;
&language.predefined.backedenum;
+ &language.predefined.sortdirection;
&language.predefined.sensitiveparametervalue;
&language.predefined.php-incomplete-class;
diff --git a/language/predefined/sortdirection.xml b/language/predefined/sortdirection.xml
new file mode 100644
index 000000000000..aeb18aac481a
--- /dev/null
+++ b/language/predefined/sortdirection.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<reference xml:id="enum.sortdirection" role="enum" xmlns="http://docbook.org/ns/docbook">
+ <title>The SortDirection enum</title>
+ <titleabbrev>SortDirection</titleabbrev>
+
+ <partintro>
+ <section xml:id="enum.sortdirection.intro">
+ &reftitle.intro;
+ <simpara>
+ The <enumname>SortDirection</enumname> enum is used to specify the
+ direction in which values are sorted.
+ </simpara>
+ <note>
+ <simpara>
+ As of PHP 8.6.0, none of the functions bundled with PHP accept a
+ <enumname>SortDirection</enumname>. For example,
+ <function>array_multisort</function> still expects
+ <constant>SORT_ASC</constant> or <constant>SORT_DESC</constant>.
+ </simpara>
+ </note>
+ </section>
+
+ <section xml:id="enum.sortdirection.synopsis">
+ &reftitle.enumsynopsis;
+
+ <enumsynopsis>
+ <enumname>SortDirection</enumname>
+
+ <enumitem>
+ <enumidentifier>Ascending</enumidentifier>
+ </enumitem>
+
+ <enumitem>
+ <enumidentifier>Descending</enumidentifier>
+ </enumitem>
+ </enumsynopsis>
+ </section>
+
+ <section xml:id="enum.sortdirection.examples">
+ &reftitle.examples;
+ <example>
+ <title>Sorting names with <enumname>SortDirection</enumname></title>
+ <programlisting role="php" annotations="non-interactive">
+<![CDATA[
+<?php
+
+function sortNames(array $names, SortDirection $direction): array
+{
+ match ($direction) {
+ SortDirection::Ascending => sort($names),
+ SortDirection::Descending => rsort($names),
+ };
+
+ return $names;
+}
+
+$names = ['Charlie', 'Alice', 'Bob'];
+
+print_r(sortNames($names, SortDirection::Descending));
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+Array
+(
+ [0] => Charlie
+ [1] => Bob
+ [2] => Alice
+)
+]]>
+ </screen>
+ </example>
+ </section>
+
+ <section xml:id="enum.sortdirection.seealso">
+ &reftitle.seealso;
+ <simplelist>
+ <member><link linkend="array.sorting">Sorting
Arrays</link></member>
+ <member><link
linkend="language.enumerations">Enumerations</link></member>
+ </simplelist>
+ </section>
+ </partintro>
+</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
+-->
diff --git a/language/predefined/versions.xml b/language/predefined/versions.xml
index 2ee25143f4c2..e53b3b619ee2 100644
--- a/language/predefined/versions.xml
+++ b/language/predefined/versions.xml
@@ -182,6 +182,7 @@
<function name="DelayedTargetValidation" from="PHP 8 >= 8.5.0"/>
<function name="NoDiscard" from="PHP 8 >= 8.5.0"/>
<function name="NoDiscard::__construct" from="PHP 8 >= 8.5.0"/>
+ <function name="SortDirection" from="PHP 8 >= 8.6.0"/>
<function name="__PHP_Incomplete_Class" from="PHP 4 >=4.0.1, PHP 5, PHP
7, PHP 8"/>
</versions>
<!-- Keep this comment at the end of the file