3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * * This file is part of Aura for PHP. * * @package Aura.Filter * * @license http://opensource.org/licenses/bsd-license.php BSD * */ namespace Aura\Filter; use Aura\Filter\Rule\Sanitize; use Aura\Filter\Rule\Validate; use Aura\Filter\Rule\Locator\SanitizeLocator; use Aura\Filter\Rule\Locator\ValidateLocator; use Aura\Filter\Spec\SanitizeSpec; use Aura\Filter\Spec\ValidateSpec; use PDO; /** * * Factory to create Filter objects. * * @package Aura.Filter * */ class FilterFactory { protected $validate_locator; protected $sanitize_locator; protected $pdo; protected $quote_prefix; protected $quote_suffix; public function __construct( PDO $pdo = null, $quote_prefix = '"', $quote_suffix = '"' ) { $this->pdo = $pdo; $this->quote_prefix = $quote_prefix; $this->quote_suffix = $quote_suffix; } /** * * Returns a new Filter instance. * * @return Filter * */ public function newFilter() { return new Filter($this->newValidateSpec(), $this->newSanitizeSpec()); } public function newValueFilter() { return new ValueFilter( $this->getValidateLocator(), $this->getSanitizeLocator() ); } public function newValidateSpec() { return new ValidateSpec($this->getValidateLocator()); } public function newSanitizeSpec() { return new SanitizeSpec($this->getSanitizeLocator()); } public function getValidateLocator() { if (! $this->validate_locator) { $this->validate_locator = new ValidateLocator($this->getValidateFactories()); } return $this->validate_locator; } public function getSanitizeLocator() { if (! $this->sanitize_locator) { $this->sanitize_locator = new SanitizeLocator($this->getSanitizeFactories()); } return $this->sanitize_locator; } protected function getValidateFactories() { $factories = array( 'alnum' => function () { return new Validate\Alnum(); }, 'alpha' => function () { return new Validate\Alpha(); }, 'between' => function () { return new Validate\Between(); }, 'blank' => function () { return new Validate\Blank(); }, 'bool' => function () { return new Validate\Bool(); }, 'closure' => function () { return new Validate\Closure(); }, 'creditCard' => function () { return new Validate\CreditCard(); }, 'dateTime' => function () { return new Validate\DateTime(); }, 'email' => function () { return new Validate\Email(); }, 'equalToField' => function () { return new Validate\EqualToField(); }, 'equalToValue' => function () { return new Validate\EqualToValue(); }, 'float' => function () { return new Validate\Float(); }, 'inKeys' => function () { return new Validate\InKeys(); }, 'int' => function () { return new Validate\Int(); }, 'inValues' => function () { return new Validate\InValues(); }, 'ipv4' => function () { return new Validate\Ipv4(); }, 'isbn' => function () { return new Validate\Isbn(); }, 'locale' => function () { return new Validate\Locale(); }, 'max' => function () { return new Validate\Max(); }, 'min' => function () { return new Validate\Min(); }, 'now' => function () { return new Validate\Now(); }, 'regex' => function () { return new Validate\Regex(); }, 'strictEqualToField' => function () { return new Validate\StrictEqualToField(); }, 'strictEqualToValue' => function () { return new Validate\StrictEqualToValue(); }, 'string' => function () { return new Validate\String(); }, 'strlen' => function () { return new Validate\Strlen(); }, 'strlenBetween' => function () { return new Validate\StrlenBetween(); }, 'strlenMax' => function () { return new Validate\StrlenMax(); }, 'strlenMin' => function () { return new Validate\StrlenMin(); }, 'trim' => function () { return new Validate\Trim(); }, 'upload' => function () { return new Validate\Upload(); }, 'url' => function () { return new Validate\Url(); }, 'word' => function () { return new Validate\Word(); }, ); $this->addValidatePdo($factories); return $factories; } protected function addValidatePdo(&$factories) { if (! $this->pdo) { return; } $pdo = $this->pdo; $quote_prefix = $this->quote_prefix; $quote_suffix = $this->quote_suffix; $factories['inTableColumn'] = function () use ($pdo, $quote_prefix, $quote_suffix) { return new Validate\InTableColumn($pdo, $quote_prefix, $quote_suffix); }; } protected function getSanitizeFactories() { return array( 'alnum' => function () { return new Sanitize\Alnum(); }, 'alpha' => function () { return new Sanitize\Alpha(); }, 'between' => function () { return new Sanitize\Between(); }, 'bool' => function () { return new Sanitize\Bool(); }, 'closure' => function () { return new Sanitize\Closure(); }, 'dateTime' => function () { return new Sanitize\DateTime(); }, 'field' => function () { return new Sanitize\Field(); }, 'float' => function () { return new Sanitize\Float(); }, 'int' => function () { return new Sanitize\Int(); }, 'isbn' => function () { return new Sanitize\Isbn(); }, 'max' => function () { return new Sanitize\Max(); }, 'min' => function () { return new Sanitize\Min(); }, 'regex' => function () { return new Sanitize\Regex(); }, 'remove' => function () { return new Sanitize\Remove(); }, 'strictEqualToField' => function () { return new Sanitize\StrictEqualToField(); }, 'strictEqualToValue' => function () { return new Sanitize\StrictEqualToValue(); }, 'string' => function () { return new Sanitize\String(); }, 'strlen' => function () { return new Sanitize\Strlen(); }, 'strlenBetween' => function () { return new Sanitize\StrlenBetween(); }, 'strlenMax' => function () { return new Sanitize\StrlenMax(); }, 'strlenMin' => function () { return new Sanitize\StrlenMin(); }, 'trim' => function () { return new Sanitize\Trim(); }, 'value' => function () { return new Sanitize\Value(); }, 'word' => function () { return new Sanitize\Word(); }, ); } }

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.3.10.0040.00416.59
7.3.00.0090.00316.53
7.2.130.0080.00616.75
7.2.120.0070.01116.60
7.2.110.0030.01216.70
7.2.100.0060.01216.88
7.2.90.0040.01116.46
7.2.80.0040.01116.70
7.2.70.0030.01216.61
7.2.60.0110.00416.85
7.2.50.0170.00016.90
7.2.40.0030.01316.72
7.2.30.0040.01116.91
7.2.20.0030.00616.88
7.2.10.0000.01516.83
7.2.00.0090.00717.85
7.1.250.0090.00615.78
7.1.200.0060.00315.73
7.1.100.0120.00417.85
7.1.70.0000.00916.94
7.1.60.0140.01119.34
7.1.50.0070.01716.77
7.1.00.0030.07722.38
7.0.200.0000.00816.47
7.0.140.0030.06022.08
7.0.100.0000.05021.75
7.0.90.0100.03021.68
7.0.80.0070.03321.81
7.0.70.0000.04021.68
7.0.60.0070.03721.73
7.0.50.0000.04322.17
7.0.40.0030.05020.14
7.0.30.0000.04720.07
7.0.20.0030.04020.20
7.0.10.0000.04320.08
7.0.00.0030.05020.19
5.6.280.0070.07321.10
5.6.250.0000.04020.93
5.6.240.0030.04320.71
5.6.230.0030.04020.71
5.6.220.0000.04320.85
5.6.210.0030.04020.58
5.6.200.0030.04021.23
5.6.190.0030.04021.14
5.6.180.0030.04021.06
5.6.170.0000.04321.28
5.6.160.0000.04321.28
5.6.150.0000.04021.14
5.6.140.0000.04321.16
5.6.130.0030.04321.15
5.6.120.0000.04321.24
5.6.110.0000.04021.14
5.6.100.0000.08321.14
5.6.90.0000.08721.23
5.6.80.0100.04020.44
5.6.70.0000.08320.53
5.6.60.0070.07320.43
5.6.50.0030.07320.44
5.6.40.0070.07720.55
5.6.30.0030.08320.55
5.6.20.0070.08020.42
5.6.10.0030.07020.55
5.6.00.0130.07320.47
5.5.380.0000.05320.49
5.5.370.0100.03020.51
5.5.360.0030.05320.48
5.5.350.0100.03320.48
5.5.340.0070.03721.02
5.5.330.0000.04320.84
5.5.320.0030.05321.04
5.5.310.0030.05021.02
5.5.300.0000.04320.88
5.5.290.0070.03720.91
5.5.280.0070.04021.04
5.5.270.0000.09020.88
5.5.260.0000.09320.84
5.5.250.0070.08320.66
5.5.240.0030.08020.27
5.5.230.0030.07020.13
5.5.220.0100.06720.38
5.5.210.0000.08320.37
5.5.200.0000.05020.23
5.5.190.0030.07720.29
5.5.180.0070.07320.39
5.5.160.0100.04720.38
5.5.150.0030.08320.26
5.5.140.0070.07320.09
5.5.130.0030.06720.31
5.5.120.0070.07020.32
5.5.110.0100.04720.09
5.5.100.0130.06320.16
5.5.90.0030.07720.18
5.5.80.0070.07720.25
5.5.70.0030.04720.27
5.5.60.0130.06020.23
5.5.50.0070.07720.16
5.5.40.0000.04720.25
5.5.30.0030.07320.15
5.5.20.0030.04720.16
5.5.10.0100.06320.11
5.5.00.0070.04320.15
5.4.450.0100.03019.44
5.4.440.0030.06019.49
5.4.430.0070.03719.25
5.4.420.0000.07719.50
5.4.410.0130.06719.28
5.4.400.0030.06019.16
5.4.390.0030.08019.07
5.4.380.0030.07019.12
5.4.370.0030.07719.15
5.4.360.0030.07018.93
5.4.350.0100.06719.19
5.4.340.0100.06719.07
5.4.320.0100.07019.19
5.4.310.0130.05719.30
5.4.300.0000.04719.06
5.4.290.0030.08019.09
5.4.280.0070.05719.14
5.4.270.0070.07019.22
5.4.260.0100.07019.09
5.4.250.0070.07018.89
5.4.240.0130.03319.14
5.4.230.0030.07319.16
5.4.220.0000.05019.14
5.4.210.0000.07018.89
5.4.200.0100.06719.14
5.4.190.0070.07718.99
5.4.180.0030.07319.09
5.4.170.0000.09319.19
5.4.160.0030.06319.06
5.4.150.0070.07719.15
5.4.140.0030.07716.44
5.4.130.0070.04016.49
5.4.120.0030.07316.49
5.4.110.0030.07016.55
5.4.100.0070.07016.50
5.4.90.0070.07316.58
5.4.80.0000.06716.45
5.4.70.0000.07016.52
5.4.60.0030.06016.49
5.4.50.0070.06316.34
5.4.40.0030.08316.51
5.4.30.0030.07316.50
5.4.20.0000.07316.54
5.4.10.0100.07316.43
5.4.00.0000.07315.93