From Newsgroup: comp.lang.php
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?
An example? (here's mine below)
~$ cat /tmp/aaa
<?php
#[ATTRIB]
class TARGET_CLASS {
#[ATTRIB]
function TARGET_METHOD() {}
}
#[ATTRIB]
function TARGET_FUNCTION() {}
function TARGET_xxx() {}
$reflections = [
new ReflectionClass('TARGET_CLASS'),
new ReflectionMethod('TARGET_CLASS::TARGET_METHOD'),
new ReflectionFunction('TARGET_FUNCTION'),
new ReflectionFunction('TARGET_xxx'),
];
foreach ($reflections as $reflection) {
echo $reflection->getName() . ': ';
echo $reflection->getAttributes()[0]->getTarget() || "IS ZERO";
echo PHP_EOL;
}
~$ php /tmp/aaa
TARGET_CLASS: 1
TARGET_METHOD: 1
TARGET_FUNCTION: 1
TARGET_xxx: PHP Warning: Undefined array key 0 in /tmp/aaa on line 25
PHP Fatal error: Uncaught Error: Call to a member function getTarget()
on null in /tmp/aaa:25
REPEAT:
An example?
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...???
https://www.google.com/search?channel=fs&client=ubuntu-sn&q=php+typeof#ip=1
--- Synchronet 3.21d-Linux NewsLink 1.2