Permalink
Browse files

Fixed bug #879: Closing brace in trait-using class definitions is cou…

…nted towards code coverage.
  • Loading branch information...
1 parent e3f7557 commit ca3aa94842a098337c2a06075191ec32940d5d0a @derickr committed Sep 29, 2012
Showing with 70 additions and 0 deletions.
  1. +7 −0 tests/bug00879.inc
  2. +59 −0 tests/bug00879.phpt
  3. +4 −0 xdebug.c
View
@@ -0,0 +1,7 @@
+<?php
+
+trait T {}
+
+class WithTrait {
+ use T;
+}
View
@@ -0,0 +1,59 @@
+--TEST--
+Test for bug #879: Closing brace in trait-using class definitions is counted towards code coverage. (PHP >= 5.4)
+--SKIPIF--
+<?php if (version_compare(phpversion(), "5.4", '<')) echo "skip >= PHP 5.4 needed\n"; ?>
+--INI--
+xdebug.default_enable=1
+xdebug.auto_trace=0
+xdebug.trace_options=0
+xdebug.trace_output_dir=/tmp
+xdebug.collect_params=1
+xdebug.collect_return=0
+xdebug.collect_assignments=0
+xdebug.auto_profile=0
+xdebug.profiler_enable=0
+xdebug.dump_globals=0
+xdebug.show_mem_delta=0
+xdebug.trace_format=0
+xdebug.extended_info=1
+xdebug.coverage_enable=1
+xdebug.overload_var_dump=0
+--FILE--
+<?php
+
+xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
+
+$file = realpath('./tests/bug00879.inc');
+include $file;
+
+new WithTrait;
+
+var_dump(xdebug_get_code_coverage());
+?>
+--EXPECTF--
+array(2) {
+ ["%sbug00879.inc"]=>
+ array(5) {
+ [3]=>
+ int(1)
+ [5]=>
+ int(1)
+ [6]=>
+ int(1)
+ [7]=>
+ int(1)
+ [8]=>
+ int(1)
+ }
+ ["%sbug00879.php"]=>
+ array(4) {
+ [5]=>
+ int(1)
+ [6]=>
+ int(1)
+ [8]=>
+ int(1)
+ [10]=>
+ int(1)
+ }
+}
View
@@ -630,6 +630,10 @@ PHP_MINIT_FUNCTION(xdebug)
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION >= 6
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_DECLARE_LAMBDA_FUNCTION);
#endif
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4)
+ XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_ADD_TRAIT);
+ XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_BIND_TRAITS);
+#endif
}
XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(include_or_eval, ZEND_INCLUDE_OR_EVAL);

0 comments on commit ca3aa94

Please sign in to comment.