1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
*/ |
4
|
|
|
function scandir_r($directory) { |
5
|
|
|
// $files = array_slice(scandir($directory, SCANDIR_SORT_NONE), 2); |
6
|
|
|
$files = array_slice(scandir($directory), 2); |
|
|
|
|
7
|
|
|
|
8
|
|
|
$map = []; |
9
|
|
|
foreach ($files as $file) { |
10
|
|
|
if (is_dir( $directory . '/' . $file)) { |
11
|
|
|
$submap = scandir_r($directory . '/' . $file); |
12
|
|
|
$map = array_merge($map, $submap); |
13
|
|
|
} |
14
|
|
|
else { |
15
|
|
|
$map[] = $directory . '/' . $file; |
16
|
|
|
} |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
return $map; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
if (PHP_VERSION_ID >= 70000) { |
23
|
|
|
$root = 'src'; |
24
|
|
|
} |
25
|
|
|
else { |
26
|
|
|
$root = 'src_5.6'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$map = scandir_r($root); |
30
|
|
|
foreach ($map as &$map_entry) { |
31
|
|
|
$map_entry = preg_replace("/^src(_\d+\.\d+)?\//", '', $map_entry); |
32
|
|
|
} |
33
|
|
|
// var_export($map); exit; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Dependency map has to be ordered to declare dependencies before |
37
|
|
|
* the code needing it. |
38
|
|
|
*/ |
39
|
|
|
$sorted_map = [ |
40
|
|
|
'ArrayAccessTrait.php', |
41
|
|
|
'FunctionCallTrait.php', |
42
|
|
|
'ExportTrait.php', |
43
|
|
|
'DeferredCallChain.php', |
44
|
|
|
'Exceptions/BadTargetClassException.php', |
45
|
|
|
'Exceptions/BadTargetInterfaceException.php', |
46
|
|
|
'Exceptions/BadTargetTypeException.php', |
47
|
|
|
'Exceptions/TargetAlreadyDefinedException.php', |
48
|
|
|
'Exceptions/UndefinedTargetClassException.php', |
49
|
|
|
'functions.php', |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
if ($missing = array_diff($sorted_map, $map)) { |
53
|
|
|
throw new \Exception( |
54
|
|
|
"Missing file in your classmap. Please add it manually to " |
55
|
|
|
. __FILE__ . "\n" |
56
|
|
|
. var_export($missing, true) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
foreach ($sorted_map as $filepath) { |
61
|
|
|
require_once($root . '/' . $filepath); |
62
|
|
|
} |
63
|
|
|
|