mirror of
https://github.com/php/doc-en.git
synced 2026-03-23 23:32:18 +01:00
100 lines
2.5 KiB
XML
100 lines
2.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<refentry xml:id="reflectionclassconstant.isenumcase" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>ReflectionClassConstant::isEnumCase</refname>
|
|
<refpurpose>Checks if class constant is an Enum case</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis role="ReflectionClassConstant">
|
|
<modifier>public</modifier> <type>bool</type><methodname>ReflectionClassConstant::isEnumCase</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
Checks if the class constant is an <link linkend="language.enumerations">Enum</link> case.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
&no.function.parameters;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&true; if the class constant is an Enum case; &false; otherwise.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example xml:id="reflectionclassconstant.isenumcase.example.basic">
|
|
<title><methodname>ReflectionClassConstant::isEnumCase</methodname> example</title>
|
|
<para>
|
|
Distinguish between Enum cases and regular class constants.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
enum Status
|
|
{
|
|
const BORING_CONSTANT = 'test';
|
|
const ENUM_VALUE = Status::PUBLISHED;
|
|
|
|
case DRAFT;
|
|
case PUBLISHED;
|
|
case ARCHIVED;
|
|
}
|
|
|
|
$reflection = new ReflectionEnum(Status::class);
|
|
foreach ($reflection->getReflectionConstants() as $constant) {
|
|
echo "{$constant->name} is ",
|
|
$constant->isEnumCase() ? "an enum case" : "a regular class constant",
|
|
PHP_EOL;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
BORING_CONSTANT is a regular class constant
|
|
ENUM_VALUE is a regular class constant
|
|
DRAFT is an enum case
|
|
PUBLISHED is an enum case
|
|
ARCHIVED is an enum case
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><classname>ReflectionEnum</classname></member>
|
|
</simplelist>
|
|
</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
|
|
-->
|