<?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;
var_dump($list);
do {
$item = $item->getParent();
if ($item->getParent() === null) {
$item = &Item::newWithParent($item);
break;
}
} while (true);
var_dump($list);
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3BONR on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3BONR on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/3BONR on line 4
Process exited with code 255.