run code in 200+ php & hhvm versions
Bugs & Features
<?php class Outer { protected $data; public function __construct($data) { $this->data = $data; } public function getArrayAccess() { /* create a proxy object implementing array access */ return new class($this->data) extends Outer implements ArrayAccess { public function offsetGet($offset) { return $this->data[$offset]; } public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); } public function offsetUnset($offset) { unset($this->data[$offset]); } public function offsetExists($offset) { return isset($this->data[$offset]); } }; } } $outer = new Outer(array( rand(1, 100) )); /* not null because inheritance */ var_dump($outer->getArrayAccess()[0]);

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Output for Arrow functions
Output for Object typehint
Output for Array change keys
Output for Lexical anon
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/elh6I on line 9

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