View Issue Details

IDProjectCategoryView StatusLast Update
0001440XdebugCode Coveragepublic2017-05-28 17:07
Reporterfreyr Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version2.5.4 
Summary0001440: Code coverage in interfaces shows group use declarations written in multiline as uncovered code
Description

If you tried to write use declarations as group eg:
use some\namespace{
ClassA, ClassB, ClassC as C
};

then code-coverage shows line after first \n as uncovered
If you declare it in one line:
use some\namespace{ClassA, ClassB, ClassC as C};
Then problem doesn't occure.
This affects only interfaces afaik.

Steps To Reproduce

Clone repository: https://github.com/freyr/photo-gallery
composer install

php -dxdebug.coverage_enable=1 vendor/phpunit/phpunit/phpunit --coverage-text --testsuite unit

Then fix use declaration in Freyr\Gallery\Model\Gallery\Manage\PhotoManageRepository or Freyr\Gallery\Model\Gallery\PhotoRepository and run tests again.

TagsNo tags attached.
Operating System
PHP Version7.1.5-7.1.9

Activities

vpassapera

2017-05-23 19:22

reporter   ~0004345

Seems like this might be related to

https://github.com/sebastianbergmann/php-code-coverage/issues/526

"Incorrect coverage reported", specially if since that seems to occur in multi-line declarations.

derick

2017-05-24 21:17

administrator   ~0004347

I can reproduce this, but I can not see where PHP actually generates code
for the two unmarked lines. VLD simply has a NOP on the first line only:

filename: /home/derick/dev/php/xdebug-reproduce-cases/1440/photo-gallery/src/Model/Gallery/Manage/PhotoManageRepository.php
function name: (null)
number of ops: 6
compiled vars: none
line #* E I O op fetch ext return operands

2 0 E > NOP
4 1 NOP
6 2 NOP
14 3 EXT_STMT
4 NOP
33 5 > RETURN

I looked a bit further, and no where does Xdebug even return this file
as part of code coverage. The only files for which Xdebug returns code
coverage is:

string(101) "/home/derick/dev/php/xdebug-reproduce-cases/1440/photo-gallery/tests/Unit/Model/Gallery/PhotoTest.php"
string(106) "/home/derick/dev/php/xdebug-reproduce-cases/1440/photo-gallery/tests/Unit/Model/Import/ImportPhotoTest.php"
string(109) "/home/derick/dev/php/xdebug-reproduce-cases/1440/photo-gallery/src/SharedKernel/NameForCollectionOfPhotos.php"
string(90) "/home/derick/dev/php/xdebug-reproduce-cases/1440/photo-gallery/src/Model/Gallery/Photo.php"
string(95) "/home/derick/dev/php/xdebug-reproduce-cases/1440/photo-gallery/src/Model/Import/ImportPhoto.php"

Found out by adding a var_dump(array_keys($data)); behind the
xdebug_stop_code_coverage in
vendor/phpunit/php-code-coverage/src/Driver/Xdebug.php).

I have to conclude that PHPCodeCoverage does something interesting here and
I would suggest you file a bug through
https://github.com/sebastianbergmann/php-code-coverage

vpassapera

2017-05-24 21:55

reporter   ~0004349

I did open a bug related to this in the php-code-coverage repo, and they closed it and said the problem was here.

https://github.com/sebastianbergmann/php-code-coverage/issues/526

sebastian

2017-05-26 14:55

reporter   ~0004351

@vpassapera: This has nothing to do with what you reported in https://github.com/sebastianbergmann/php-code-coverage/issues/526.

What you reported in https://github.com/sebastianbergmann/php-code-coverage/issues/526#issue-227935416 was fixed by Derick and Xdebug. It has nothing to do with what @freyr reported here.

What you reported in https://github.com/sebastianbergmann/php-code-coverage/issues/526#issuecomment-304151561 also has nothing to do with what @freyr reported here.

@freyr: It looks like you have discovered a visualization issue related to multi-use statements. @derick opened a ticket for this at https://github.com/sebastianbergmann/php-code-coverage/issues/530 and I will work on this ASAP.

derick

2017-05-28 17:07

administrator   ~0004352

This is not related to Xdebug, but rather how PHP Code Coverage works. As no work is required here, I am closing this issue.

Issue History

Date Modified Username Field Change
2017-05-20 09:58 freyr New Issue
2017-05-23 19:22 vpassapera Note Added: 0004345
2017-05-24 21:17 derick Note Added: 0004347
2017-05-24 21:55 vpassapera Note Added: 0004349
2017-05-26 14:55 sebastian Note Added: 0004351
2017-05-28 17:07 derick Note Added: 0004352
2017-05-28 17:07 derick Status new => resolved
2017-05-28 17:07 derick Resolution open => no change required
2017-05-28 17:07 derick Assigned To => derick