From a9512af8109e889eb2c6042c57797184930667cd Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 16 Jun 2016 02:30:23 +0300 Subject: Implemented RFC: Fix inconsistent behavior of $this variable Squashed commit of the following: commit bdd3b6895c3ce3eacfcf7d4bf4feb8dfa61801fd Author: Dmitry Stogov Date: Thu Jun 16 00:19:42 2016 +0300 Fixed GOTO VM commit 2f1d7c8b89ce821086d357cf65f629f040a85c03 Author: Dmitry Stogov Date: Wed Jun 15 21:01:57 2016 +0300 Removed unused variable commit cf749c42b0b1919f70b1e7d6dcbfff76899506af Author: Dmitry Stogov Date: Wed Jun 15 19:06:16 2016 +0300 Protection from $this reassign through mb_parse_str() commit 59a9a6c83c66b666971e57f1173b33a422166efd Author: Dmitry Stogov Date: Wed Jun 15 18:14:50 2016 +0300 Added type inference rule for FETCH_THIS opcode commit 73f8d14a856f14a461430b3c7534ab2ce870cbf6 Author: Dmitry Stogov Date: Wed Jun 15 18:11:18 2016 +0300 Restored PHP-7 behavior of isset($this->foo). It throws exception if not in object context. Removed useless opcode handlers. commit fa0881381e8ae97e022ae5d1ec0851c952f33c82 Author: Dmitry Stogov Date: Tue May 31 12:25:47 2016 +0300 Changed "Notice: Undefined variable: this" into "Exception: Using $this when not in object context". commit e32cc528c0f2c97963d8ec83eff0269f1f45af18 Author: Dmitry Stogov Date: Tue May 24 02:02:43 2016 +0300 Throw exception on attempt to re-assign $this through extract() and parse_str(). commit 41f1531b52113ec8a4c208aa6b9ef50f1386bb3f Author: Dmitry Stogov Date: Mon May 23 22:18:36 2016 +0300 Fixed inconsistent $this behavior --- Zend/zend_execute.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'Zend/zend_execute.c') diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index b2769ad6fb..935eb25f4c 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2133,7 +2133,7 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void ZEND_FASTCALL zend_interru * +----------------------------------------+ */ -static zend_always_inline void i_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value, int check_this) /* {{{ */ +static zend_always_inline void i_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value) /* {{{ */ { uint32_t first_extra_arg, num_args; ZEND_ASSERT(EX(func) == (zend_function*)op_array); @@ -2191,11 +2191,6 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu } while (var != end); } - if (check_this && op_array->this_var != (uint32_t)-1 && EXPECTED(Z_TYPE(EX(This)) == IS_OBJECT)) { - ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This))); - GC_REFCOUNT(Z_OBJ(EX(This)))++; - } - EX_LOAD_RUN_TIME_CACHE(op_array); EX_LOAD_LITERALS(op_array); @@ -2219,13 +2214,6 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu EX(call) = NULL; EX(return_value) = return_value; - if (UNEXPECTED(op_array->this_var != (uint32_t)-1) && EXPECTED(Z_TYPE(EX(This)) == IS_OBJECT)) { - GC_REFCOUNT(Z_OBJ(EX(This)))++; - if (!zend_hash_add(EX(symbol_table), CG(known_strings)[ZEND_STR_THIS], &EX(This))) { - GC_REFCOUNT(Z_OBJ(EX(This)))--; - } - } - zend_attach_symbol_table(execute_data); if (!op_array->run_time_cache) { @@ -2248,13 +2236,6 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da EX(return_value) = return_value; if (EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE) { - if (UNEXPECTED(op_array->this_var != (uint32_t)-1) && EXPECTED(Z_TYPE(EX(This)) == IS_OBJECT)) { - GC_REFCOUNT(Z_OBJ(EX(This)))++; - if (!zend_hash_add(EX(symbol_table), CG(known_strings)[ZEND_STR_THIS], &EX(This))) { - GC_REFCOUNT(Z_OBJ(EX(This)))--; - } - } - zend_attach_symbol_table(execute_data); } else { uint32_t first_extra_arg, num_args; @@ -2307,11 +2288,6 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da var++; } while (var != end); } - - if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_TYPE(EX(This)) == IS_OBJECT)) { - ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This))); - GC_REFCOUNT(Z_OBJ(EX(This)))++; - } } if (!op_array->run_time_cache) { -- cgit v1.2.1