php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76860 Missed "Accessing static property as non static" warning
Submitted: 2018-09-11 09:06 UTC Modified: 2018-09-11 15:31 UTC
From: dmitry@php.net Assigned: dmitry (profile)
Status: Closed Package: *General Issues
PHP Version: master-Git-2018-09-11 (Git) OS: *
Private report: No CVE-ID: None
 [2018-09-11 09:06 UTC] dmitry@php.net
Description:
------------
Accessing private static property as non-static may miss warning message.

Test script:
---------------
<?php
class A {
    private static $a = "a";
    public function __construct() {
	var_dump($this->a);
    }
}
class B extends A {
}
new B;
?>

Expected result:
----------------
Notice: Accessing static property B::$a as non static in %s on line %d

Notice: Undefined property: B::$a in %s on line %d

NULL


Actual result:
--------------
Notice: Undefined property: B::$a in %s on line %d

NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-11 09:07 UTC] dmitry@php.net
-Assigned To: +Assigned To: dmitry
 [2018-09-11 09:11 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2018-09-11 09:11 UTC] dmitry@php.net
Fixed in master
 [2018-09-11 13:20 UTC] nikic@php.net
There is now an inconsistency with this case:


<?php
class A {
    private static $a = "a";
    public function __construct() {
	var_dump($this->a);
    }
}
class B extends A {
    private static $a = "a";
}
new B;
?>

We would have to drop this check to make it consistent: https://github.com/php/php-src/blob/master/Zend/zend_object_handlers.c#L434
 [2018-09-11 13:24 UTC] nikic@php.net
Or rather, not drop but replace it with a goto no_changed.
 [2018-09-11 15:31 UTC] dmitry@php.net
Should be fixed, as well.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed May 22 17:01:34 2019 UTC