View Issue Details

IDProjectCategoryView StatusLast Update
0001784XdebugCode Coveragepublic2020-05-18 14:41
Reporterabhituls55@gmail.comAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionnot fixable 
Product Version2.9.5 
Target VersionFixed in Version 
Summary0001784: Values inside the array are being treated as non-executable code.
DescriptionI am using xdebug with phpunit 7.5. I am getting white-lines (non-executable code) on some lines which are actually executing and should be treated as executable code. All these lines are inside array.
For eg.
155 [
156 'stockareaId.required' => 'Stockarea Id is required required',
157 'product_lots.required' => 'Product Lots is required',
158 'product_lots.array' => 'Product Lots must be array',
159 'product_lots.*.string' => 'Product Lot number must be an alphanumeric string',
160 'product_lots.*.alpha_num' => 'Product Lot number must be an alphanumeric string',
161 'product_lots.*.unique' => 'Product Lot number must be unique to the product',
162 'product_lots.*.distinct' => 'Product Lot numbers for the product must be distinct',
163 ]);
164

In this only 156 was coming green. All others are neither red nor green. I am 100% sure other values in array are also getting executed since my test-cases are verifying their outputs and have also used my own debugging. But Xdebug is showing them non-executable code. But firstly they are executable code and secondly they are not getting shown as exectued.
Tagsvisual html
Operating Systemwindows 10
PHP Version7.3.5-7.3.9

Activities

abhituls55@gmail.com

2020-05-17 23:36

reporter  

error.PNG (35,694 bytes)
error.PNG (35,694 bytes)

derick

2020-05-18 00:08

administrator   ~0005412

It's very likely that PHP has optimised these executable lines away, it's kinda smart like that. Please provide the full *PHP* file that has this problem as an attachment.

abhituls55@gmail.com

2020-05-18 13:50

reporter   ~0005413

Here is the php file you asked for which contains this code.

ProductController.php (12,018 bytes)

derick

2020-05-18 14:17

administrator   ~0005414

Last edited: 2020-05-18 14:17

View 2 revisions

PHP's Engine has generated the following internal code for this:

 147    27        INIT_ARRAY                                       0000015:0000007      <array>, 'stockarea_id'
        28        ADD_ARRAY_ELEMENT                                0000015:0000007      <array>, 'product_lots'


Although it has created the array with the first element correctly on line 147, it also did the addition of the second array element on that same line, and not on line *148*.

 149    29        INIT_ARRAY                                       0000017:0000008      'required'
        30        ADD_ARRAY_ELEMENT                                0000017:0000008      'string'
        31        ADD_ARRAY_ELEMENT                                0000017:0000008      'alpha_num'
        32        ADD_ARRAY_ELEMENT                                0000017:0000008      'distinct'
 150    33        INIT_STATIC_METHOD_CALL                                  'Illuminate%5CValidation%5CRule', 'unique'
        34        EXT_FCALL_BEGIN                                          
        35        SEND_VAL_EX                                              'product_lots'
        36        SEND_VAL_EX                                              'lot_number'
        37        DO_FCALL                                      0  $9      
        38        EXT_FCALL_END                                            
        39        INIT_METHOD_CALL                                         $9, 'where'
        40        EXT_FCALL_BEGIN                                          
        41        DECLARE_LAMBDA_FUNCTION                                  '%00app%5Chttp%5Ccontrollers%5Cadmin%5C%7Bclosure%7D%2Ftmp%2FProductController.php0x7fb0d95af5ec'
        42        BIND_LEXICAL                                             0000015:0000009, !2

I don't quite understand why line 150 isn't in your coverage output, I think it should show up. However, I can't really run this code, so I can not investigate that now. If you'd like me to find out, please submit a new bug report that I can run locally—preferably as short as possible as is described in the documentation (https://xdebug.org/reporting-bugs).
 153    43        SEND_VAL_EX                                              0000015:0000009
        44        DO_FCALL                                      0  $9      
        45        EXT_FCALL_END                                            
        46        ADD_ARRAY_ELEMENT                                0000017:0000008      $9
        47        ADD_ARRAY_ELEMENT                                0000015:0000007      0000017:0000008, 'product_lots.%2A'
        48        SEND_VAL_EX                                              0000015:0000007

The above adds the result of the Rule::unique call to the array.
 156    49        SEND_VAL_EX                                              <array>
        50        DO_FCALL                                      0  $7      
        51        EXT_FCALL_END                                            
        52        ASSIGN                                                   !3, $7

PHP has indeed optimised the whole array creation from line 156 to 162 into one line as I expected. This makes it look like PHP didn't execute the code, but it was just clever and optimised this into a constant array (SEND_VAL_EX <array> gives that away). I can't do anything about this on the Xdebug side of things.
 165    53        EXT_STMT                                                 
        54        INIT_METHOD_CALL                                         !3, 'fails'
        55        EXT_FCALL_BEGIN                                          
        56        DO_FCALL                                      0  $7      
        57        EXT_FCALL_END                                            
        58      > JMPZ                                                     $7, ->76

This then calls the 'fails()' method on line 165.

abhituls55@gmail.com

2020-05-18 14:41

reporter   ~0005415

Thanks derick for your help and information. I can't product a reduced test, as it would take sufficient time for me to generate it and for you to go through it as these test cases are bonded with phpunit inside laravel framework. But still I got the idea where the problem can be. Thanks for help.

Issue History

Date Modified Username Field Change
2020-05-17 23:36 abhituls55@gmail.com New Issue
2020-05-17 23:36 abhituls55@gmail.com Tag Attached: visual html
2020-05-17 23:36 abhituls55@gmail.com File Added: error.PNG
2020-05-18 00:08 derick Assigned To => derick
2020-05-18 00:08 derick Status new => feedback
2020-05-18 00:08 derick Note Added: 0005412
2020-05-18 13:50 abhituls55@gmail.com File Added: ProductController.php
2020-05-18 13:50 abhituls55@gmail.com Note Added: 0005413
2020-05-18 13:50 abhituls55@gmail.com Status feedback => assigned
2020-05-18 14:17 derick Status assigned => resolved
2020-05-18 14:17 derick Resolution open => not fixable
2020-05-18 14:17 derick Note Added: 0005414
2020-05-18 14:17 derick Note Edited: 0005414 View Revisions
2020-05-18 14:41 abhituls55@gmail.com Note Added: 0005415