View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001784 | Xdebug | Code Coverage | public | 2020-05-17 23:36 | 2020-05-18 14:41 |
| Reporter | abhituls55@gmail.com | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | not fixable | ||
| Product Version | 2.9.5 | ||||
| Summary | 0001784: Values inside the array are being treated as non-executable code. | ||||
| Description | I 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. 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. | ||||
| Tags | visual html | ||||
| Operating System | windows 10 | ||||
| PHP Version | 7.3.5-7.3.9 | ||||
|
|
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. |
|
|
Here is the php file you asked for which contains this code. |
|
|
PHP's Engine has generated the following internal code for this:
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.
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).
The above adds the result of the Rule::unique call to the array.
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.
This then calls the 'fails()' method on line 165. |
|
|
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. |