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: 2020-07-05 04:22 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: No Feedback Package: Class/Object related
PHP Version: 5.6.25 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
44 - 13 = ?
Subscribe to this entry?

 
 [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?
 [2020-06-25 08:07 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2020-06-25 08:07 UTC] nikic@php.net
It looks like the script.txt is no longer available, so it's no longer possible to understand what this bug report was about :(
 [2020-07-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 21:01:29 2024 UTC