Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Possible issues with array reference detection in PHP 7.4 #244

Closed
jmalloc opened this issue Aug 18, 2019 · 1 comment
Closed

Possible issues with array reference detection in PHP 7.4 #244

jmalloc opened this issue Aug 18, 2019 · 1 comment

Comments

@jmalloc
Copy link
Member

jmalloc commented Aug 18, 2019

PHP 7.4 introduces reference reflection, which overall might provide a nicer mechanism for reference detection, but the RFC specifically makes mention of the "mutate array to detect if its a reference" approach that may cease to function correctly. If I remember correctly, this is what phony does internally when rendering arrays.

@ezzatron ezzatron added this to the 4.0.0 milestone Oct 30, 2019
ezzatron added a commit that referenced this issue Dec 4, 2019
@ezzatron
Copy link
Contributor

ezzatron commented Dec 4, 2019

I implemented support for the new ReflectionReference API in the exporter, and it actually had some nice side effects, like making array IDs persistent across exporter invocations (which is how objects already worked).

As I suspected, the deep equality logic does similar stuff to what the exporter was doing, like assigning IDs to arrays by setting a special array key. This could probably be replaced with logic that used ReflectionReference too, but I can't see any way that it could possibly be as performant as the current implementation, which continues to work just fine under PHP 7.4. I'm not inclined to change it just yet, for that reason.

@jmalloc The deep equality code was actually your contribution, I think. If I ever have to rewrite it to use the new reference reflection stuff I might have to get your input 😅

@ezzatron ezzatron closed this as completed Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants