Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:17:33+00:00 2026-05-28T01:17:33+00:00

I’m using PHPUnit 3.6.7, PHP_CodeCoverage 1.1.1, and Xdebug 2.1.2. When I have PHPUnit write

  • 0

I’m using PHPUnit 3.6.7, PHP_CodeCoverage 1.1.1, and Xdebug 2.1.2. When I have PHPUnit write my code coverage statistics to a clover-style XML file, it occasionally shows a close-curly-brace as not being covered by tests.

I see a lot of discussion online of when PHPUnit is “reaching” the close curly-braces, but I don’t understand the general concept of what’s going on. For example, I have zero coverage on one line here:

if (is_array($foo)) {
    foreach ($foo as $bar) {
        if (property_exists($bar, 'baz')) {
            return $bar;
        }
    }
}  // this line has 0 coverage
return null;

And here:

class Foo
{
    public $myProperty;
    public function myMethod()
    {
        $this->myProperty = '1';
    }
}  // this line has 0 coverage

Other classes in my project don’t have this problem; their close-curly-braces don’t show up in the XML file at all, so they are not listed as having zero coverage.

I understand that PHP_CodeCoverage 1.1.2 (not released yet) will let me put a “// @codeCoverageIgnore” comment after a close curly-brace, but until that’s available I want to know what’s going on, so that I can fix my tests to give me complete coverage. What’s the rule-of-thumb to tell me when a curly-brace should be counted as “covered” or “not covered”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:17:34+00:00Added an answer on May 28, 2026 at 1:17 am

    What’s the rule-of-thumb to tell me when a curly-brace should be counted as "covered" or "not covered"?

    There is a "Edge Cases" section in the phpunit documentation but that apparently isn’t complete as I’ve learned in the last view days 🙂

    What I’ve personally never seen is your second example failing. I also couldn’t reproduce it: I couldn’t find a PHP/xDebug/PHPUnit combination where this didn’t work out. (Reproduce below)

    The same goes for the other case you showed. For all I could test both closing braces where detected as "not executable/reachable" just like one would expect it.

    So for both of those cases no //@codeCoverageIgnore or //@codeCoverageIgnore[Start|End] should be needed.

    As @Derick suggested in the comments for any further analysis the whole file would be needed.


    Reproduce

    <?php
    
    class Foo
    {
        public $myProperty;
        public function myMethod()
        {
            $this->myProperty = '1';
        }
    }
    
    <?php
    
    require __DIR__ . '/closingBrace.php';
    
    class FooTest extends PHPUnit_Framework_TestCase {
    
        public function testMyMethod() {
            $x = new Foo();
            $x->myMethod();
        }
    
    }
    

    Running phpunit --coverage-text fooTest.php

    Code Coverage Report 
      2012-01-12 10:17:32
    
     Summary: 
      Classes: 100.00% (1/1)
      Methods: 100.00% (1/1)
      Lines:   100.00% (2/2)
    

    which only marks the $this->myProperty = '1'; it’s closing brace as executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.