|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65911 scope resolution operator - strange behavior with $this
Submitted: 2013-10-16 09:23 UTC Modified: -
From: ori at uumpa dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.4.20 OS: ubuntu 13.04
Private report: No CVE-ID:
 [2013-10-16 09:23 UTC] ori at uumpa dot com
When using the scope resolution operator with $this it ignores everything before the scope operator and just returns whatever is after the scope operator

for example, if we are inside an object with attribute foo:


the above script returns $this->foo

I assume it should raise an error (Access to undeclared static property)

Test script:
class A {}

class B
    public function go()
	$this->foo = 'bar';
	echo A::$this->foo; // 'bar'


$obj = new B();

Expected result:
it should raise a fatal error - Access to undeclared property A::$this

Actual result:
It does not raise an error and just echoes 'bar'


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-16 16:42 UTC]
Automatic comment on behalf of
Log: Fixed bug #65911 ($this not usable as static property)
 [2013-10-16 16:42 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 17:01:58 2014 UTC