mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-26 05:48:57 +00:00

Co-authored-by: Yoshinari Takaoka <mumumu@mumumu.org> Co-authored-by: Sergey Panteleev <sergey@php.net> Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de> Closes GH-960.
105 lines
2.5 KiB
XML
105 lines
2.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<refentry xml:id="reflectionenum.getcases" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ReflectionEnum::getCases</refname>
|
|
<refpurpose>Returns a list of all cases on an Enum</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>array</type><methodname>ReflectionEnum::getCases</methodname>
|
|
<void />
|
|
</methodsynopsis>
|
|
<para>
|
|
An Enum may contain zero or more cases. This method retrieves all defined cases,
|
|
in lexical order (that is, the order they appear in the source code).
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
&no.function.parameters;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
An array of Enum reflection objects, one for each case in the Enum. For a Unit Enum,
|
|
they will all be instances of <classname>ReflectionEnumUnitCase</classname>. For a Backed
|
|
Enum, they will all be instances of <classname>ReflectionEnumBackedCase</classname>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><methodname>ReflectionEnum::getCase</methodname> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
enum Suit
|
|
{
|
|
case Hearts;
|
|
case Diamonds;
|
|
case Clubs;
|
|
case Spades;
|
|
}
|
|
|
|
$rEnum = new ReflectionEnum(Suit::class);
|
|
|
|
$cases = $rEnum->getCases();
|
|
|
|
foreach ($cases as $rCase) {
|
|
var_dump($rCase->getValue());
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
enum(Suit::Hearts)
|
|
enum(Suit::Diamonds)
|
|
enum(Suit::Clubs)
|
|
enum(Suit::Spades)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><link linkend="language.enumerations">Enumerations</link></member>
|
|
<member><methodname>ReflectionEnum::getCase</methodname></member>
|
|
<member><methodname>ReflectionEnum::isBacked</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
|
|
-->
|