Skip to content

Commit 8bbb015

Browse files
committed
Autoloader bootstrap - save memory
1 parent 2b6ca1b commit 8bbb015

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bootstrap.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php declare(strict_types = 1);
22

33
spl_autoload_register(function (string $class): void {
4+
static $composerAutoloader;
45
if (!extension_loaded('phar') || defined('__PHPSTAN_RUNNING__')) {
56
return;
67
}
@@ -10,7 +11,9 @@
1011
throw new \Exception('Phar wrapper is not registered. Please review your php.ini settings.');
1112
}
1213

13-
$composerAutoloader = require 'phar://' . __DIR__ . '/phpstan.phar/vendor/autoload.php';
14+
if ($composerAutoloader === null) {
15+
$composerAutoloader = require 'phar://' . __DIR__ . '/phpstan.phar/vendor/autoload.php';
16+
}
1417
$composerAutoloader->loadClass($class);
1518

1619
return;

0 commit comments

Comments
 (0)