On Tue, 30 Nov 2004, Michiel Rook wrote:
> I've experienced a few difficulties with the (promising) XDEBUG_CC_UNUSED
> parameter in 2.0.0beta2. It concerns the following code:
>
> <?
> function a()
> {
> return NULL;
> }
>
> xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
> a();
> $cc = xdebug_get_code_coverage();
> xdebug_stop_code_coverage();
> var_dump($cc);
> ?>
>
> which results in the following output:
>
> array(1) {
> ["/var/www/experiment/xdebug_cc.php"]=>
> array(5) {
> [2]=>
> int(-1)
> [4]=>
> int(1)
> [5]=>
> int(-1)
> [8]=>
> int(1)
> [9]=>
> int(1)
> }
> }
>
> IMHO this output is not entirely correct, as the single statement in a()
> is executed, but the stub and end of the function aren't?
The result is totally correct. The starting stub *is* executed (the line
with function a()), but it is executed when the script first runs
(before you call xdebug_start_code_coverage). The ending stub is not
executed before you return from the function before reaching the end
(with the return NULL statement).
Change your code to:
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED); // Added
function a()
{
// return NULL;
}
// xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
a();
$cc = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
var_dump($cc);
?>
And you see what I mean.
regards,
Derick
-- Xdebug | http://xdebug.org | xdebug-general@lists.xdebug.orgReceived on Tue Nov 30 2004 - 20:08:41 GMT
This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST