3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class Catalog_Model_DbSelect_Abstract { /** All created instances so far */ protected static $_instances = array(); protected $property; /** * Gets the singleton of a select statement * @param array|string $args The arguments arguments that are needed to build the select (e.g. attribute set names, product types). * @return Catalog_Model_DbSelect_Abstract The select instance */ public static function getInstance($args = null) { $class = get_called_class(); $key = $class . (is_array($args) ? implode('_', $args) : $args); if (!array_key_exists($key, static::$_instances)) { static::$_instances[$key] = new $class($args); } return clone static::$_instances[$key]; } public function setProperty($property) { $this->property=$property;} public function getProperty() { return $this->property;} } class DerivedClass1 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass2 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass3 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass4 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass5 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass6 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass7 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass8 extends Catalog_Model_DbSelect_Abstract {} class DerivedClass9 extends Catalog_Model_DbSelect_Abstract {} $mem = memory_get_usage(); for ($classI = 1; $classI < 10; $classI++) { for ($argsI = 1; $argsI < 20; $argsI++) { for ($varnameI = 1; $varnameI < 20; $varnameI++) { $classname = 'DerivedClass' . $classI; $varname = 'instance' . $varnameI; $args = 'foo' . $argsI; $$varname = $classname::getInstance($args); echo 'called ' . $classname . '::getInstance(' . $args . ')' . PHP_EOL; if (isset($propertySet) && !isset($propertyRead)) { $propertyRead = $$varname->getProperty(); var_dump($propertyRead); $propertyRead = true; } if (!isset($propertySet)) { $$varname->setProperty('bar'); $propertySet = true; } echo 'memory usage: ' . (memory_get_usage() - $mem) . PHP_EOL; } } }

Abusive script

This script was stopped while abusing our resources