forked from phpstan/phpstan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
144 lines (122 loc) · 6.17 KB
/
bootstrap.php
File metadata and controls
144 lines (122 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php declare(strict_types = 1);
namespace PHPStan;
use Composer\Autoload\ClassLoader;
use function class_exists;
use const PHP_VERSION_ID;
final class PharAutoloader
{
/** @var ClassLoader */
private static $composerAutoloader;
/** @var bool */
private static $polyfillsLoaded = false;
final public static function loadClass(string $class): void {
if (!extension_loaded('phar') || defined('__PHPSTAN_RUNNING__')) {
return;
}
if (strpos($class, '_PHPStan_') === 0) {
if (!in_array('phar', stream_get_wrappers(), true)) {
throw new \Exception('Phar wrapper is not registered. Please review your php.ini settings.');
}
if (self::$composerAutoloader === null) {
self::$composerAutoloader = require 'phar://' . __DIR__ . '/phpstan.phar/vendor/autoload.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/react/async/src/functions_include.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/react/promise/src/functions_include.php';
}
self::$composerAutoloader->loadClass($class);
return;
}
if (strpos($class, 'PHPStan\\') !== 0 || strpos($class, 'PHPStan\\PhpDocParser\\') === 0) {
return;
}
if (!in_array('phar', stream_get_wrappers(), true)) {
throw new \Exception('Phar wrapper is not registered. Please review your php.ini settings.');
}
if (!self::$polyfillsLoaded) {
self::$polyfillsLoaded = true;
if (
PHP_VERSION_ID < 80000
&& empty($GLOBALS['__composer_autoload_files']['a4a119a56e50fbb293281d9a48007e0e'])
&& !class_exists(\Symfony\Polyfill\Php80\Php80::class, false)
) {
$GLOBALS['__composer_autoload_files']['a4a119a56e50fbb293281d9a48007e0e'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php80/Php80.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php80/bootstrap.php';
}
if (
empty($GLOBALS['__composer_autoload_files']['0e6d7bf4a5811bfa5cf40c5ccd6fae6a'])
&& !class_exists(\Symfony\Polyfill\Mbstring\Mbstring::class, false)
) {
$GLOBALS['__composer_autoload_files']['0e6d7bf4a5811bfa5cf40c5ccd6fae6a'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-mbstring/Mbstring.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-mbstring/bootstrap.php';
}
if (
empty($GLOBALS['__composer_autoload_files']['e69f7f6ee287b969198c3c9d6777bd38'])
&& !class_exists(\Symfony\Polyfill\Intl\Normalizer\Normalizer::class, false)
) {
$GLOBALS['__composer_autoload_files']['e69f7f6ee287b969198c3c9d6777bd38'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-intl-normalizer/Normalizer.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-intl-normalizer/bootstrap.php';
}
if (
!extension_loaded('intl')
&& empty($GLOBALS['__composer_autoload_files']['8825ede83f2f289127722d4e842cf7e8'])
&& !class_exists(\Symfony\Polyfill\Intl\Grapheme\Grapheme::class, false)
) {
$GLOBALS['__composer_autoload_files']['8825ede83f2f289127722d4e842cf7e8'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-intl-grapheme/Grapheme.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-intl-grapheme/bootstrap.php';
}
if (
PHP_VERSION_ID < 80100
&& empty ($GLOBALS['__composer_autoload_files']['23c18046f52bef3eea034657bafda50f'])
&& !class_exists(\Symfony\Polyfill\Php81\Php81::class, false)
) {
$GLOBALS['__composer_autoload_files']['23c18046f52bef3eea034657bafda50f'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php81/Php81.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php81/bootstrap.php';
}
if (
PHP_VERSION_ID < 80300
&& empty ($GLOBALS['__composer_autoload_files']['662a729f963d39afe703c9d9b7ab4a8c'])
&& !class_exists(\Symfony\Polyfill\Php83\Php83::class, false)
) {
$GLOBALS['__composer_autoload_files']['662a729f963d39afe703c9d9b7ab4a8c'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php83/Php83.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php83/bootstrap.php';
}
if (
PHP_VERSION_ID < 80400
&& empty ($GLOBALS['__composer_autoload_files']['9d2b9fc6db0f153a0a149fefb182415e'])
&& !class_exists(\Symfony\Polyfill\Php83\Php84::class, false)
) {
$GLOBALS['__composer_autoload_files']['9d2b9fc6db0f153a0a149fefb182415e'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php84/Php84.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php84/bootstrap.php';
}
if (
PHP_VERSION_ID < 80500
&& empty ($GLOBALS['__composer_autoload_files']['606a39d89246991a373564698c2d8383'])
&& !class_exists(\Symfony\Polyfill\Php83\Php85::class, false)
) {
$GLOBALS['__composer_autoload_files']['606a39d89246991a373564698c2d8383'] = true;
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php85/Php85.php';
require_once 'phar://' . __DIR__ . '/phpstan.phar/vendor/symfony/polyfill-php85/bootstrap.php';
}
}
$filename = str_replace('\\', DIRECTORY_SEPARATOR, $class);
if (strpos($class, 'PHPStan\\BetterReflection\\') === 0) {
$filename = substr($filename, strlen('PHPStan\\BetterReflection\\'));
$filepath = 'phar://' . __DIR__ . '/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/' . $filename . '.php';
} else {
$filename = substr($filename, strlen('PHPStan\\'));
$filepath = 'phar://' . __DIR__ . '/phpstan.phar/src/' . $filename . '.php';
}
if (!file_exists($filepath)) {
return;
}
require $filepath;
}
}
spl_autoload_register([PharAutoloader::class, 'loadClass']);