forked from vimeo/psalm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreloader.php
37 lines (30 loc) · 810 Bytes
/
Preloader.php
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
<?php
declare(strict_types=1);
namespace Psalm\Internal;
use Psalm\Progress\Phase;
use Psalm\Progress\Progress;
use function class_exists;
use function count;
/** @internal */
final class Preloader
{
private static bool $preloaded = false;
public static function preload(?Progress $progress = null, bool $hasJit = false): void
{
if (self::$preloaded) {
return;
}
if ($hasJit) {
$progress?->startPhase(Phase::JIT_COMPILATION);
$progress?->expand(count(PreloaderList::CLASSES)+1);
}
foreach (PreloaderList::CLASSES as $class) {
$progress?->taskDone(0);
class_exists($class);
}
if ($hasJit) {
$progress?->finish();
}
self::$preloaded = true;
}
}