-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrap.php
More file actions
55 lines (53 loc) · 1.77 KB
/
bootstrap.php
File metadata and controls
55 lines (53 loc) · 1.77 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
<?php
declare(strict_types=1);
if (! function_exists('includeCwdVendorAutoloadIfExists')) {
function includeCwdVendorAutoloadIfExists(array $alreadyLoadedAutoloadFiles): void
{
$cwdVendorAutoload = \getcwd() . '/vendor/autoload.php';
if (! \is_file($cwdVendorAutoload)) {
return;
}
loadIfNotLoadedYet($cwdVendorAutoload, $alreadyLoadedAutoloadFiles);
}
}
if (! function_exists('includeDependencyOrRepositoryVendorAutoloadIfExists')) {
function includeDependencyOrRepositoryVendorAutoloadIfExists(array $alreadyLoadedAutoloadFiles): void
{
// vendor is already loaded
if (\class_exists(\Html\Delegator\HTMLDocumentDelegator::class)) {
return;
}
$devVendorAutoload = __DIR__ . '/../vendor/autoload.php';
if (! \is_file($devVendorAutoload)) {
return;
}
loadIfNotLoadedYet($devVendorAutoload, $alreadyLoadedAutoloadFiles);
}
}
if (! function_exists('autoloadProjectAutoloaderFile')) {
function autoloadProjectAutoloaderFile(string $file, array $alreadyLoadedAutoloadFiles): void
{
$path = \dirname(__DIR__) . $file;
if (! \is_file($path)) {
return;
}
loadIfNotLoadedYet($path, $alreadyLoadedAutoloadFiles);
}
}
if (! function_exists('loadIfNotLoadedYet')) {
function loadIfNotLoadedYet(string $file, array &$alreadyLoadedAutoloadFiles): void
{
if (! \file_exists($file)) {
return;
}
if (\in_array($file, $alreadyLoadedAutoloadFiles, \true)) {
return;
}
$realPath = \realpath($file);
if (! \is_string($realPath)) {
return;
}
$alreadyLoadedAutoloadFiles[] = $realPath;
require_once $file;
}
}