From: [email protected] <[email protected]> On Behalf Of Nicolas
Grekas
Sent: Thursday, June 21, 2018 18:51
To: Bob Weinand <[email protected]>
Cc: Nikita Popov <[email protected]>; PHP internals <[email protected]>
Subject: Re: [PHP-DEV] [RFC] Typed Properties
something like a ReflectionReference class, which will give you the referencing
properties via ReflectionProperty instances
I may not have the object when walking on data structures, but only the
reference (in an array.)
It could work this way I suppose: `ReflectionReference::fromArray(array $array,
string $key): ?ReflectionReference`,
returning `null` when `$array[$key]` is not a reference, and the instance
otherwise.
WDYT?
I imagined a ReflectionReference::__construct(&$value), with methods
getRefcount() : int and getReferencingProperties() : ReflectionProperty[]
To check whether it’s a reference at all, you’d use if ((new
ReflectionReference($array[$key]))->getRefcount() > 2) { /* is ref */ } else {
/* not a ref */ }, for computing the allowed types you’d intersect the types of
the ReflectionProperties returned by getReferencingProperties().
Bob