View Issue Details

IDProjectCategoryView StatusLast Update
0001032XdebugUncategorizedpublic2014-03-05 09:42
Reporteraik099Assigned Toderick 
Status resolvedResolutionno change required 
PlatformOSSlackwareOS Version13
Product Version2.2.3 
Target VersionFixed in Version 
Summary0001032: Incorrect coverage reporting for multi-line class creation
DescriptionI've found out, that in following cases (see image) coverage information being incorrectly collected by xdebug or displayed in report:

1. constant usage in multiline exception constructor call
2. closing brace for private method, that is last method in class
Additional InformationRelated issue:
TagsNo tags attached.
Operating SystemLinux
PHP Version5.4.15-5.4.20



2014-02-22 18:26


IncorrectCoverage.png (150,745 bytes)
IncorrectCoverage.png (150,745 bytes)


2014-02-22 18:41

reporter   ~0002674

Last edited: 2014-02-22 18:48

View 2 revisions

Relevant "clover.xml" part:

<package name="aik099\QATools\BEM\PropertyDecorator">
      <file name=".../library/aik099/QATools/BEM/PropertyDecorator/BEMPropertyDecorator.php">
        <class name="BEMPropertyDecorator" namespace="aik099\QATools\BEM\PropertyDecorator">
          <metrics methods="5" coveredmethods="5" conditionals="0" coveredconditionals="0" statements="36" coveredstatements="30" elements="41" coveredelements="35"/>
        <line num="56" type="method" name="__construct" crap="1" count="15"/>
        <line num="58" type="stmt" count="15"/>
        <line num="60" type="stmt" count="15"/>
        <line num="61" type="stmt" count="15"/>
        <line num="62" type="stmt" count="15"/>
        <line num="72" type="method" name="doDecorate" crap="6.81" count="10"/>
        <line num="74" type="stmt" count="10"/>
        <line num="76" type="stmt" count="10"/>
        <line num="77" type="stmt" count="1"/>
        <line num="80" type="stmt" count="9"/>
        <line num="82" type="stmt" count="8"/>
        <line num="83" type="stmt" count="8"/>
        <line num="85" type="stmt" count="0"/>
        <line num="88" type="stmt" count="0"/>
        <line num="89" type="stmt" count="0"/>
        <line num="90" type="stmt" count="0"/>
        <line num="92" type="stmt" count="0"/>
        <line num="95" type="stmt" count="1"/>
        <line num="105" type="method" name="_isBEMBlock" crap="1" count="9"/>
        <line num="107" type="stmt" count="9"/>
        <line num="117" type="method" name="_isBEMElement" crap="1" count="5"/>
        <line num="119" type="stmt" count="5"/>
        <line num="131" type="method" name="_assertAnnotationUsage" crap="10.02" count="8"/>
        <line num="133" type="stmt" count="8"/>
        <line num="134" type="stmt" count="2"/>
        <line num="135" type="stmt" count="2"/>
        <line num="137" type="stmt" count="2"/>
        <line num="141" type="stmt" count="6"/>
        <line num="143" type="stmt" count="6"/>
        <line num="144" type="stmt" count="4"/>
        <line num="145" type="stmt" count="4"/>
        <line num="147" type="stmt" count="4"/>
        <line num="149" type="stmt" count="2"/>
        <line num="150" type="stmt" count="1"/>
        <line num="151" type="stmt" count="1"/>
        <line num="153" type="stmt" count="1"/>
        <line num="155" type="stmt" count="1"/>
        <line num="156" type="stmt" count="1"/>
        <line num="157" type="stmt" count="1"/>
        <line num="159" type="stmt" count="1"/>
        <line num="161" type="stmt" count="0"/>
        <line num="164" type="stmt" count="0"/>
        <metrics loc="163" ncloc="97" classes="1" methods="5" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="36" coveredstatements="30" elements="41" coveredelements="33"/>

Actually line 164 is empty line at the end of a file. And I'm using TABs for indentation if that helps.


2014-03-05 09:25

administrator   ~0002748

I can not do anything about point 1, as PHP doesn't always correctly identify which lines code belongs too. This should be addressed in the PHP parser itself.

As for issue 2, can you perhaps provide me with a short example that reproduces this? It is possible that you really don't reach the end of the function — there is an implicit "return NULL" there which you technically could hit if $annotations is set, but doesn't match any of your three if/elseif clauses.


2014-03-05 09:33

reporter   ~0002753

1 - got it.

2 - I see, maybe in my tests I always hit all these IF/ELSE and never actually getting to the end of the method. Never thought of that.

Actually you might be right, since after I've improved my coverage (method code wasn't changed) the line with a brace became covered too. Now I surely will consider closing brace of a method as "return null;" to make it clear what really happens.

Thanks for detailed explanation.

No bug then. You can safely close it.


2014-03-05 09:42

administrator   ~0002758

All right. Thanks for listening :-)

Issue History

Date Modified Username Field Change
2014-02-22 18:26 aik099 New Issue
2014-02-22 18:26 aik099 File Added: IncorrectCoverage.png
2014-02-22 18:41 aik099 Note Added: 0002674
2014-02-22 18:48 aik099 Note Edited: 0002674 View Revisions
2014-03-05 09:25 derick Note Added: 0002748
2014-03-05 09:25 derick Assigned To => derick
2014-03-05 09:25 derick Status new => feedback
2014-03-05 09:33 aik099 Note Added: 0002753
2014-03-05 09:33 aik099 Status feedback => assigned
2014-03-05 09:42 derick Note Added: 0002758
2014-03-05 09:42 derick Status assigned => resolved
2014-03-05 09:42 derick Resolution open => no change required
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized