public function testSingletons() { $this->assertSame(Symfony::getInstance(Symfony::PSR0), Symfony::getInstance(Symfony::PSR0)); $this->assertSame(Symfony::getInstance(Symfony::PSR4), Symfony::getInstance(Symfony::PSR4)); }
const PSR0 = 'psr0'; const PSR4 = 'psr4'; private static $instances = array(); private function __construct() { } public static function getInstance($type = self::PSR0) { if (!isset(static::$instances[$type])) { switch ($type) { case self::PSR0: Common::prefixPsr0ClassRequire('Symfony\\Component\\ClassLoader\\ClassLoader'); static::$instances[$type] = new ClassLoader(); break; case self::PSR4: Common::prefixPsr0ClassRequire('Symfony\\Component\\ClassLoader\\Psr4ClassLoader'); static::$instances[$type] = new Psr4ClassLoader(); break; default: throw new \InvalidArgumentException('Invalid type'); } static::$instances[$type]->register(); } return static::$instances[$type]; } } if (!Common::isFedoraNamespaceRegistered()) { Symfony::getInstance()->addPrefix('Fedora\\Autoload\\', dirname(dirname(__DIR__))); Symfony::getInstance()->addPrefix('Fedora\\', Common::LIB_DIR); Common::setFedoraNamespaceRegistered(); }