Ticket #2037 (assigned defect)

Opened 4 years ago

Last modified 2 years ago

var_dump() can't tell if its argument is a reference

Reported by: tim Assigned to: tim (accepted)
Priority: normal Milestone: 3.0.0 release
Component: Core Version: trunk
Severity: major Keywords:
Cc:

Description (Last modified by weyrick)

var_dump can tell if it was passed a reference or not:

<?php

$foo = 2;
var_dump(&$foo);
var_dump($foo);

?>



Change History

07/26/04 05:49:37 changed by tim

var_dump() is generally funky.  here's a test case that makes it all a little more obvious:

<?php

class a { 
}

$a = new a();
$a->foo =& $a;
var_dump(&$a);
var_dump($a);

$b = array();
$b[1] =& $b;
var_dump(&$b);
var_dump($b);


?>

07/26/04 12:18:55 changed by tim

well, the cases where the argument is passed with & are 
"call-time pass-by-reference", which we don't support.

the fact that the objects print differently from the arrays, i.e.:

object(a)(1) {
  ["foo"]=>
  &object(a)(1) {
    ["foo"]=>
    &object(a)(1) {
      ["foo"]=>
      *RECURSION*
    }
  }
}
array(1) {
  [1]=>
  array(1) {
    [1]=>
    *RECURSION*
  }
}

is a zend bug, IMHO, and I've filed it as such.  
bug id #29390 on bugs.php.net.

07/26/04 12:20:37 changed by tim

we don't handle this the same as them either:

<?php 
$b = array(); 
$b[1] =& $b; 
$b =& $b; 
var_dump($b); 
var_dump($b); 
?>


they say:

array(1) {
  [1]=>
  &array(1) {
    [1]=>
    &array(1) {
      [1]=>
      *RECURSION*
    }
  }
}
array(1) {
  [1]=>
  array(1) {
    [1]=>
    *RECURSION*
  }
}

whereas we say the same thing each time.  filed as bug #29389
on bugs.php.net.

01/24/06 04:52:01 changed by weyrick

verified still relavent

04/15/07 11:17:21 changed by weyrick

  • severity changed from feature to major.
  • version set to trunk.
  • type set to defect.
  • description changed.
  • milestone set to 3.0.0 release.