Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000829XdebugFeature/Change requestpublic2012-05-10 10:022012-07-14 20:38
Reporterphon 
Assigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionnot fixable 
PlatformOSOS Version
Product Version2.2.0 
Target Version2.2.1Fixed in Version2.2.1 
Summary0000829: Code coverage is wrong when using dim assign
DescriptionDescription:
------------
<?php
xdebug_start_code_coverage();

$result = array(
    "ret" => 0,
    "msg" => 'test'
);

var_dump(xdebug_get_code_coverage());

?>

Expected result:
----------------
array(1) {
  '/data/xdebug/test.php' =>
  array(3) {
    [4] =>
    int(1)
    [9] =>
    int(1)
  }
}

Actual result:
--------------
array(1) {
  '/data/xdebug/test.php' =>
  array(3) {
    [5] =>
    int(1)
    [7] =>
    int(1)
    [9] =>
    int(1)
  }
}
TagsNo tags attached.
Operating System
PHP Version5.2.10
Attached Files

- Relationships

-  Notes
(0002210)
derick (administrator)
2012-05-28 13:10
edited on: 2012-05-28 13:14

Sadly, this is not something I can fix. PHP is a bit weird with array assignments. Internally, the code that PHP sees is:

compiled vars:  !0 = $result
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   2     0  >   EXT_STMT                                                 
         1      EXT_FCALL_BEGIN                                          
         2      DO_FCALL                                      0          'xdebug_start_code_coverage'

         
3      EXT_FCALL_END                                            
   5     4      EXT_STMT                                                 
         5      INIT_ARRAY                                       0000002:0000001      0, 'ret'
   7     6      ADD_ARRAY_ELEMENT                                0000002:0000001      'test', 'msg'
         7      ASSIGN                                                   !0, 0000002:0000001
   9     8      EXT_STMT                                                 
         9      EXT_FCALL_BEGIN                                          
        10      EXT_FCALL_BEGIN                                          
        11      DO_FCALL                                      0  $3      'xdebug_get_code_coverage'

        
12      EXT_FCALL_END                                            
        13      SEND_VAR_NO_REF                               6          $3
        14      DO_FCALL                                      1          'var_dump'
        15      EXT_FCALL_END                                            
  12    16      EXT_STMT                                                 
        17    > RETURN                                                   1


With the array init and assignment on line 5 and 7:

   5     4      EXT_STMT                                                 
         5      INIT_ARRAY                                       0000002:0000001      0, 'ret'
   7     6      ADD_ARRAY_ELEMENT                                0000002:0000001      'test', 'msg'
         7      ASSIGN                                                   !0, 0000002:0000001



- Issue History
Date Modified Username Field Change
2012-05-10 10:02 phon New Issue
2012-05-28 09:25 derick Target Version => 2.2.1
2012-05-28 13:10 derick Note Added: 0002210
2012-05-28 13:10 derick Status new => resolved
2012-05-28 13:10 derick Resolution open => not fixable
2012-05-28 13:10 derick Assigned To => derick
2012-05-28 13:12 derick Note Edited: 0002210 View Revisions
2012-05-28 13:13 derick Note Edited: 0002210 View Revisions
2012-05-28 13:13 derick Note Edited: 0002210 View Revisions
2012-05-28 13:14 derick Note Edited: 0002210 View Revisions
2012-07-14 20:38 derick Fixed in Version => 2.2.1


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker