3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Object { // protected $hasMany; protected $theSignificativeProperties = ['nome', 'login']; public function getHasMany() { return $this->hasMany; } public function getSignificativeProperties() { return $this->theSignificativeProperties; } } class Aluno extends Object { private $nome; private $login; protected $hasMany = ['post', 'disciplina']; protected $theSignificativeProperties = ['nome', 'login']; /*public function getHasMany() { return $this->hasMany; }*/ /*public function getSignificativeProperties() { return $this->theSignificativeProperties; }*/ } class Post extends Object { // } class Disciplina extends Object { protected $hasMany = ['aluno']; } class EntityManager { // } class RelationalEntityManager extends EntityManager { public function find($array) { // echo 'Usando o RelationalEntityManager. '; echo 'Vou fazer JOIN com '; print_r($array); $query = 'SELECT'; return $query; } } class BaseController { protected $objectService; protected $model; public function __construct($modelName) { $this->model = $modelName; $this->objectService = new BaseObjectService($modelName, new RelationalEntityManager()); } public function view() { $args = func_get_args(); $this->objectService->view($args); } } class AlunoController extends BaseController { } class DisciplinaController extends BaseController { } class BaseObjectService { protected $em; protected $model; public function __construct($modelName, EntityManager $entityManager) { $this->model = $modelName; $this->em = $entityManager; } public function view($args) { // echo 'Argumentos: '; print_r($args); echo 'Classe em questão: ' . $this->model; echo ' -> Propriedades: '; $reflect = new ReflectionClass(ucfirst($this->model)); // $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED); $props = $reflect->getProperties(); foreach ($props as $prop) { print $prop->getN ame() . ", "; } $methods = $reflect->getMethods(); $array = array(); foreach ($methods as $method) { print $method->getName() . ", "; if ( $method->getName() == 'getHasMany') { echo 'achou o HASMANY de ' . $this->model ; //print_r($reflect->getHasMany()); $hasManyMethod = $reflect->getMethod('getHasMany'); $c = ucfirst($this->model); $x = new $c(); $array = $hasManyMethod->invoke($x); print_r($array); } } echo ' --- '; // var_dump($props); $results = $this->em->find($array); $data['results'] = $results; $this->render($this->model, 'view', $data); } public function render($controller, $action, $data) { extract($data); echo 'require ' . $controller . '/' . $action . 'view.php'; echo 'dados recebidos: '; print_r($data); } } // echo 'Aluno: ' . class_exists('Aluno') . '<br>'; // echo 'Teste: '; var_dump(class_exists('Teste')) . '\n'; // $a = new Aluno(); // print_r ( $a->getSignificativeProperties() ); $alunoController = new AlunoController('aluno'); $alunoController->view('marcelo', 'boi', 1); $disciplinaController = new DisciplinaController('disciplina'); $disciplinaController->view('PHP', 55);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.1.70.0060.01216.65
7.1.60.0230.02034.94
7.1.50.0240.01834.80
7.1.40.0120.01834.21
7.1.30.0140.01434.39
7.1.20.0280.02134.51
7.1.10.0070.00716.48
7.1.00.0080.00516.29
7.0.200.0140.00416.49
7.0.190.0030.01416.46
7.0.180.0120.00316.09
7.0.170.0120.00316.01
7.0.160.0070.00716.12
7.0.150.0090.00916.00
7.0.140.0070.01116.07
7.0.130.0060.00916.23
7.0.120.0030.01216.23
7.0.110.0060.00916.02
7.0.100.0000.01516.16
7.0.90.0070.00716.01
7.0.80.0090.00615.93
7.0.70.0030.01016.04
7.0.60.0030.01015.95
7.0.50.0100.00316.17
7.0.40.0030.01116.38
7.0.30.0050.00916.49
7.0.20.0000.01216.30
7.0.10.0070.00716.44
7.0.00.0050.01016.18

preferences:
142.1 ms | 1386 KiB | 7 Q