- Output for 5.3.0 - 5.3.24, 5.4.0 - 5.4.15
- Parse error: syntax error, unexpected '&' in JZuCC on line 15
Process exited with code 255. - Output for 5.3.25
- Parse error: syntax error, unexpected '&' in /in/EQ8Pn on line 15
Process exited with code 255.
<?php
class Item {
public static function &newWithParent(Item &$parent)
{
$item = new Item();
$item->parent = &$parent;
return $item;
}
private $parent;
public function &getParent()
{
return &$this->parent;
}
}
$item = Item::newWithParent(Item::newWithParent(Item::newWithParent(new Item())));
// Basically it's this now: {"parent":{"parent":{"parent":{"parent":null}}}}
// I want to set that null value
$list = $item;
do {
$prev = &$item;
$item = $item->getParent();
if ($item->getParent() === null) {
$prev =& Item::newWithParent($item);
break;
}
} while (true);
var_dump($list);