View Issue Details

IDProjectCategoryView StatusLast Update
0001192XdebugUncategorizedpublic2015-11-05 15:08
ReporterGisleburt Assigned Toderick  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
PlatformVirtual BoxOSUbuntuOS Version14.04
Product Version2.3.2 
Fixed in Version2.4.0beta1 
Summary0001192: Dead code analysis does not work for generators with 'return;'

There seems to be an issue where code that should be marked as "Dead Code", is marked as "Uncovered" when using an early return in a generator.

Steps To Reproduce


    "require": {
        "phpunit/phpunit": "5.0.8"



require 'vendor/autoload.php';

function gen(&$output, $branch = false)

    if($branch) {
        $output = 'branched';
    } // This line is never covered.
    $output = 'did not branch';


class GenTest extends \PHPUnit_Framework_TestCase

    public function testGen()
        $output = '';
        $gen = gen($output);

        while($gen->valid()) {

            'did not branch',

        $output = '';
        $gen = gen($output, true);

        while($gen->valid()) {




$ vendor/bin/phpunit --coverage-html reports --whitelist test.php test.php




$ php --version
PHP (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans

$ composer show -i
doctrine/instantiator             1.0.5  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
myclabs/deep-copy                 1.4.0  Create deep copies (clones) of your objects
phpdocumentor/reflection-docblock 2.0.4
phpspec/prophecy                  v1.5.0 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage         3.0.1  Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator         1.4.1  FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template         1.2.1  Simple template engine.
phpunit/php-timer                 1.0.7  Utility class for timing
phpunit/php-token-stream          1.4.8  Wrapper around PHP's tokenizer extension.
phpunit/phpunit                   5.0.8  The PHP Unit Testing framework.
phpunit/phpunit-mock-objects      3.0.3  Mock Object library for PHPUnit
sebastian/comparator              1.2.0  Provides the functionality to compare PHP values for equality
sebastian/diff                    1.3.0  Diff implementation
sebastian/environment             1.3.2  Provides functionality to handle HHVM/PHP environments
sebastian/exporter                1.2.1  Provides the functionality to export PHP variables for visualization
sebastian/global-state            1.1.1  Snapshotting of global state
sebastian/recursion-context       1.0.1  Provides functionality to recursively process PHP variables
sebastian/resource-operations     1.0.0  Provides a list of PHP built-in functions that operate on resources
sebastian/version                 1.0.6  Library that helps with managing the version number of Git-hosted PHP projects
symfony/yaml                      v2.7.5 Symfony Yaml Component
Additional Information

This bug also reported at

TagsNo tags attached.
Attached Files
Operating System
PHP Version5.6.10-5.6.14



2015-10-25 10:40

administrator   ~0003195

This seems to be because Xdebug (and VLD) don't see the "GENERATOR_RETURN" opcode as a jump (to exit) opcode. Fix on the way.


2015-10-26 20:39

administrator   ~0003196

Fixed for 2.3.4 and 3.0.0-dev.

Issue History

Date Modified Username Field Change
2015-10-23 12:39 Gisleburt New Issue
2015-10-23 12:39 Gisleburt File Added: 2015-10-23 13_31_24-Code Coverage for _www_test_test.php.png
2015-10-25 10:40 derick Note Added: 0003195
2015-10-25 10:40 derick Assigned To => derick
2015-10-25 10:40 derick Status new => confirmed
2015-10-26 20:39 derick Note Added: 0003196
2015-10-26 20:39 derick Status confirmed => closed
2015-10-26 20:39 derick Resolution open => fixed
2015-10-26 20:39 derick Fixed in Version => 2.3.4
2015-10-26 20:40 derick Summary Coverage of early return in generators => Dead code analysis does not work for generators with 'return;'
2015-11-05 15:08 derick Fixed in Version 2.3.4 => 2.4.0beta1
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