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() { // echo 'Usando o RelationalEntityManager.'; } } 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 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->getName() . ", "; } $methods = $reflect->getMethods(); 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); $this->em->find(); } } 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);

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)
8.3.60.0110.01116.50
8.3.50.0070.00716.21
8.3.40.0090.00618.88
8.3.30.0040.01818.59
8.3.20.0000.00820.34
8.3.10.0040.00423.48
8.3.00.0060.00317.59
8.2.180.0170.00016.50
8.2.170.0040.01122.96
8.2.160.0130.00020.39
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0070.00020.38
8.2.120.0070.00026.35
8.2.110.0090.00020.58
8.2.100.0060.00617.72
8.2.90.0040.00418.92
8.2.80.0000.00817.97
8.2.70.0030.00617.38
8.2.60.0000.00917.91
8.2.50.0000.00918.10
8.2.40.0000.00822.34
8.2.30.0040.00421.05
8.2.20.0040.00417.93
8.2.10.0000.00717.92
8.2.00.0040.00417.88
8.1.280.0070.01025.92
8.1.270.0040.00421.83
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.61
8.1.230.0110.00018.91
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0100.00017.23
8.1.190.0000.00817.10
8.1.180.0050.00218.10
8.1.170.0000.00918.39
8.1.160.0040.00418.89
8.1.150.0080.00020.46
8.1.140.0040.00419.48
8.1.130.0000.00718.81
8.1.120.0070.00017.40
8.1.110.0050.00217.36
8.1.100.0040.00417.27
8.1.90.0040.00417.25
8.1.80.0000.00717.35
8.1.70.0070.00017.37
8.1.60.0000.00817.50
8.1.50.0040.00417.25
8.1.40.0070.00017.43
8.1.30.0000.00717.57
8.1.20.0050.00317.50
8.1.10.0000.00717.41
8.1.00.0040.00417.20
8.0.300.0000.00718.77
8.0.290.0070.00016.63
8.0.280.0030.00318.37
8.0.270.0070.00317.14
8.0.260.0060.00316.80
8.0.250.0030.00316.87
8.0.240.0070.00016.77
8.0.230.0030.00516.80
8.0.220.0070.00016.84
8.0.210.0000.00816.76
8.0.200.0030.00316.82
8.0.190.0000.00816.80
8.0.180.0000.00716.73
8.0.170.0000.00716.79
8.0.160.0000.00716.82
8.0.150.0050.00316.73
8.0.140.0000.00716.83
8.0.130.0050.00013.21
8.0.120.0040.00416.85
8.0.110.0040.00416.67
8.0.100.0040.00416.95
8.0.90.0050.00216.89
8.0.80.0040.01116.85
8.0.70.0000.00816.70
8.0.60.0050.00316.65
8.0.50.0000.00816.79
8.0.30.0050.01517.06
8.0.20.0130.01017.40
8.0.10.0040.00416.82
8.0.00.0070.01016.52
7.4.330.0060.00015.55
7.4.320.0030.00316.46
7.4.300.0060.00016.38
7.4.290.0070.00016.39
7.4.280.0000.00816.38
7.4.270.0040.00416.48
7.4.260.0000.00513.08
7.4.250.0070.00016.36
7.4.240.0030.00316.48
7.4.230.0000.00716.54
7.4.220.0100.01316.49
7.4.210.0050.00916.54
7.4.200.0000.00816.57
7.4.160.0130.00516.31
7.4.150.0140.00417.40
7.4.140.0090.01117.86
7.4.130.0120.00616.48
7.4.120.0100.00816.36
7.4.110.0160.00616.43
7.4.100.0040.01516.30
7.4.90.0160.00016.22
7.4.80.0100.01319.39
7.4.70.0100.00716.44
7.4.60.0070.01016.30
7.4.50.0040.01216.12
7.4.40.0100.00716.21
7.4.30.0170.00716.31
7.4.10.0030.01215.17
7.4.00.0080.00814.94
7.3.330.0060.00013.11
7.3.320.0050.00013.07
7.3.310.0060.00016.05
7.3.300.0060.00016.00
7.3.290.0040.00416.05
7.3.280.0110.00816.20
7.3.270.0130.00617.40
7.3.260.0120.00516.41
7.3.250.0090.01016.27
7.3.240.0080.01016.23
7.3.230.0030.01416.31
7.3.210.0060.01316.10
7.3.200.0070.01016.21
7.3.190.0130.01316.21
7.3.180.0110.00616.35
7.3.170.0100.00716.35
7.3.160.0090.00916.50
7.3.130.0090.00914.45
7.3.120.0140.00314.43
7.3.110.0070.00714.66
7.3.100.0070.00714.73
7.3.90.0000.01614.92
7.3.80.0000.00814.31
7.3.70.0090.00614.52
7.3.60.0070.00714.71
7.3.50.0100.00714.73
7.3.40.0090.00014.80
7.3.30.0000.01714.70
7.3.20.0050.00516.57
7.3.10.0070.00716.55
7.3.00.0030.00716.51
7.2.330.0110.00716.60
7.2.320.0090.00816.48
7.2.310.0160.00616.60
7.2.300.0090.01016.25
7.2.290.0130.01016.20
7.2.260.0100.01014.54
7.2.250.0040.01415.04
7.2.240.0040.01114.77
7.2.230.0090.00614.72
7.2.220.0090.00614.98
7.2.210.0060.00614.97
7.2.200.0060.00614.69
7.2.190.0080.00414.70
7.2.180.0030.00614.69
7.2.170.0030.01314.78
7.2.160.0000.01414.98
7.2.150.0090.00616.41
7.2.140.0000.01516.57
7.2.130.0070.00716.62
7.2.120.0000.01016.68
7.2.110.0090.00616.70
7.2.100.0000.01516.58
7.2.90.0000.01616.66
7.2.80.0070.00316.47
7.2.70.0000.01416.83
7.2.60.0080.00316.72
7.2.50.0070.00416.79
7.2.40.0040.01116.85
7.2.30.0090.00316.98
7.2.20.0070.00716.48
7.2.10.0000.01516.95
7.2.00.0030.00917.89
7.1.330.0110.00015.66
7.1.320.0030.00615.87
7.1.310.0040.00815.63
7.1.300.0040.01115.92
7.1.290.0090.00615.58
7.1.280.0000.01615.80
7.1.270.0070.01015.64
7.1.260.0000.01515.91
7.1.250.0060.00315.82
7.1.240.0040.01115.77
7.1.230.0040.01115.88
7.1.220.0070.00715.85
7.1.210.0060.00915.83
7.1.200.0060.00915.74
7.1.190.0060.00616.06
7.1.180.0000.01215.68
7.1.170.0060.00315.49
7.1.160.0030.01015.78
7.1.150.0030.00615.59
7.1.140.0100.00015.60
7.1.130.0000.01015.72
7.1.120.0030.00715.61
7.1.110.0070.00316.03
7.1.100.0040.01117.12
7.1.90.0070.01015.81
7.1.80.0040.00815.64
7.1.70.1170.01015.63
7.1.60.0930.00724.48
7.1.50.1080.01924.45
7.1.40.1050.01324.20
7.1.30.1380.01724.16
7.1.20.1100.00824.39
7.1.10.0970.00715.31
7.1.00.0870.00815.36
7.0.330.0030.01115.43
7.0.320.0030.00615.46
7.0.310.0110.00015.21
7.0.300.0080.00515.48
7.0.290.0090.00615.24
7.0.280.0130.00015.43
7.0.270.0000.00815.40
7.0.260.0060.00615.45
7.0.250.0110.00715.36
7.0.240.0080.00615.46
7.0.230.0090.00615.39
7.0.220.0040.01115.45
7.0.210.0060.00615.55
7.0.200.1300.01415.28
7.0.190.1320.00715.16
7.0.180.0870.01114.97
7.0.170.1430.00815.07
7.0.160.1350.00714.75
7.0.150.0900.00814.79
7.0.140.0980.01314.99
7.0.130.0980.01115.05
7.0.120.0930.01815.04
7.0.110.0880.01314.95
7.0.100.0880.01015.12
7.0.90.0980.00915.13
7.0.80.0870.01515.15
7.0.70.0870.01014.79
7.0.60.0800.01614.79
7.0.50.0920.00714.99
7.0.40.0850.01013.94
7.0.30.0860.00814.02
7.0.20.0870.01114.11
7.0.10.0820.00814.09
7.0.00.1050.00714.13
5.6.400.0070.00314.52
5.6.390.0070.01014.33
5.6.380.0090.00614.66
5.6.370.0060.00614.77
5.6.360.0030.01314.30
5.6.350.0040.01114.45
5.6.340.0090.00614.79
5.6.330.0040.00814.46
5.6.320.0030.01414.47
5.6.310.0070.00714.45
5.6.300.0040.01114.67
5.6.290.0080.00614.70
5.6.280.0030.00714.36
5.6.270.0120.00014.49
5.6.260.0000.00914.55
5.6.250.0030.01014.32
5.6.240.0040.00814.57
5.6.230.0070.00714.48
5.6.220.0070.01114.39
5.6.210.0060.00314.46
5.6.200.0030.01314.43
5.6.190.0060.00914.22
5.6.180.0000.01414.27
5.6.170.0000.01514.47
5.6.160.0140.00014.56
5.6.150.0000.01314.54
5.6.140.0040.01114.39
5.6.130.0100.00614.30
5.6.120.0060.00914.51
5.6.110.0090.00614.58
5.6.100.0070.00314.16
5.6.90.0000.01514.53
5.6.80.0120.00314.50
5.6.70.0030.00914.27
5.6.60.0070.01014.43
5.6.50.0070.00714.67
5.6.40.0060.00614.63
5.6.30.0030.00914.21
5.6.20.0000.01314.64
5.6.10.0090.00614.60
5.6.00.0070.00714.35

preferences:
32.87 ms | 400 KiB | 5 Q