From 5e5cedfbf2cb1aecf052b75a9573eeb882eaf308 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Wed, 29 Jan 2014 13:56:39 -0800 Subject: [PATCH] Make SplObjectStorage exporting in HHVM match Zend SplObjectStorage::$storage is the current method. HHVM is about to be changed so that it uses $__storage instead to reduce the chance of a conflict in cases like this: ```PHP attach($o1); $store->storage = 'herpderp'; ``` This gets PHPUnit to 100%, but #1 still depends on an array_keys fix for recursive structures that hasn't reached master yet. --- src/Exporter.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Exporter.php b/src/Exporter.php index 6897e00..e131381 100644 --- a/src/Exporter.php +++ b/src/Exporter.php @@ -270,9 +270,16 @@ class Exporter } // Some internal classes like SplObjectStorage don't work with the - // above (fast) mechanism nor with reflection + // above (fast) mechanism nor with reflection in Zend. // Format the output similarly to print_r() in this case if ($value instanceof \SplObjectStorage) { + // However, the fast method does work in HHVM, and exposes the + // internal implementation. Hide it again. + if (property_exists('\SplObjectStorage', '__storage')) { + unset($array['__storage']); + } else if (property_exists('\SplObjectStorage', 'storage')) { + unset($array['storage']); + } foreach ($value as $key => $val) { $array[spl_object_hash($val)] = array( 'obj' => $val,