php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73713 Static var in class func initialized after same func of parent class is called
Submitted: 2016-12-10 18:45 UTC Modified: 2016-12-20 04:34 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: thomas at beamstyle dot com dot hk Assigned:
Status: Open Package: Class/Object related
PHP Version: 5.6.25 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-12-10 18:45 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-10 18:46 UTC] thomas at beamstyle dot com dot hk
-PHP Version: 5.6.29 +PHP Version: 5.6.25
 [2016-12-10 18:46 UTC] thomas at beamstyle dot com dot hk
PHP version typo
 [2016-12-20 04:34 UTC] thomas at beamstyle dot com dot hk
Hello there, doesn't seem so active here.  Does anyone happy to see this issue?
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Feb 18 14:01:25 2019 UTC