Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,18 +769,16 @@ ZEND_FUNCTION(get_class_vars)
/* {{{ Returns an array of object properties */
ZEND_FUNCTION(get_object_vars)
{
zval *obj;
zval *value;
HashTable *properties;
zend_string *key;
zend_object *zobj;
zend_ulong num_key;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT(obj)
Z_PARAM_OBJ(zobj)
ZEND_PARSE_PARAMETERS_END();

zobj = Z_OBJ_P(obj);
properties = zobj->handlers->get_properties(zobj);
if (properties == NULL) {
RETURN_EMPTY_ARRAY();
Expand Down Expand Up @@ -839,22 +837,22 @@ ZEND_FUNCTION(get_object_vars)
/* {{{ Returns an array of mangled object properties. Does not respect property visibility. */
ZEND_FUNCTION(get_mangled_object_vars)
{
zval *obj;
zend_object *obj;
HashTable *properties;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT(obj)
Z_PARAM_OBJ(obj)
ZEND_PARSE_PARAMETERS_END();

properties = Z_OBJ_HT_P(obj)->get_properties(Z_OBJ_P(obj));
properties = obj->handlers->get_properties(obj);
if (!properties) {
ZVAL_EMPTY_ARRAY(return_value);
return;
}

properties = zend_proptable_to_symtable(properties,
(Z_OBJCE_P(obj)->default_properties_count ||
Z_OBJ_P(obj)->handlers != &std_object_handlers ||
(obj->ce->default_properties_count ||
obj->handlers != &std_object_handlers ||
GC_IS_RECURSIVE(properties)));
RETURN_ARR(properties);
}
Expand Down
12 changes: 7 additions & 5 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ZEND_METHOD(Closure, call)
zend_fcall_info_cache fci_cache;
zend_function my_function;
zend_object *newobj;
zend_class_entry *newclass;

fci.param_count = 0;
fci.params = NULL;
Expand All @@ -140,26 +141,27 @@ ZEND_METHOD(Closure, call)
closure = (zend_closure *) Z_OBJ_P(ZEND_THIS);

newobj = Z_OBJ_P(newthis);
newclass = newobj->ce;

if (!zend_valid_closure_binding(closure, newthis, Z_OBJCE_P(newthis))) {
if (!zend_valid_closure_binding(closure, newthis, newclass)) {
return;
}

if (closure->func.common.fn_flags & ZEND_ACC_GENERATOR) {
zval new_closure;
zend_create_closure(&new_closure, &closure->func, Z_OBJCE_P(newthis), closure->called_scope, newthis);
zend_create_closure(&new_closure, &closure->func, newclass, closure->called_scope, newthis);
closure = (zend_closure *) Z_OBJ(new_closure);
fci_cache.function_handler = &closure->func;
} else {
memcpy(&my_function, &closure->func, closure->func.type == ZEND_USER_FUNCTION ? sizeof(zend_op_array) : sizeof(zend_internal_function));
my_function.common.fn_flags &= ~ZEND_ACC_CLOSURE;
/* use scope of passed object */
my_function.common.scope = Z_OBJCE_P(newthis);
my_function.common.scope = newclass;
fci_cache.function_handler = &my_function;

/* Runtime cache relies on bound scope to be immutable, hence we need a separate rt cache in case scope changed */
if (ZEND_USER_CODE(my_function.type)
&& (closure->func.common.scope != Z_OBJCE_P(newthis)
&& (closure->func.common.scope != newclass
|| (closure->func.common.fn_flags & ZEND_ACC_HEAP_RT_CACHE))) {
void *ptr;

Expand All @@ -172,7 +174,7 @@ ZEND_METHOD(Closure, call)
}
}

fci_cache.called_scope = newobj->ce;
fci_cache.called_scope = newclass;
fci_cache.object = fci.object = newobj;

fci.size = sizeof(fci);
Expand Down
12 changes: 6 additions & 6 deletions Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ static zend_object* zend_weakref_new(zend_class_entry *ce) {
return &wr->std;
}

static zend_always_inline zend_bool zend_weakref_find(zval *referent, zval *return_value) {
void *tagged_ptr = zend_hash_index_find_ptr(&EG(weakrefs), (zend_ulong) Z_OBJ_P(referent));
static zend_always_inline zend_bool zend_weakref_find(zend_object *referent, zval *return_value) {
void *tagged_ptr = zend_hash_index_find_ptr(&EG(weakrefs), (zend_ulong) referent);
if (!tagged_ptr) {
return 0;
}
Expand All @@ -209,13 +209,13 @@ static zend_always_inline zend_bool zend_weakref_find(zval *referent, zval *retu
return 0;
}

static zend_always_inline void zend_weakref_create(zval *referent, zval *return_value) {
static zend_always_inline void zend_weakref_create(zend_object *referent, zval *return_value) {
zend_weakref *wr;

object_init_ex(return_value, zend_ce_weakref);

wr = zend_weakref_fetch(return_value);
wr->referent = Z_OBJ_P(referent);
wr->referent = referent;

zend_weakref_register(wr->referent, ZEND_WEAKREF_ENCODE(wr, ZEND_WEAKREF_TAG_REF));
}
Expand Down Expand Up @@ -245,10 +245,10 @@ ZEND_COLD ZEND_METHOD(WeakReference, __construct)

ZEND_METHOD(WeakReference, create)
{
zval *referent;
zend_object *referent;

ZEND_PARSE_PARAMETERS_START(1,1)
Z_PARAM_OBJECT(referent)
Z_PARAM_OBJ(referent)
ZEND_PARSE_PARAMETERS_END();

if (zend_weakref_find(referent, return_value)) {
Expand Down
6 changes: 3 additions & 3 deletions ext/spl/php_spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,13 +641,13 @@ PHP_FUNCTION(spl_object_hash)
/* {{{ Returns the integer object handle for the given object */
PHP_FUNCTION(spl_object_id)
{
zval *obj;
zend_object *obj;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT(obj)
Z_PARAM_OBJ(obj)
ZEND_PARSE_PARAMETERS_END();

RETURN_LONG((zend_long)Z_OBJ_HANDLE_P(obj));
RETURN_LONG((zend_long)obj->handle);
}
/* }}} */

Expand Down