-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add support for defining object constants via define() #7243
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 |
---|---|---|
|
@@ -432,10 +432,6 @@ static bool validate_constant_array_argument(HashTable *ht, int argument_number) | |
break; | ||
} | ||
} | ||
} else if (Z_TYPE_P(val) != IS_STRING && Z_TYPE_P(val) != IS_RESOURCE) { | ||
zend_argument_type_error(argument_number, "cannot be an object, %s given", zend_zval_type_name(val)); | ||
ret = 0; | ||
break; | ||
} | ||
} | ||
} ZEND_HASH_FOREACH_END(); | ||
|
@@ -444,6 +440,13 @@ static bool validate_constant_array_argument(HashTable *ht, int argument_number) | |
} | ||
/* }}} */ | ||
|
||
static bool validate_constant_obj_argument(zend_object *obj) | ||
{ | ||
bool ret = 1; | ||
|
||
return ret; | ||
} | ||
|
||
static void copy_constant_array(zval *dst, zval *src) /* {{{ */ | ||
{ | ||
zend_string *key; | ||
|
@@ -520,11 +523,10 @@ ZEND_FUNCTION(define) | |
val = &val_free; | ||
break; | ||
} | ||
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. the |
||
ZEND_FALLTHROUGH; | ||
default: | ||
zval_ptr_dtor(&val_free); | ||
zend_argument_type_error(2, "cannot be an object, %s given", zend_zval_type_name(val)); | ||
RETURN_THROWS(); | ||
|
||
if (!validate_constant_obj_argument(Z_OBJ_P(val))) { | ||
RETURN_THROWS(); | ||
} | ||
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. I'm sure we need some custom code here, just like arrays do |
||
} | ||
|
||
ZVAL_COPY(&c.value, val); | ||
|
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.
clearly, this is just a placeholder :( I'm not sure what should be validated