[doc-en] master: ext/reflection: Document ReflectionConstant::getAttributes() (PHP 8.5) (#5675)

From: Date: Thu, 16 Jul 2026 20:02:05 +0000
Subject: [doc-en] master: ext/reflection: Document ReflectionConstant::getAttributes() (PHP 8.5) (#5675)
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-23463@lists.php.net to get a copy of this message
Author: Louis-Arnaud (lacatoire) Committer: GitHub (web-flow) Pusher: jordikroon Date: 2026-07-16T22:02:02+02:00 Commit: https://github.com/php/doc-en/commit/543f9825542891ca85581c3ac9cda5b8f01258b5 Raw diff: https://github.com/php/doc-en/commit/543f9825542891ca85581c3ac9cda5b8f01258b5.diff ext/reflection: Document ReflectionConstant::getAttributes() (PHP 8.5) (#5675) Changed paths: A reference/reflection/reflectionconstant/getattributes.xml Diff: diff --git a/reference/reflection/reflectionconstant/getattributes.xml b/reference/reflection/reflectionconstant/getattributes.xml new file mode 100644 index 000000000000..9720e1cafa2b --- /dev/null +++ b/reference/reflection/reflectionconstant/getattributes.xml @@ -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 +-->

« previous php.doc.cvs (#23463) next »