1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-24 23:22:14 +01:00
Files
2023-12-09 02:03:40 +08:00

108 lines
2.7 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: ec2fe9a592f794978114ef5021db9f1d00c2e05d Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<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>返回枚举中的所有条目的清单</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="ReflectionEnum">
<modifier>public</modifier> <type>array</type><methodname>ReflectionEnum::getCases</methodname>
<void/>
</methodsynopsis>
<para>
每个枚举都能包括零或多个条目。该方法能获取所有定义的条目,
顺序为语法中的顺序(也就是源码中出现的顺序)。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
数组,包含了 Enum 的反射对象,包含每一个枚举条目。
对于 Unit Enum它们都会是 <classname>ReflectionEnumUnitCase</classname> 的实例。
对于回退枚举,它们都会是 <classname>ReflectionEnumBackedCase</classname> 的实例。
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>ReflectionEnum::getCases</methodname> 示例</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">枚举</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
-->