Jump to content

What is it for ReflectionAttribute::IS_INSTANCEOF


rick645
Go to solution Solved by kicken,

Recommended Posts

The targets are the Attribute::TARGET values.
https://www.php.net/manual/en/language.attributes.classes.php

Since an attribute can be applied to more than one type of thing, getTarget() returns the bitmask of those TARGETs. Then you can use normal bit arithmetic to find out if it applies to a class, or method, or whatever.

Link to comment
Share on other sites

The page talks about Attribute::TARGET_*[1] and not Attribute::TARGET

Anyway, do you know what the constant ReflectionAttribute::IS_INSTANCEOF is for?

$ php -r 'echo ReflectionAttribute::IS_INSTANCEOF . PHP_EOL;'
2

So what?

[1] Expandable in
    Attribute::TARGET_CLASS
    Attribute::TARGET_FUNCTION
    Attribute::TARGET_METHOD
    Attribute::TARGET_PROPERTY
    Attribute::TARGET_CLASS_CONSTANT
    Attribute::TARGET_PARAMETER
    Attribute::TARGET_ALL
    Attribute::IS_REPEATABLE

Link to comment
Share on other sites

5 hours ago, rick645 said:

The page talks about Attribute::TARGET_*[1] and not Attribute::TARGET

Yeah.

"The targets are the Attribute::TARGET values."

Plural.

5 hours ago, rick645 said:

Anyway, do you know what the constant ReflectionAttribute::IS_INSTANCEOF is for?

https://www.php.net/manual/en/class.reflectionattribute.php#reflectionattribute.constants.is-instanceof

"Retrieve attributes using an instanceof check."

Do you know how to "retrieve attributes"?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.