Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

@codeCoverageIgnore #14

Closed
eskwayrd opened this issue Apr 6, 2011 · 1 comment
Closed

@codeCoverageIgnore #14

eskwayrd opened this issue Apr 6, 2011 · 1 comment

Comments

@eskwayrd
Copy link

eskwayrd commented Apr 6, 2011

@codeCoverageIgnore has no effect when the method we wish to ignore is:

/**
 * @codeCoverageIgnore
 */
final private function __construct() {}

The problem is in Token.php, line 119:

    for ($i = $this->id - 2; $i > $this->id - 6; $i -= 2) {

The comparison should be '>=' instead of '>', or the lower bound should be 8 instead of 6.

@sebastianbergmann
Copy link
Owner

The code in the master branch (which will become PHP_TokenStream 1.1 to be used by PHP_CodeCoverage 1.1 and PHPUnit 3.6) is different:

public function getDocblock()
{
    $tokens            = $this->tokenStream->tokens();
    $currentLineNumber = $tokens[$this->id]->getLine();
    $prevLineNumber    = $currentLineNumber - 1;

    for ($i = $this->id - 1; $i; $i--) {
        if (!isset($tokens[$i])) {
            return;
        }

        if ($tokens[$i] instanceof PHP_Token_FUNCTION ||
            $tokens[$i] instanceof PHP_Token_CLASS ||
            $tokens[$i] instanceof PHP_Token_TRAIT) {
            // Some other trait, class or function, no docblock can be
            // used for the current token
            break;
        }

        $line = $tokens[$i]->getLine();

        if ($line == $currentLineNumber ||
            ($line == $prevLineNumber &&
             $tokens[$i] instanceof PHP_Token_WHITESPACE)) {
            continue;
        }

        if ($line < $currentLineNumber &&
            !$tokens[$i] instanceof PHP_Token_DOC_COMMENT) {
            break;
        }

        return (string)$tokens[$i];
    }
}

If the problem persist with PHP_TokenStream 1.1 and PHP_CodeCoverage 1.1 please open a new ticket. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants