php-code-coverage: Executable code not shown as executed/executable
Moved here from #411 (where more than one issue was discussed).
Environment
- Linux
- PHP 7.1.0RC6
- Xdebug 2.5.0RC1
- PHPUnit 5.6.7
- php-code-coverage 4.0.3
Steps to reproduce
git clone https://github.com/ramsey/uuid-doctrine.git
cd uuid-doctrine
git checkout abbcbe56b023319dea7a72177333089cf47f5a69
composer install
./vendor/bin/phpunit
Actual result
Expected result
Lines 50-52 of the uuid-doctrine/src/UuidBinaryType.php
files should not be white.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 5
- Comments: 30 (17 by maintainers)
Commits related to this issue
- Fix issue #488 Since I am new to the project and codebase, I am unsure if my fix is correct, but tested it using the method in issue #488 and it works. My concerns are however, as follows: why does t... — committed to JoepRoebroek/php-code-coverage by JoepRoebroek 8 years ago
- Improved fix for #488 — committed to JoepRoebroek/php-code-coverage by JoepRoebroek 8 years ago
- Remove previous fix for #488 — committed to JoepRoebroek/php-code-coverage by JoepRoebroek 8 years ago
FYI I see xdebug 2.5.1 was released today and includes the patch for this issue https://xdebug.org/updates.php#x_2_5_1
It does! Please add an xdebug ticket with the relevant info!
https://github.com/xdebug/xdebug/commit/80e9144b47f1847eb80f33f89e6f9c07eb4d8c7c
So I guess this can be closed now.
Ok, after some digging I have been able to build a small script that reproduces the problem in XDebug and it is completely independent of the phpunit code. Here it is:
As you can see TestClass extends TestClass2. When I remove
extends TestClass2
, the bug does not occur. Also, when I put the lineinclude 'TestClass2.php'
directly inTestClass.php
, the bug also does not occur. So it has to do with the fact that the class is included in a top level file, but extended from in another file. The bug does occur in PHP7, but not in PHP5.This shows an XDebug related issue, therefore I will start an issue thread on their bugtracker.
Fast work there! Thank you so much, I’ll compile and try out the master branch now. Kudos to JoepRoebroek for figuring the cause. Happy New Year!
Thanks @lordelph 👍
Thanks for investigating!
Ok, I investigated the code some more and concluded that my initial addition should already be done by the function
initializeFilesThatAreSeenTheFirstTime
. However this function is flawed when it is called multiple times and is presented with the same file, but where each file contains different lines in its array.Therefore, the following fix also works:
Let me know what you think. I tried phpunit with
#!/usr/bin/env php5
aswell, to see what the difference is. And with PHP5, the inital call toxdebug_get_code_coverage
returns an array with all lines containing executable code, whereas in PHP7 this does not happen. Therefore, I think the above fix is sufficient.