Re: [RFC] Reflection for references
| From: | Marco Pivetta | Date: | Tue, 15 Jan 2019 10:30:18 +0000 |
| Subject: | Re: [RFC] Reflection for references | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103739@lists.php.net to get a copy of this message | ||
A few issues with the RFC so far:
*
ReflectionReference seems to be designed around arrays only: maybe
ReflectionArrayKeyReference or such?
* Can the getId() return type be restricted to either int or
string?
Why is it a union type right now? Technical limitation?
* ReflectionReference#__construct() should be private, since it is
unusable anyway
* fromArrayElem => fromArrayElement
* is this open for inheritance? If so, what scenarios would fit inheriting
from ReflectionReference?
* what happens when ReflectionReference::fromArrayElement() is given
invalid data, such as non-existing keys? I'd expect it to throw.
* instead of $ref1->getId() === $ref2->getId(),
$ref1->matches($ref2)
or such.
* what are possible scenarios for getting the identifier as a primitive,
and then storing it somewhere (like an array of reference identifiers)?
* There seems to be a lot of design around ReflectionReference#getId()
to avoid leaking internal pointer information: can it be completely
dropped, if we have $ref1->matches($ref2) instead?
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
On Tue, Jan 15, 2019 at 11:16 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals,
>
> I'd like to propose the addition of a ReflectionReference class, as
> described in the following RFC:
> https://wiki.php.net/rfc/reference_reflection
>
> This topic was previously discussed at
> https://externals.io/message/102638
> .
> The TL;DR is that some libraries need a way to detect references and
> determine whether two references are the same. They previously used an ugly
> hack to achieve this, but this hack will no longer (reliably) work due to
> the introduction of typed properties, so we need to do something about this
> for the 7.4 release.
>
> Regards,
> Nikita
>