View Issue Details

IDProjectCategoryView StatusLast Update
0001258XdebugUncategorizedpublic2016-02-23 20:25
Reporterasgrim Assigned To 
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version15.04
Product Version2.4.0rc3 
Fixed in Version2.4.0 
Summary0001258: Coverage does not cover case statements
Description

I have a switch statement that is fully tested, and all execution paths do not appear to be covered when viewed with PHP_CodeCoverage.

I queried on IRC, and a very kind and helpful Mr Rethans said "I probably don't overload the opcode - please submit a bug", so here it is!

I'm happy to try and create a proper reproducible test case if the provided code sample is not sufficient.

Steps To Reproduce

private function compileBinaryOp(Node\BinaryOp\AbstractBinaryOp $node, InputData $inputData)
{
$left = $this->compileNode($node->getLeft(), $inputData);
$right = $this->compileNode($node->getRight(), $inputData);

switch (get_class($node)) {
    case Node\BinaryOp\Equals::class:
        return $left == $right;
    case Node\BinaryOp\NotEquals::class:
        return $left != $right;
    case Node\BinaryOp\BooleanAnd::class:
        return $left && $right;
    case Node\BinaryOp\BooleanOr::class:
        return $left || $right;
    case Node\BinaryOp\GreaterThan::class:
        return $left > $right;
    case Node\BinaryOp\GreaterThanOrEqual::class:
        return $left >= $right;
    case Node\BinaryOp\LessThan::class:
        return $left < $right;
    case Node\BinaryOp\LessThanOrEqual::class:
        return $left <= $right;
    case Node\BinaryOp\In::class:
        return in_array($left, $right);
    case Node\BinaryOp\NotIn::class:
        return !in_array($left, $right);
    default:
        throw UnknownNodeType::fromNode($node);
}

}

TagsNo tags attached.
Operating SystemUbuntu 15.04
PHP Version7.0.0-7.0.4

Activities

robob4him

2016-02-15 22:34

reporter   ~0003495

Confirmed for 2.4.0rc4

derick

2016-02-23 20:25

administrator   ~0003515

Fixed for 2.4.0. Thanks for the report, and the PR with the test case!