Skip to content
Browse files

Can't return an object, restriction of PHP itself

  • Loading branch information...
1 parent 75c9bc8 commit 03121e6f0fa00fb1445aba331ccb6cfaa7fe3c33 @colder committed
Showing with 31 additions and 1 deletion.
  1. +30 −0 tests/weakmap_004.phpt
  2. +1 −1 wr_weakmap.c
View
30 tests/weakmap_004.phpt
@@ -0,0 +1,30 @@
+--TEST--
+WeakMap: test detach on unset
+--FILE--
+<?php
+$a = new StdClass;
+$b = new StdClass;
+$c = new StdClass;
+$d = new StdClass;
+
+$wm = new WeakMap;
+
+$wm[$a] = $b;
+$wm[$c] = $b;
+$wm[$d] = $b;
+
+foreach($wm as $k => $v) {
+ var_dump($k);
+ var_dump($v);
+}
+
+unset($a);
+
+foreach($wm as $k => $v) {
+ var_dump($k);
+ var_dump($v);
+}
+?>
+==END==
+--EXPECTF--
+==END==
View
2 wr_weakmap.c
@@ -468,7 +468,7 @@ PHP_METHOD(WeakMap, key)
if (zend_hash_get_current_data_ex(&intern->map, (void**)&element, &intern->pos) == FAILURE) {
return;
}
- RETVAL_ZVAL(*element, 1, 0);
+ RETVAL_LONG(index);
} /* }}} */
/* {{{ proto mixed WeakMap::current()

0 comments on commit 03121e6

Please sign in to comment.
Something went wrong with that request. Please try again.