Skip to content

Commit 4ffc323

Browse files
committed
- MFH Show closure's bound as static parameter
1 parent b5d15b2 commit 4ffc323

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

ext/reflection/php_reflection.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -850,24 +850,32 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
850850
}
851851
if (closure) {
852852
const zend_function *closure_fptr = zend_get_closure_method_def(closure TSRMLS_CC);
853+
zval *closure_this = zend_get_closure_this_ptr(closure TSRMLS_CC);
854+
HashTable *static_variables = NULL;
855+
int index = 0, count = closure_this ? 1 : 0;
853856
if (closure_fptr->type == ZEND_USER_FUNCTION && closure_fptr->op_array.static_variables) {
854-
HashTable *static_variables = closure_fptr->op_array.static_variables;
855-
HashPosition pos;
856-
uint key_len;
857-
char* key;
858-
ulong num_index, index = 0;
859-
int count = zend_hash_num_elements(static_variables);
860-
if (count) {
861-
string_printf(str, "\n");
862-
string_printf(str, "%s - Static Parameters [%d] {\n", indent, count);
857+
static_variables = closure_fptr->op_array.static_variables;
858+
count += zend_hash_num_elements(static_variables);
859+
}
860+
if (count) {
861+
string_printf(str, "\n");
862+
string_printf(str, "%s - Static Parameters [%d] {\n", indent, count);
863+
if (closure_this) {
864+
string_printf(str, "%s Parameter #%d [ %s $this ]\n", indent, ++index, Z_OBJCE_P(closure_this)->name);
865+
}
866+
if (static_variables) {
867+
HashPosition pos;
868+
uint key_len;
869+
char* key;
870+
ulong num_index;
863871
zend_hash_internal_pointer_reset_ex(static_variables, &pos);
864872
while (index++ < count) {
865873
zend_hash_get_current_key_ex(static_variables, &key, &key_len, &num_index, 0, &pos);
866874
string_printf(str, "%s Parameter #%d [ $%s ]\n", indent, index++, key);
867875
zend_hash_move_forward_ex(static_variables, &pos);
868-
}
869-
string_printf(str, "%s }\n", indent);
876+
}
870877
}
878+
string_printf(str, "%s }\n", indent);
871879
}
872880
}
873881
string_init(&param_indent);

0 commit comments

Comments
 (0)