In context of static accesses like classname::$this, the string
"$this" should not be handled like a $this variable, but as an
identifier for a static variable.
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2013, PHP 5.4.22
+- Core:
+ . Fixed bug #65911 (scope resolution operator - strange behavior with $this).
+ (Bob Weinand)
+
- CLI server:
. Fixed bug #65818 (Segfault with built-in webserver and chunked transfer
encoding). (Felipe)
--- /dev/null
+--TEST--
+Bug #65911 (scope resolution operator - strange behavior with $this)
+--FILE--
+<?php
+class A {}
+
+class B
+{
+ public function go()
+ {
+ $this->foo = 'bar';
+ echo A::$this->foo; // should not output 'bar'
+ }
+}
+
+$obj = new B();
+$obj->go();
+?>
+--EXPECTF--
+Fatal error: Access to undeclared static property: A::$this in %s on line %d
{
if ((opline->opcode == ZEND_FETCH_W) && (opline->op1_type == IS_CONST)
&& (Z_TYPE(CONSTANT(opline->op1.constant)) == IS_STRING)
+ && ((opline->extended_value & ZEND_FETCH_STATIC_MEMBER) != ZEND_FETCH_STATIC_MEMBER)
&& (Z_HASH_P(&CONSTANT(opline->op1.constant)) == THIS_HASHVAL)
&& (Z_STRLEN(CONSTANT(opline->op1.constant)) == (sizeof("this")-1))
&& !memcmp(Z_STRVAL(CONSTANT(opline->op1.constant)), "this", sizeof("this"))) {