Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: ReflectionAttribute: IS_INSTANCEOF and getTarget() Date: Mon, 13 Nov 2023 14:32:39 +0100 Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Qh7yNyrQy5qXZrdWbJawegc6DSo+M3v4/rfwt4sBqaFQhbi5ZT Cancel-Lock: sha1:rpWc9NiYgwbPKz43kbDUktYYtFI= sha256:mAI7VSHr/TBcEAFtElluAnhltMSpERLI8gbtSXQCK9g= User-Agent: Mozilla Thunderbird Content-Language: en-US-large In-Reply-To: Xref: csiph.com comp.lang.php:19546 On 13/11/2023 12.50, alex wrote: > Il 13/11/23 07:54, J.O. Aho ha scritto: >>> https://www.php.net/manual/en/reflectionattribute.gettarget.php >> >> There are a number of attributes you can give a class, TARGET_* and >> you will get the sum of all those targets as an unified bit value. 0 >> if none of the TARGET_* are set. > > mmmhhh... > > Are you sure? No and yes, it wasn't really what I thought I thought it would give the value of #[Attribute(Attribute::TARGET_CLASS|Attribute::IS_REPEATABLE)] (65) but it only gives you Attribute::TARGET_CLASS (1) Attribute::TARGET_FUNCTION (2) Attribute::TARGET_METHOD (4) see: https://github.com/php/php-src/blob/cc2bf119519c8dd7d6afa2b63aa4ea8b014f205d/Zend/zend_attributes.h You can see at the unitest: https://github.com/php/php-src/blob/cc2bf119519c8dd7d6afa2b63aa4ea8b014f205d/Zend/tests/attributes/020_userland_attribute_validation.phpt >>> https://www.php.net/manual/en/class.reflectionattribute.php#reflectionattribute.constants.is-instanceof >> >> this will give you something like typeof for the instance in question. > > typeof...??? just ignore this part.. typeof used in other languages when you want to know what type something is of and I was hasty in my reply and guessed without really reading. -- //Aho