@ 2012-08-14T16:33:19Z <?php
class Collection {}
class Link {}
class Node {
private $label = '_';
private $links;
private $attrs;
public function __construct($label = '_')
{
$this -> setLabel($label);
}
public function getLabel()
{
return $this -> label;
}
public function setLabel($label)
{
if (!is_scalar($label)) {
throw new ErrorException("Error Processing Request", 1);
}
$this -> label = $label;
return $this -> getLabel();
}
public function __get($name)
{
if (isset($this -> links -> $name)) {
return $this -> links -> $name;
} elseif (isset($this -> attrs -> $name)) {
return $this -> attrs -> $name;
} else {
throw new ErrorException("Error Processing Request", 1);
}
}
public function __set($name, $value)
{
if ($name == '_' && !($value instanceof Node || $value instanceof Link || $value instanceof Collection)) {
throw new ErrorException("Error Processing Request", 1);
}
$name_type = (
(1 * (isset($this -> links -> $name) && count($this -> links -> $name) == 1)) |
(2 * (isset($this -> links -> $name) && count($this -> links -> $name) <> 1)) |
(3 * isset($this -> attrs -> $name)) |
(13 * !(isset($this -> attrs -> $name) || isset($this -> links -> $name)))
);
$value_type = (
(5 * ($value instanceof Collection)) |
(7 * ($value instanceof Node)) |
(17 * ($value instanceof Link)) |
(11 * !($value instanceof Node || $value instanceof Link || $value instanceof Collection))
);
switch ($name_type * $value_type) {
case 5:
case 10: {
foreach ($value as $node) {
$this -> links -> {$name} -> attach($node);
}
break;
}
case 7:
case 14: {
$this -> links -> {$name} -> attach($value);
break;
}
case 11:
case 22: {
trigger_error('Converting ' . $name . ' from ' .
((count($this -> links -> $name) <> 1) ? 'Collection' : 'Node') .
' to property', E_USER_WARNING);
unset($this -> links -> $name);
$this -> attrs -> $name = $value;
break;
}
case 15: {
trigger_error('Converting ' . $name . ' from property to Collection', E_USER_WARNING);
unset($this -> attrs -> $name);
$this -> links -> $name = $value;
break;
}
case 21: {
trigger_error('Converting ' . $name . ' from property to Node', E_USER_WARNING);
unset($this -> attrs -> $name);
$this -> links -> $name = new Collection;
$this -> links -> {$name} -> attach($value);
break;
}
case 33:
case 143: {
$this -> attrs -> $name = $value;
break;
}
case 65: {
$this -> links -> $name = $value;
break;
}
case 91: {
$this -> links -> $name = new Collection;
$this -> links -> {$name} -> attach($value);
break;
}
case 17:
case 34: {
$this -> links -> {$name} -> attach($value -> getTail());
$this -> links -> {$name} -> attach($value -> getHead());
break;
}
case 51: {
trigger_error('Converting ' . $name . ' from property to Collection', E_USER_WARNING);
unset($this -> attrs -> $name);
$this -> links -> $name = new Collection;
$this -> links -> {$name} -> attach($value -> getTail());
$this -> links -> {$name} -> attach($value -> getHead());
break;
}
case 221: {
$this -> links -> $name = new Collection;
$this -> links -> {$name} -> attach($value -> getTail());
$this -> links -> {$name} -> attach($value -> getHead());
break;
}
default: {
throw new ErrorException("Error Processing Request", 1);
// no break
}
}
}
public function __isset($name)
{
return (isset($this -> links -> $name) || isset($this -> attrs -> $name));
}
public function __unset($name)
{
unset($this -> links -> $name, $this -> attrs -> $name);
}
public function serialize()
{
return serialize(array(
'label' => $this -> getLabel(),
'links' => $this -> links,
'attrs' => $this -> attrs
));
}
public function unserialize($serialized)
{
$unserialized = unserialize($serialized);
$this -> setLabel($unserialized['label']);
$this -> links = $unserialized['links'];
$this -> attrs = $unserialized['attrs'];
}
}
$node = new Node;
$node->self = $node;
echo serialize($node);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught Error: Attempt to assign property "self" on null in /in/vMA3a:104
Stack trace:
#0 /in/vMA3a(161): Node->__set('self', Object(Node))
#1 {main}
thrown in /in/vMA3a on line 104
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
33.33 ms | 401 KiB | 8 Q