diff options
Diffstat (limited to 'vendor/composer/ClassLoader.php')
-rw-r--r-- | vendor/composer/ClassLoader.php | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 3a8ed4886..fd56bd7d8 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -43,7 +43,7 @@ namespace Composer\Autoload; class ClassLoader { /** @var \Closure(string):void */ - private $includeFile; + private static $includeFile; /** @var ?string */ private $vendorDir; @@ -109,18 +109,7 @@ class ClassLoader public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - $this->includeFile = static function($file) { - include $file; - }; + self::initializeIncludeClosure(); } /** @@ -440,7 +429,7 @@ class ClassLoader public function loadClass($class) { if ($file = $this->findFile($class)) { - ($this->includeFile)($file); + (self::$includeFile)($file); return true; } @@ -570,4 +559,23 @@ class ClassLoader return false; } + + private static function initializeIncludeClosure(): void + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = static function($file) { + include $file; + }; + } } |