3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface PolicyRule { public function isSatisfiedBy(string $aValue); } class CredentialPolicy implements PolicyRule { private $maximumDaysOld; private $policyRules = []; public function __construct(array $aPolicyRuleSet) { foreach ($aPolicyRuleSet as $rule) { if ($rule instanceof PolicyRule && $rule !== $this) { $this->policyRules[] = $rule; } } } public function isSatisfiedBy(string $aCredential) : bool { foreach ($this->policyRules as $rule) { if (! $rule->isSatisfiedBy($aCredential)) { return false; } } return true; } } abstract class EnforcedRule implements PolicyRule { const UNENFORCED = 0; const ENFORCED = 1; private $enforcementType; protected function isEnforced() : bool { return ($this->enforcementType == self::ENFORCED); } protected function setEnforcementType(int $aType) { $this->guardEnforcementType($aType); $this->enforcementType = $aType; } protected function guardEnforcementType(int $aType) { if (! in_array($aType, [self::UNENFORCED, self::ENFORCED])) { throw new InvalidEnforcementTypeException($aType); } } } abstract class MinimumCharacterCountRule extends EnforcedRule { const DEFAULT_MINIMUM = 1; protected $regexPattern; protected $minimumCount = self::DEFAULT_MINIMUM; public function isSatisfiedBy(string $aValue) : bool { if (! $this->isEnforced()) { return true; } $matches = []; preg_match_all($this->regexPattern, $aValue, $matches); return (count($matches[0]) >= $this->minimumCount); } } class NumericRule extends MinimumCharacterCountRule { protected $regexPattern = '/[0-9]/'; public function __construct(int $aMinimumCount = self::DEFAULT_MINIMUM, int $anEnforcementType = self::ENFORCED) { $this->setEnforcementType($anEnforcementType); $this->minimumCount = $aMinimumCount; } } class SpecialCharacterRule extends MinimumCharacterCountRule { protected $regexPattern = '/[~`#\$%\^&\*\(\)\-_\+\|,\.<>]/'; public function __construct(int $aMinimumCount = self::DEFAULT_MINIMUM, int $anEnforcementType = self::ENFORCED) { $this->setEnforcementType($anEnforcementType); $this->minimumCount = $aMinimumCount; } } $policy = new CredentialPolicy([ new NumericRule(), new SpecialCharacterRule() ]); var_dump($policy->isSatisfiedBy("for5"));

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.70.0120.00416.75
8.3.60.0100.01318.65
8.3.50.0130.00621.99
8.3.40.0120.00918.88
8.3.30.0100.01018.84
8.3.20.0040.01121.92
8.3.10.0180.00023.52
8.3.00.0030.00619.63
8.2.190.0130.00716.63
8.2.180.0090.00916.63
8.2.170.0070.00722.96
8.2.160.0110.01120.43
8.2.150.0060.00324.18
8.2.140.0040.01424.66
8.2.130.0060.00317.88
8.2.120.0030.00726.35
8.2.110.0030.00619.19
8.2.100.0030.00918.03
8.2.90.0000.00919.30
8.2.80.0040.00417.97
8.2.70.0000.00917.88
8.2.60.0000.00817.93
8.2.50.0030.00518.07
8.2.40.0050.00319.41
8.2.30.0040.00420.56
8.2.20.0000.01017.84
8.2.10.0000.00718.31
8.2.00.0080.00018.12
8.1.280.0150.00725.92
8.1.270.0000.00823.84
8.1.260.0100.00728.09
8.1.250.0080.00028.09
8.1.240.0090.00322.08
8.1.230.0070.00422.75
8.1.220.0060.00317.78
8.1.210.0000.00818.77
8.1.200.0030.00617.60
8.1.190.0050.00317.82
8.1.180.0040.00418.10
8.1.170.0060.00318.71
8.1.160.0050.00321.98
8.1.150.0050.00318.95
8.1.140.0030.00519.74
8.1.130.0040.00417.73
8.1.120.0000.00717.64
8.1.110.0070.00017.53
8.1.100.0000.00817.50
8.1.90.0070.00017.55
8.1.80.0000.00717.63
8.1.70.0050.00317.63
8.1.60.0040.00417.65
8.1.50.0000.00817.64
8.1.40.0030.00517.68
8.1.30.0060.00317.84
8.1.20.0000.00917.69
8.1.10.0030.00617.64
8.1.00.0030.00517.61
8.0.300.0050.00318.77
8.0.290.0000.00816.88
8.0.280.0040.00418.50
8.0.270.0000.00717.32
8.0.260.0000.00717.36
8.0.250.0000.00717.05
8.0.240.0070.00017.02
8.0.230.0000.00817.20
8.0.220.0040.00417.09
8.0.210.0000.00717.00
8.0.200.0000.00717.02
8.0.190.0030.00617.13
8.0.180.0080.00017.00
8.0.170.0030.00517.11
8.0.160.0040.00417.12
8.0.150.0030.00417.08
8.0.140.0000.00716.96
8.0.130.0030.00313.54
8.0.120.0060.00317.07
8.0.110.0080.00016.96
8.0.100.0000.00717.05
8.0.90.0020.00516.91
8.0.80.0030.01117.13
8.0.70.0040.00417.02
8.0.60.0030.00516.98
8.0.50.0000.00817.00
8.0.30.0090.00917.43
8.0.20.0090.01017.48
8.0.10.0040.00417.09
8.0.00.0090.01017.06
7.4.330.0020.00216.80
7.4.320.0070.00016.70
7.4.300.0040.00416.84
7.4.290.0050.00216.72
7.4.280.0030.00316.84
7.4.270.0070.00016.79
7.4.260.0030.00316.72
7.4.250.0040.00416.86
7.4.240.0000.00716.68
7.4.230.0070.00016.93
7.4.220.0120.00616.82
7.4.210.0170.00316.75
7.4.200.0000.00716.50
7.4.160.0040.01216.80
7.4.150.0120.00617.40
7.4.140.0120.00717.86
7.4.130.0100.00716.87
7.4.120.0100.01016.85
7.4.110.0100.01016.88
7.4.100.0090.00916.75
7.4.90.0140.00616.75
7.4.80.0100.01019.39
7.4.70.0100.00616.81
7.4.60.0150.00716.77
7.4.50.0000.01316.74
7.4.40.0130.00316.76
7.4.30.0150.00716.86
7.4.00.0070.00715.09
7.3.330.0000.00613.37
7.3.320.0050.00013.50
7.3.310.0040.00416.45
7.3.300.0000.00716.50
7.3.290.0080.01016.58
7.3.280.0110.00916.58
7.3.270.0060.01217.40
7.3.260.0060.01216.54
7.3.250.0130.00816.66
7.3.240.0120.00816.83
7.3.230.0090.01216.52
7.3.210.0100.00716.53
7.3.200.0070.01616.72
7.3.190.0060.01016.58
7.3.180.0070.01116.64
7.3.170.0110.00616.81
7.3.160.0070.01116.46
7.3.120.0090.00614.79
7.3.110.0070.00715.20
7.3.100.0100.00314.93
7.3.90.0060.00915.29
7.3.80.0080.00815.09
7.3.70.0040.01115.12
7.3.60.0040.00715.13
7.3.50.0070.01015.02
7.3.40.0060.00614.96
7.3.30.0080.00815.07
7.3.20.0130.00016.74
7.3.10.0120.00516.88
7.3.00.0150.00516.68
7.2.330.0140.00417.04
7.2.320.0160.00716.77
7.2.310.0130.00316.84
7.2.300.0070.01016.91
7.2.290.0070.01417.03
7.2.240.0040.01115.08
7.2.230.0060.00915.07
7.2.220.0120.00415.25
7.2.210.0040.00815.07
7.2.200.0030.01315.56
7.2.190.0070.00715.05
7.2.180.0030.01014.99
7.2.170.0040.01515.30
7.2.160.0050.00515.15
7.2.150.0060.00916.97
7.2.140.0080.00617.05
7.2.130.0060.00616.99
7.2.120.0070.00916.92
7.2.110.0120.00517.05
7.2.100.0050.00917.18
7.2.90.0080.01116.96
7.2.80.0140.00816.97
7.2.70.0170.00416.99
7.2.60.0120.00516.95
7.2.50.0100.01017.05
7.2.40.0100.01016.81
7.2.30.0150.00416.87
7.2.20.0140.00817.07
7.2.10.0150.00616.97
7.2.00.0060.01117.70
7.1.330.0120.00616.07
7.1.320.0060.00915.86
7.1.310.0030.01315.61
7.1.300.0060.01015.85
7.1.290.0100.00316.17
7.1.280.0070.01016.04
7.1.270.0060.01015.89
7.1.260.0060.00916.07
7.1.250.0070.00915.82
7.1.200.0090.00315.93
7.1.100.0000.01118.39
7.1.70.0130.00317.50
7.1.60.0070.01419.36
7.1.50.0030.02116.96
7.1.00.0000.08022.32
7.0.200.0030.00616.93
7.0.60.0070.08019.96
7.0.50.0130.07317.91
7.0.40.0070.04320.29
7.0.30.0230.08020.21
7.0.20.0330.08020.32
7.0.10.0130.03320.08
7.0.00.0070.08720.44
5.6.280.0000.05721.07
5.6.210.0070.08020.45
5.6.200.0030.04318.12
5.6.190.0200.07720.61
5.6.180.0370.07720.52
5.6.170.0170.05720.52
5.6.160.0030.08320.46
5.6.150.0100.08318.23
5.6.140.0030.08318.17
5.6.130.0100.05718.15
5.6.120.0070.07721.13
5.6.110.0070.08320.97
5.6.100.0030.04021.00
5.6.90.0030.04321.01
5.6.80.0070.06720.52
5.5.350.0200.07020.42
5.5.340.0030.06018.08
5.5.330.0100.05320.27
5.5.320.0100.07720.30
5.5.310.0230.05320.29
5.5.300.0030.04317.94
5.5.290.0100.06018.03
5.5.280.0000.04320.78
5.5.270.0130.06320.89
5.5.260.0070.04320.96
5.5.250.0100.04020.70
5.5.240.0170.02720.05

preferences:
54.26 ms | 401 KiB | 5 Q