php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66199 Access to undeclared static property: static::$this
Submitted: 2013-11-29 09:18 UTC Modified: 2013-11-29 14:14 UTC
From: gulturyan at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.22 OS: Ubuntu 12.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: gulturyan at gmail dot com
New email:
PHP Version: OS:

 

 [2013-11-29 09:18 UTC] gulturyan at gmail dot com
Description:
------------
in version 5.4.22 not working static::$this
in version 5.4.21 still work.

Test script:
---------------
class A {
    
    public function aa() {
        return get_class(static::$this);
    }
    
}

class A2 extends A {
    
}

$a = new A2();

die(var_dump($a->aa()));

Expected result:
----------------
A2

Actual result:
--------------
Fatal error: Access to undeclared static property: A2::$this

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-29 09:20 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2013-11-29 09:20 UTC] nikic@php.net
You are accessing the static property $this, which does not exist in your code sample. So you get an error. What's incorrect about this?
 [2013-11-29 12:44 UTC] gulturyan at gmail dot com
perhaps it was an undocumented feature
sorry.
I can use get_called_class()
 [2013-11-29 14:14 UTC] bwoebi@php.net
That static::$this worked was a bug. See also https://bugs.php.net/bug.php?id=65911

static::$this in PHP 5.4.21 was equal to just $this.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 13:01:36 2025 UTC