View Issue Details

IDProjectCategoryView StatusLast Update
0001160XdebugUsage problems (Wrong Results)public2015-06-18 09:32
ReporterbogeuxAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionduplicate 
Platformx86_64OSLinux debianOS Version6.0.10
Product Version2.3.2 
Target VersionFixed in Version2.3.3 
Summary0001160: xdebug is still stricter than PHP regarding the code property type
DescriptionAccording to the issue http://bugs.xdebug.org/bug_view_page.php?bug_id=00000723 we still can't set a string code and throw the exception. In this case the code would be overrite with the value (int)0;
Steps To ReproduceWith xdebug (2.3.2) enabled :

class myException extends Exception {
    public function __construct($message = '', $code = "-1", $params = array(), Exception $previousException = null) {
        parent::__construct($message, -1);
              $this->code = $code;
        }
}

$ex = new myException('foo', 'foo');
var_dump($ex->getCode());
try {
    throw $ex;
} catch (BException $e) {
    var_dump($e->getCode());
}
var_dump($ex->getCode());

Output :
string 'foo' (length=3)
int 0
int 0

TagsNo tags attached.
Operating Systemlinux debian
PHP Version5.6.0-5.6.4

Relationships

duplicate of 0001133 closedderick PDO exception code value type is changed 

Activities

bogeux

2015-06-10 08:06

reporter   ~0003113

Little fail in my "Steps To Reproduce", the type in the catch sould be myException.

derick

2015-06-18 09:32

administrator   ~0003124

It's a duplicate of 0001133, which I've already fixed. I've verified it with your example too:

derick@whisky:~ $ php --ri xdebug | grep Version
Version => 2.3.2
[PHP: 5.6.9-dev ]

derick@whisky:~ $ php /tmp/foo.php
string(3) "foo"
int(0)
int(0)
[PHP: 5.6.9-dev ]

derick@whisky:~ $ php --ri xdebug | grep Version
Version => 2.3.3-dev
[PHP: 5.6.9-dev ]

derick@whisky:~ $ php /tmp/foo.php
string(3) "foo"
string(3) "foo"
string(3) "foo"
[PHP: 5.6.9-dev ]

derick@whisky:~ $ cat /tmp/foo.php
<?php
class myException extends Exception {
    public function __construct($message = '', $code = "-1", $params = array(), Exception $previousException = null) {
        parent::__construct($message, -1);
              $this->code = $code;
        }
}

$ex = new myException('foo', 'foo');
var_dump($ex->getCode());
try {
    throw $ex;
} catch (myException $e) {
    var_dump($e->getCode());
}
var_dump($ex->getCode());
?>

Issue History

Date Modified Username Field Change
2015-06-10 08:03 bogeux New Issue
2015-06-10 08:06 bogeux Note Added: 0003113
2015-06-18 09:32 derick Note Added: 0003124
2015-06-18 09:32 derick Relationship added duplicate of 0001133
2015-06-18 09:32 derick Status new => resolved
2015-06-18 09:32 derick Fixed in Version => 2.3.3
2015-06-18 09:32 derick Resolution open => duplicate
2015-06-18 09:32 derick Assigned To => derick
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)