Skip to content

Commit 543f982

Browse files
authored
ext/reflection: Document ReflectionConstant::getAttributes() (PHP 8.5) (#5675)
1 parent 34314b7 commit 543f982

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<refentry xml:id="reflectionconstant.getattributes" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4+
<refnamediv>
5+
<refname>ReflectionConstant::getAttributes</refname>
6+
<refpurpose>Gets Attributes</refpurpose>
7+
</refnamediv>
8+
9+
<refsect1 role="description">
10+
&reftitle.description;
11+
<methodsynopsis role="ReflectionConstant">
12+
<modifier>public</modifier> <type>array</type><methodname>ReflectionConstant::getAttributes</methodname>
13+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>name</parameter><initializer>&null;</initializer></methodparam>
14+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
15+
</methodsynopsis>
16+
<simpara>
17+
Returns all attributes declared on this global constant as an array of <classname>ReflectionAttribute</classname>.
18+
</simpara>
19+
</refsect1>
20+
21+
<refsect1 role="parameters">
22+
&reftitle.parameters;
23+
<variablelist>
24+
&reflection.getattributes.param.name;
25+
&reflection.getattributes.param.flags;
26+
</variablelist>
27+
</refsect1>
28+
29+
<refsect1 role="returnvalues">
30+
&reftitle.returnvalues;
31+
<simpara>
32+
Array of attributes, as <classname>ReflectionAttribute</classname> objects.
33+
</simpara>
34+
</refsect1>
35+
36+
<refsect1 role="changelog">
37+
&reftitle.changelog;
38+
<para>
39+
<informaltable>
40+
<tgroup cols="2">
41+
<thead>
42+
<row>
43+
<entry>&Version;</entry>
44+
<entry>&Description;</entry>
45+
</row>
46+
</thead>
47+
<tbody>
48+
<row>
49+
<entry>8.5.0</entry>
50+
<entry>
51+
This method was introduced.
52+
</entry>
53+
</row>
54+
</tbody>
55+
</tgroup>
56+
</informaltable>
57+
</para>
58+
</refsect1>
59+
60+
<refsect1 role="examples">
61+
&reftitle.examples;
62+
<para>
63+
<example>
64+
<title>Basic usage</title>
65+
<programlisting role="php">
66+
<![CDATA[
67+
<?php
68+
#[Attribute]
69+
class Fruit {
70+
}
71+
72+
#[Attribute]
73+
class Red {
74+
}
75+
76+
#[Fruit]
77+
#[Red]
78+
const APPLE = 'apple';
79+
80+
$constant = new ReflectionConstant('APPLE');
81+
$attributes = $constant->getAttributes();
82+
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
83+
?>
84+
]]>
85+
</programlisting>
86+
&example.outputs;
87+
<screen>
88+
<![CDATA[
89+
Array
90+
(
91+
[0] => Fruit
92+
[1] => Red
93+
)
94+
]]>
95+
</screen>
96+
</example>
97+
</para>
98+
</refsect1>
99+
100+
<refsect1 role="seealso">
101+
&reftitle.seealso;
102+
<simplelist>
103+
<member><methodname>ReflectionClass::getAttributes</methodname></member>
104+
<member><methodname>ReflectionClassConstant::getAttributes</methodname></member>
105+
<member><methodname>ReflectionFunctionAbstract::getAttributes</methodname></member>
106+
<member><methodname>ReflectionProperty::getAttributes</methodname></member>
107+
</simplelist>
108+
</refsect1>
109+
110+
</refentry>
111+
<!-- Keep this comment at the end of the file
112+
Local variables:
113+
mode: sgml
114+
sgml-omittag:t
115+
sgml-shorttag:t
116+
sgml-minimize-attributes:nil
117+
sgml-always-quote-attributes:t
118+
sgml-indent-step:1
119+
sgml-indent-data:t
120+
indent-tabs-mode:nil
121+
sgml-parent-document:nil
122+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
123+
sgml-exposed-tags:nil
124+
sgml-local-catalogs:nil
125+
sgml-local-ecat-files:nil
126+
End:
127+
vim600: syn=xml fen fdm=syntax fdl=2 si
128+
vim: et tw=78 syn=sgml
129+
vi: ts=1 sw=1
130+
-->

0 commit comments

Comments
 (0)