|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 06:00:02 2025 UTC |
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