|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-05-04 06:05 UTC] guoxiao08 at gmail dot com
Description:
------------
Call a private static function in a subclass, and it failed in 5.5.
However it runs normally in php 5.4
Test script:
---------------
<?php
class A {
private static function testprivate() {
return 1;
}
public static function test() {
return function() {
return self::testprivate();
};
}
}
class B extends A {
}
$fn = B::test();
echo $fn();
Expected result:
----------------
1
Actual result:
--------------
Fatal error: Call to private method A::testprivate() from context 'B' in /tmp/test.php on line 9
Call Stack:
0.0048 645824 1. {main}() /tmp/test.php:0
0.0048 646304 2. B::{closure:/tmp/test.php:8-10}() /tmp/test.php:18
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
I think this is conflicts with: <?php class A { static function foo() { $f = function() { return static::class; }; return $f(); } } class B extends A {} var_dump(B::foo()); ?> :<