From: Zeev Suraski Date: Wed, 4 Feb 2004 13:56:41 +0000 (+0000) Subject: -Error out when trying to re-assign $this X-Git-Tag: php-5.0.0b4RC1~146 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1fc3963ee725218c4f9206df54f617196baa1e0;p=php -Error out when trying to re-assign $this --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 6d01268412..969c15998b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -487,6 +487,13 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) SET_UNUSED(opline->result); *result = last_op->result; } else { + if (CG(active_class_entry) && (last_op->opcode == ZEND_FETCH_W) && (last_op->op1.op_type == IS_CONST) + && (last_op->op1.u.constant.type == IS_STRING) + && (last_op->op1.u.constant.value.str.len == (sizeof("this")-1)) + && !memcmp(last_op->op1.u.constant.value.str.val, "this", sizeof("this"))) { + zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); + } + opline->opcode = ZEND_ASSIGN; opline->op1 = *variable; opline->op2 = *value;