Skip to content
Permalink
Browse files

Merged pull request #489

  • Loading branch information...
derickr committed Jul 12, 2019
2 parents 06653c3 + 6d10f61 commit 6b73bef7329e12c0f578cb75bddca18aa3ebd177
Showing with 74 additions and 0 deletions.
  1. +16 −0 tests/bug01679.inc
  2. +31 −0 tests/bug01679.phpt
  3. +21 −0 tests/utils.inc
  4. +6 −0 xdebug.c
@@ -0,0 +1,16 @@
<?php
class pow {}
class Test
{
static $foo = 42;
public function doSomething()
{
new pow(
static::$foo,
3
);
}
}
?>
@@ -0,0 +1,31 @@
--TEST--
Test for bug #1679: Code Coverage misses static property as function argument (>= PHP 7.1)
--SKIPIF--
<?php
require __DIR__ . '/utils.inc';
check_reqs('PHP >= 7.1');
?>
--FILE--
<?php
require __DIR__ . '/utils.inc';
xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
include dirname( __FILE__ ) . '/bug01679.inc';
$o = new Test;
$o->doSomething();
$cc = xdebug_get_code_coverage();
ksort( $cc );
$fileInfo = array_values( array_slice( $cc, 0, 1 ) )[0];
mustBeExecuted( $fileInfo, [ 10, 11, 12, 14, 17 ] );
?>
--EXPECTF--
line #10 is present and covered
line #11 is present and covered
line #12 is present and covered
line #14 is present and covered
line #17 is present and covered
@@ -144,3 +144,24 @@ function check_reqs( $req_str )
die( "skip required: " . join( ' && ', $parts ) . " — missing: " . join( ' && ', $errors ) );
}
}
function mustBeExecuted( array $coverageInfo, array $lines )
{
foreach ( $lines as $line )
{
if ( !array_key_exists( $line, $coverageInfo ) )
{
echo "FAIL: line #${line} is not present in coverage info\n";
continue;
}
if ( $coverageInfo[$line] !== 1 )
{
echo "FAIL: line #${line} is not covered\n";
continue;
}
echo "line #${line} is present and covered\n";
}
}
?>
@@ -828,6 +828,9 @@ PHP_MINIT_FUNCTION(xdebug)
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_OBJ_W);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_OBJ_FUNC_ARG);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_DIM_FUNC_ARG);
#if PHP_VERSION_ID >= 70100
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_STATIC_PROP_FUNC_ARG);
#endif
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_DIM_UNSET);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_OBJ_UNSET);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_FETCH_CLASS);
@@ -1019,6 +1022,9 @@ PHP_MSHUTDOWN_FUNCTION(xdebug)
zend_set_user_opcode_handler(ZEND_FETCH_OBJ_W, NULL);
zend_set_user_opcode_handler(ZEND_FETCH_OBJ_FUNC_ARG, NULL);
zend_set_user_opcode_handler(ZEND_FETCH_DIM_FUNC_ARG, NULL);
#if PHP_VERSION_ID >= 70100
zend_set_user_opcode_handler(ZEND_FETCH_STATIC_PROP_FUNC_ARG, NULL);
#endif
zend_set_user_opcode_handler(ZEND_FETCH_DIM_UNSET, NULL);
zend_set_user_opcode_handler(ZEND_FETCH_OBJ_UNSET, NULL);
zend_set_user_opcode_handler(ZEND_FETCH_CLASS, NULL);

0 comments on commit 6b73bef

Please sign in to comment.
You can’t perform that action at this time.