summaryrefslogtreecommitdiff
path: root/Zend/zend_execute_API.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2003-02-10 09:45:27 +0000
committerZeev Suraski <zeev@php.net>2003-02-10 09:45:27 +0000
commitdbb73d8f1ee28c6b1edaaa3b630cf1dc3f5f32bf (patch)
tree7bd4c08bbeb54d34962f8efda144f6f45aff91eb /Zend/zend_execute_API.c
parentedc8e67e3b47603b2aa3b37e4f7c48cf13a59574 (diff)
downloadphp-git-dbb73d8f1ee28c6b1edaaa3b630cf1dc3f5f32bf.tar.gz
Add ability to reference self:: and parent:: in constant initializers
(bug #21849)
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r--Zend/zend_execute_API.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 3788ae263f..b170603bec 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -378,6 +378,23 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
last = tsrm_strtok_r(p->value.str.val, ":", &temp);
+ if (strcasecmp(last, "self")==0) {
+ if (EG(scope)) {
+ last = EG(scope)->name;
+ } else {
+ zend_error(E_ERROR, "Cannot access self:: when no class scope is active");
+ }
+ } else if (strcasecmp(last, "parent")==0) {
+ if (!EG(scope)) {
+ zend_error(E_ERROR, "Cannot access parent:: when no class scope is active");
+ } else if (!EG(scope)->parent) {
+ zend_error(E_ERROR, "Cannot access parent:: when current class scope has no parent");
+ } else {
+ last = EG(scope)->parent->name;
+ }
+ }
+
+
if (zend_lookup_class(last, strlen(last), &ce TSRMLS_CC) == FAILURE) {
zend_error(E_ERROR, "Undefined class '%s'", last);
}