Code Coverage Tool
So I noticed the code covergae tool in PHPStorm Beta 4 doesn't count the last line of methods with return statements as covered? Is anyone else having this issue or just me? Bug or feature?
Attachment(s):
code_coverage.PNG
请先登录再写评论。
Hi Edgar,
Code coverage data is supplied by PHPUnit and PhpStorm just displays this data -- nothing more.
Open the coverage xml file (should be located in C:\Users\USERNAME\.WebIde40\system\coverage\ folder on Windows 7) and check yourself (or post it here and I can can tell you where to look).
BTW -- what PHPUnit's own HTML Report says about the same line? Add something like this to your phpunit.xml file:
From my experience with PHPUnit and xdebug combo -- extra empty line at the end of file or comma after last array element (if array declared with each key on separate line) can make a difference in having that line covered or not.
Hey Andriy, thanks for the response, howvere I am using Zend debuger instead of Xdebug. I checked my files and it I dont have any white space at the bottom (extra lines or anything) Ill ask on the zedn formum see if I get any info there.
So ... what PHPUnit's own HTML Report says about the same line?

It could be Zend issue -- dunno. I mean, with xdebug I have function declaration is marked as covered, but your screenshot shows shows nothing for that. That could be the difference how each of them counts the lines they are processing.
yeah the part that drives me nuts is that the lines covered reads less than it should be if I have 10 method with return statments in a class with 100 lines of code the coverage reads 90% which sucks
I will look inot it some more and see if it is a zend thing or maybe something else that can be done.
About numbers ... I have 100% line coverage in some files (and PHPUnit own report confirms it) but PhpStorm still shows like 98% .. 96% only -- just because when those "totals" are calculated, wrong fields from coverage.xml file are used (WI-9910)
I suggest to compare PhpStorm results with PHPUnit own reports, and if they differ -- report as a bug (as I would assume that long-time used PHPUnit reports to be more accurate here). Otherwise -- good luck hunting the reasons.
Hi, Edgar,
Sorry for the delay.
It is related to the PHP internals. PHP consider '}' as a last executabe statement if the function finish execution without 'return' statement. You can even put a breakpoint on this line and a script will break at it. At the moment PhpStorm just shows a raw coverage data obtained from Zend Debugger, but I think that we can post-process all incoming reports and filter some tricky stuff like this. I submited an issue about that - http://youtrack.jetbrains.com/issue/WI-10769.
Thank you for feedback!
Andriy,
Thanks for the assistance!;)
Andriy,
It depends on coverage extension. There is usually some difference in Zend Debugger and Xdebug coverage reports.
Thank you for feedback!
Andriy,
Please note that highlighting of the lines with methods declaration is the result of PHPUnit post-processing since PHP and Xdebug know nothing about methods. Xdebug just give you a set of all covered lines.
thank you Nokolay, I plus oned it.