Bug #73713 [Opn->Fbk]: Static var in class func initialized after same func of parent class is called
Edit report at https://bugs.php.net/bug.php?id=73713&edit=1
ID: 73713
Updated by: nikic@php.net
Reported by: thomas at beamstyle dot com dot hk
Summary: Static var in class func initialized after same func
of parent class is called
-Status: Open
+Status: Feedback
Type: Bug
Package: Class/Object related
Operating System: Windows
PHP Version: 5.6.25
Block user comment: N
Private report: N
New Comment:
It looks like the script.txt is no longer available, so it's no longer possible to understand
what this bug report was about :(
Previous Comments:
------------------------------------------------------------------------
[2016-12-20 04:34:46] thomas at beamstyle dot com dot hk
Hello there, doesn't seem so active here. Does anyone happy to see this issue?
------------------------------------------------------------------------
[2016-12-10 18:46:46] thomas at beamstyle dot com dot hk
PHP version typo
------------------------------------------------------------------------
[2016-12-10 18:45:40] thomas at beamstyle dot com dot hk
Description:
------------
-----
When all 3 classes are in one file, everything works fine, and Test Script A (main) gives expected
output.
However, when you separate the classes into 3 files and using autoloading (PSR-4 via composer, but
probably doesn't matter what standard we use), this fails...
-----
Also, one more interesting fact is if you try Test Script B (on the side), It seems to work as
expected, though it should not make any difference based on my class declaration.
Test script:
---------------
Class declaration:
http://beamstyle.com.hk/download/script.txt
Test Script A (Main):
\Namespace2\B::test() . '<br>';
\Namespace2\C::test() . '<br>';
\Namespace2\B::test() . '<br>';
\Namespace2\C::test() . '<br>';
Test Script B (On the side):
\Namespace2\C::test() . '<br>';
\Namespace2\B::test() . '<br>';
\Namespace2\C::test() . '<br>';
\Namespace2\B::test() . '<br>';
Expected result:
----------------
$var===null for the class: Namespace2\B
$var===null for the class: Namespace2\C
$var!==null for the class: Namespace2\B
$var!==null for the class: Namespace2\C
Actual result:
--------------
$var===null for the class: Namespace2\B
$var!==null for the class: Namespace2\C
$var!==null for the class: Namespace2\B
$var!==null for the class: Namespace2\C
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73713&edit=1
Thread (5 messages)