On Tue, Jan 15, 2019 at 11:57 AM Nikita Popov <nikita....@gmail.com> wrote:
> > * 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? >> > > As Nicolas already wrote, the ID / Hash functionality is needed to allow > hashtable lookups. Having just matches() would require iterating over the > whole set of known references and comparison each and every one. With the > getId() API, it's just a single HT lookup. > > We could add $ref1->equals($ref2) as an *additional* convenience method, > but it would not replace the getId() API. > I'd say that if the indexing is a fairly common scenario (seems like it, coming from Nicolas, who is the most direct API consumer here), the `->matches()` isn't needed at all. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/