php.net |  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: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ori at uumpa dot com
New email:
PHP Version: OS:

 

 [2013-10-16 09:23 UTC] ori at uumpa dot com
Description:
------------
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:

STATIC_CLASS::$this->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();
$obj->go();


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'

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-16 16:42 UTC] nikic@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4c0bb6d76eb0c8b9fdc74c3c8858a146ab34e2f8
Log: Fixed bug #65911 ($this not usable as static property)
 [2013-10-16 16:42 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2014-10-07 23:16 UTC] stas@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4c0bb6d76eb0c8b9fdc74c3c8858a146ab34e2f8
Log: Fixed bug #65911 ($this not usable as static property)
 [2014-10-07 23:27 UTC] stas@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4c0bb6d76eb0c8b9fdc74c3c8858a146ab34e2f8
Log: Fixed bug #65911 ($this not usable as static property)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC