8000 feature #12061 [Debug] expose object_handle (nicolas-grekas) · symfony/symfony@0314d75 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0314d75

Browse files
committed
feature #12061 [Debug] expose object_handle (nicolas-grekas)
This PR was merged into the 2.6-dev branch. Discussion ---------- [Debug] expose object_handle | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This is a small enhancement to the symfony debug C extension that allows fetching an object's handle. This is the `#number` as displayed by var_dump(): `class stdClass**#1** (0) {}` This is required for VarDumper to be able to expose objects' handles and thus have more precise dumps. It will allow inspecting "same" relationships between two *different* dumps. Commits ------- 5f6b676 [Debug] expose object_handle
2 parents 6acf3e7 + 5f6b676 commit 0314d75

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/Symfony/Component/Debug/Resources/ext/README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ Its behavior is about the same as:
3333
'object_class' => get_class($array[$key]),
3434
'object_refcount' => /* internal object refcount of $array[$key] */,
3535
'object_hash' => spl_object_hash($array[$key]),
36+
'object_handle' => /* internal object handle $array[$key] */,
3637
);
3738
break;
3839
3940
case 'resource':
4041
$info += array(
41-
'resource_id' => (int) substr((string) $array[$key], 13),
42+
'resource_handle' => (int) $array[$key],
4243
'resource_type' => get_resource_type($array[$key]),
4344
'resource_refcount' => /* internal resource refcount of $array[$key] */,
4445
);

src/Symfony/Component/Debug/Resources/ext/symfony_debug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ PHP_FUNCTION(symfony_zval_info)
7272
add_assoc_stringl(return_value, "object_class", (char *)Z_OBJCE_P(arg)->name, Z_OBJCE_P(arg)->name_length, 1);
7373
add_assoc_long(return_value, "object_refcount", EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(arg)].bucket.obj.refcount);
7474
add_assoc_string(return_value, "object_hash", hash, 1);
75+
add_assoc_long(return_value, "object_handle", Z_OBJ_HANDLE_P(arg));
7576
} else if (Z_TYPE_P(arg) == IS_ARRAY) {
7677
add_assoc_long(return_value, "array_count", zend_hash_num_elements(Z_ARRVAL_P(arg)));
7778
} else if(Z_TYPE_P(arg) == IS_RESOURCE) {
78-
add_assoc_long(return_value, "resource_id", Z_LVAL_P(arg));
79+
add_assoc_long(return_value, "resource_handle", Z_LVAL_P(arg));
7980
add_assoc_string(return_value, "resource_type", (char *)_symfony_debug_get_resource_type(Z_LVAL_P(arg)), 1);
8081
add_assoc_long(return_value, "resource_refcount", _symfony_debug_get_resource_refcount(Z_LVAL_P(arg)));
8182
} else if (Z_TYPE_P(arg) == IS_STRING) {

src/Symfony/Component/Debug/Resources/ext/tests/001.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ array(5) {
7272
["strlen"]=>
7373
int(6)
7474
}
75-
array(7) {
75+
array(8) {
7676
["type"]=>
7777
string(6) "object"
7878
["zval_hash"]=>
@@ -87,6 +87,8 @@ array(7) {
8787
int(1)
8888
["object_hash"]=>
8989
string(32) "%s"
90+
["object_handle"]=>
91+
int(1)
9092
}
9193
array(5) {
9294
["type"]=>
@@ -109,7 +111,7 @@ array(7) {
109111
int(2)
110112
["zval_isref"]=>
111113
bool(false)
112-
["resource_id"]=>
114+
["resource_handle"]=>
113115
int(4)
114116
["resource_type"]=>
115117
string(6) "stream"
@@ -146,4 +148,4 @@ array(4) {
146148
["zval_isref"]=>
147149
bool(true)
148150
}
149-
NULL
151+
NULL

0 commit comments

Comments
 (0)
0