php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55825 Missing initial value of static locals in trait methods
Submitted: 2011-09-30 22:18 UTC Modified: 2011-10-03 17:03 UTC
From: ottoni at fb dot com Assigned: laruence (profile)
Status: Closed Package: *General Issues
PHP Version: 5.4SVN-2011-09-30 (snap) OS: Linux
Private report: No CVE-ID: None
 [2011-09-30 22:18 UTC] ottoni at fb dot com
Description:
------------
The initial value of static locals inside trait methods is being lost.




Test script:
---------------
<?php
trait T1 {
  public function inc() {
    static $x=1;
    echo $x++ . "\n";
  }
}
class C { use T1; }
$c1 = new C;
$c1->inc();
$c1->inc();


Expected result:
----------------
1
2


Actual result:
--------------
1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-03 16:54 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2011-10-03 17:00 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=317672
Log: Fixed bug #55825, and add test script
 [2011-10-03 17:03 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2011-10-03 17:03 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=37e1ed68e50b3f695da310a445fdfa8abd39386d
Log: Fixed bug #55825, and add test script
 [2012-07-24 23:39 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=37e1ed68e50b3f695da310a445fdfa8abd39386d
Log: Fixed bug #55825, and add test script
 [2013-11-17 09:36 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=37e1ed68e50b3f695da310a445fdfa8abd39386d
Log: Fixed bug #55825, and add test script
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC