3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace App\Entity; abstract class Entity { protected $repository; protected $transformColumns = []; protected $transformValues = []; protected $properites = []; public function __construct () { $this->transformColumns = [ 'archivedAt' => (function ($column) { return 'archived_at'; }) ]; } public function set (string $column, $value) { if (isset($this->transformColumns[$column])) { $column = $this->transformColumns[$column]($column); } if (isset($this->transformValues[$column])) { $value = $this->transformValues[$column]($value); } $this->properites[$column] = $value; return; } public function __set ($column, $value) { return $this->set($column, $value); } public function get(string $column) { if (isset($this->transformColumns[$column])) { $column = $this->transformColumns[$column]($column); } return $this->properites[$column]; } public function __get ($column) { return $this->get($column); } } $o = new Entity(); $o->archived_at = (new DateTime())->format('d-m-Y H:i:s'); echo '<pre>', var_dump($o), '</pre>';
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Cannot instantiate abstract class App\Entity\Entity in /in/FXohP:47 Stack trace: #0 {main} thrown in /in/FXohP on line 47
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Fatal error: Cannot instantiate abstract class App\Entity\Entity in /in/FXohP on line 47
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/FXohP on line 5
Process exited with code 255.