Bug #78960 [Com]: Const Privacy on static:: doesn't match func privacy on static::
| From: | riikka dot kalliomaki at gmail dot com | Date: | Tue, 07 Apr 2020 10:47:55 +0000 |
| Subject: | Bug #78960 [Com]: Const Privacy on static:: doesn't match func privacy on static:: | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226452@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78960&edit=1
ID: 78960
Comment by: riikka dot kalliomaki at gmail dot com
Reported by: donatj at gmail dot com
Summary: Const Privacy on static:: doesn't match func privacy
on static::
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: All
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
Also ran into this problem in the context of using isset(). Would be nice to know whether this is
considered a bug or a feature going forward so that I would know whether to wait for a fix or not
before upgrade. The following test script can also illustrate the issue:
https://3v4l.org/3cJ5N
Test script:
---------------
<?php
class foo {
private static $foo = true;
public static function test() {
var_dump(isset(static::$foo));
}
}
class none extends foo {
}
class overmethod extends foo {
public static function test() {
var_dump(isset(static::$foo));
}
}
class overprop extends foo {
private static $foo = null;
}
none::test();
overmethod::test();
overprop::test();
Expected result:
----------------
bool(false)
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(false)
bool(false)
Previous Comments:
------------------------------------------------------------------------
[2020-02-07 22:39:47] googleguy@php.net
Including test script in report since link may vanish
Test script:
------------
<?php
class A {
private static function VALUE1(){
return 'func';
}
private static $VALUE2 = 'var';
private const VALUE3 = 'cost';
public static function func_value(){
return static::VALUE1();
}
public static function member_value(){
return static::$VALUE2;
}
public static function const_value(){
return static::VALUE3;
}
}
class B extends A { }
echo A::func_value();
echo "\n";
echo B::func_value();
echo "\n---\n";
echo A::member_value();
echo "\n";
echo B::member_value();
echo "\n---\n";
echo A::const_value();
echo "\n";
echo B::const_value();
------------------------------------------------------------------------
[2019-12-13 20:29:33] donatj at gmail dot com
Description:
------------
Calls to private static methods and members from the same class via static:: work in the same class
extended by another class.
Calls to private constants from the same class via static:: do not work.
Test script:
---------------
https://3v4l.org/HiPuc
Expected result:
----------------
Expect uniform behaviour in one way or the other.
Actual result:
--------------
Private methods and members are accessible. Constants are not.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78960&edit=1