3v4l.org

run code in 300+ PHP versions simultaneously
<?php // オブジェクトの不要なプロパティを削除 function removeUnwantedProperties(mixed $element): mixed { if (is_array($element)) { foreach ($element as $key => $val) { if ($key !== "\0*\0" && is_object($val)) { $element[$key] = removeUnwantedProperties($val); } } } elseif (is_object($element)) { $rc = new ReflectionClass($element); $properties = $rc->getProperties(); foreach ($properties as $property) { if (!filterProperties($property)) { unset($element->{$property->getName()}); } else { $getterName = 'get' . ucfirst($property->getName()); if (method_exists($element, $getterName)) { $element->{$property->getName()} = removeUnwantedProperties($element->$getterName()); } else { die('throw'); } } } } return $element; } function filterProperties($property) { $attributes = $property->getAttributes(); foreach ($attributes as $attribute) { if ($attribute->getName() === NoOutput::class) { return false; } } return true; } class Test1 { public $x; // protected だとエラーになる #[NoOutput] public $y; public function __construct() { $this->x = "X"; $this->y = "Y"; } public function getX() { return $this->x; } public function getY() { return $this->y; } } $t1 = new Test1(); $object = removeUnwantedProperties($t1); print_r($object);

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.5.00.0110.01120.05
8.4.150.0030.00014.05
8.4.140.0130.00817.59
8.4.130.0090.01317.61
8.4.120.0080.00320.46
8.4.110.0110.00622.44
8.4.100.0110.01017.62
8.4.90.0100.01020.45
8.4.80.0030.00618.98
8.4.70.0130.00718.99
8.4.60.0060.01020.56
8.4.50.0040.00518.61
8.4.40.0130.00617.91
8.4.30.0030.01318.63
8.4.20.0160.00318.79
8.4.10.0130.00719.29
8.3.280.0120.00818.48
8.3.270.0130.01216.87
8.3.260.0100.01016.44
8.3.250.0060.00319.00
8.3.240.0100.00616.36
8.3.230.0090.01016.79
8.3.220.0070.00918.80
8.3.210.0280.00616.58
8.3.200.0080.00116.68
8.3.190.0060.00218.93
8.3.180.0080.00718.92
8.3.170.0110.00718.80
8.3.160.0090.01218.54
8.3.150.0000.00816.84
8.3.140.0000.01819.12
8.3.130.0040.00418.43
8.3.120.0030.00518.95
8.3.110.0040.00420.94
8.3.100.0030.00618.43
8.3.90.0070.00316.79
8.3.80.0140.00018.38
8.3.70.0150.00618.65
8.3.60.0150.00416.50
8.3.50.0070.01416.42
8.3.40.0110.00320.42
8.3.30.0130.00620.07
8.3.20.0040.00424.18
8.3.10.0070.01424.66
8.3.00.0170.00324.66
8.2.290.0090.00216.46
8.2.280.0080.00618.38
8.2.270.0150.00316.69
8.2.260.0080.00017.17
8.2.250.0040.00416.71
8.2.240.0100.00718.25
8.2.230.0040.00422.58
8.2.220.0040.00424.06
8.2.210.0150.00326.77
8.2.200.0070.00418.41
8.2.190.0110.01116.91
8.2.180.0090.01217.00
8.2.170.0110.00418.67
8.2.160.0030.01022.96
8.2.150.0080.00025.66
8.2.140.0000.01524.66
8.2.130.0160.00324.66
8.2.120.0150.00624.66
8.2.110.0070.01124.66
8.2.100.0170.00324.66
8.2.90.0100.01024.66
8.2.80.0130.00624.66
8.2.70.0030.01724.66
8.2.60.0170.00324.66
8.2.50.0100.01024.66
8.2.40.0180.00324.66
8.2.30.0140.00724.66
8.2.20.0140.00724.66
8.2.10.0080.01124.66
8.2.00.0140.00324.66
8.1.330.0080.00721.90
8.1.320.0100.00916.35
8.1.310.0000.01716.66
8.1.300.0040.00418.23
8.1.290.0030.00618.88
8.1.280.0100.01025.92
8.1.270.0140.00024.66
8.1.260.0110.00424.66
8.1.250.0040.00424.66
8.1.240.0070.00724.66
8.1.230.0100.00724.66
8.1.220.0060.00324.66
8.1.210.0070.00724.66
8.1.200.0000.00824.66
8.1.190.0070.00724.66
8.1.180.0040.00424.66
8.1.170.0000.00824.66
8.1.160.0050.00524.66
8.1.150.0000.00924.66
8.1.140.0040.00424.66
8.1.130.0000.00824.66
8.1.120.0080.00024.66
8.1.110.0060.00324.66
8.1.100.0040.00424.66
8.1.90.0080.00024.66
8.1.80.0000.00824.66
8.1.70.0080.00024.66
8.1.60.0050.00324.66
8.1.50.0060.00324.66
8.1.40.0030.00524.66
8.1.30.0080.00024.66
8.1.20.0080.00024.66
8.1.10.0050.00324.66
8.1.00.0030.00624.66

preferences:
39.52 ms | 403 KiB | 5 Q