-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add ZEND_API for weakmap functionality via zend_weakrefs_hash_add/del #7600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--TEST-- | ||
Test internal weakmap API | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a SKIPIF (8.0) or EXTENSIONS (8.1) section. |
||
--FILE-- | ||
<?php | ||
|
||
$id1 = new \stdClass; | ||
$id2 = new \stdClass; | ||
|
||
var_dump(zend_weakmap_attach($id1, 1)); | ||
var_dump(zend_weakmap_attach($id1, 3)); | ||
var_dump(zend_weakmap_attach($id2, 2)); | ||
|
||
var_dump(zend_weakmap_dump()); | ||
|
||
var_dump(zend_weakmap_remove($id2)); | ||
var_dump(zend_weakmap_remove($id2)); | ||
|
||
var_dump(zend_weakmap_dump()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might want to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. facepalm :-D |
||
|
||
?> | ||
--EXPECTF-- | ||
bool(true) | ||
bool(false) | ||
bool(true) | ||
array(2) { | ||
[%d]=> | ||
int(1) | ||
[%d]=> | ||
int(2) | ||
} | ||
bool(true) | ||
bool(false) | ||
array(1) { | ||
[%d]=> | ||
int(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zend_weakref_unregister already does the hash del, so it might make sense to replace your hash_index_del here with hash_index_exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. And yeah will provide a small test for it.