diff --git a/src/flextype/Foundation/Flextype.php b/src/flextype/Foundation/Flextype.php index 8861db11a..eca23d059 100644 --- a/src/flextype/Foundation/Flextype.php +++ b/src/flextype/Foundation/Flextype.php @@ -23,11 +23,11 @@ final class Flextype public const VERSION = '0.9.16'; /** - * The Flextype Application instances. + * The Flextype instance. * * @var array */ - private static array $instances = []; + private static ?Flextype $instance = null; /** * The Flextype Application. @@ -93,6 +93,8 @@ public function container(): Container /** * Returns Flextype Instance. + * + * Gets the instance via lazy initialization (created on first usage) * * @return Flextype Returns the current Flextype Instance. * @@ -100,12 +102,11 @@ public function container(): Container */ public static function getInstance(?ContainerInterface $container = null): Flextype { - $cls = static::class; - if (! isset(self::$instances[$cls])) { - self::$instances[$cls] = new static($container); + if (static::$instance === null) { + static::$instance = new self(); } - return self::$instances[$cls]; + return static::$instance; } /**