Le jeu. 21 juin 2018 à 19:37, Nicolas Grekas <nicolas.grekas+...@gmail.com>
a écrit :

> 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().
>>
>

I just realized that this interface would suffer from a significant
drawback: it would trigger COW when iterating over immutable arrays,
defeating the shared-memory optimization provided by OPcache.

An interface like new ReflectionReference($array, $key) would be free from
the issue. Combined with get_defined_vars() and the (array) operator for
objects, we can inspect any PHP data structure or scope also this way.

Nicolas

>

Reply via email to