-
Notifications
You must be signed in to change notification settings - Fork 880
Document ReflectionConstant::getAttributes() (PHP 8.5) #5675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jordikroon
merged 4 commits into
php:master
from
lacatoire:feat/reflection-constant-getattributes-8.5
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dead2af
feat(reflection): ajoute la doc de ReflectionConstant::getAttributes(…
lacatoire a09c86f
Apply DocBook style check: para->simpara, exceptionname, attribute order
lacatoire ce513a1
Unwrap simplelist from para in seealso
lacatoire c3ad745
Add usage example to ReflectionConstant::getAttributes
lacatoire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
reference/reflection/reflectionconstant/getattributes.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- $Revision$ --> | ||
| <refentry xml:id="reflectionconstant.getattributes" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
| <refnamediv> | ||
| <refname>ReflectionConstant::getAttributes</refname> | ||
| <refpurpose>Gets Attributes</refpurpose> | ||
| </refnamediv> | ||
|
|
||
| <refsect1 role="description"> | ||
| &reftitle.description; | ||
| <methodsynopsis role="ReflectionConstant"> | ||
| <modifier>public</modifier> <type>array</type><methodname>ReflectionConstant::getAttributes</methodname> | ||
| <methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>name</parameter><initializer>&null;</initializer></methodparam> | ||
| <methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam> | ||
| </methodsynopsis> | ||
| <simpara> | ||
| Returns all attributes declared on this global constant as an array of <classname>ReflectionAttribute</classname>. | ||
| </simpara> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="parameters"> | ||
| &reftitle.parameters; | ||
| <variablelist> | ||
| &reflection.getattributes.param.name; | ||
| &reflection.getattributes.param.flags; | ||
| </variablelist> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="returnvalues"> | ||
| &reftitle.returnvalues; | ||
| <simpara> | ||
| Array of attributes, as <classname>ReflectionAttribute</classname> objects. | ||
| </simpara> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="changelog"> | ||
| &reftitle.changelog; | ||
| <para> | ||
| <informaltable> | ||
| <tgroup cols="2"> | ||
| <thead> | ||
| <row> | ||
| <entry>&Version;</entry> | ||
| <entry>&Description;</entry> | ||
| </row> | ||
| </thead> | ||
| <tbody> | ||
| <row> | ||
| <entry>8.5.0</entry> | ||
| <entry> | ||
| This method was introduced. | ||
| </entry> | ||
| </row> | ||
| </tbody> | ||
| </tgroup> | ||
| </informaltable> | ||
| </para> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="examples"> | ||
| &reftitle.examples; | ||
| <para> | ||
| <example> | ||
| <title>Basic usage</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| #[Attribute] | ||
| class Fruit { | ||
| } | ||
|
|
||
| #[Attribute] | ||
| class Red { | ||
| } | ||
|
|
||
| #[Fruit] | ||
| #[Red] | ||
| const APPLE = 'apple'; | ||
|
|
||
| $constant = new ReflectionConstant('APPLE'); | ||
| $attributes = $constant->getAttributes(); | ||
| print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| &example.outputs; | ||
| <screen> | ||
| <![CDATA[ | ||
| Array | ||
| ( | ||
| [0] => Fruit | ||
| [1] => Red | ||
| ) | ||
| ]]> | ||
| </screen> | ||
| </example> | ||
| </para> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="seealso"> | ||
| &reftitle.seealso; | ||
| <simplelist> | ||
| <member><methodname>ReflectionClass::getAttributes</methodname></member> | ||
| <member><methodname>ReflectionClassConstant::getAttributes</methodname></member> | ||
| <member><methodname>ReflectionFunctionAbstract::getAttributes</methodname></member> | ||
| <member><methodname>ReflectionProperty::getAttributes</methodname></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 | ||
| --> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.