-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-all.php
More file actions
77 lines (65 loc) · 2.89 KB
/
run-all.php
File metadata and controls
77 lines (65 loc) · 2.89 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
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* Run all kariricode/classdiscovery examples in sequence.
* Validates the library end-to-end against real use cases.
*
* Usage: php run-all.php
*/
$examples = [
'01' => 'Basic FileScanner',
'02' => 'Attribute Filter (Route)',
'03' => 'Service Auto-Registration',
'04' => 'Event Listener Discovery',
'05' => 'File Cache Strategy',
'06' => 'ReflectionScanner + Attribute Instances',
'07' => 'AttributeScanner — scanForAttribute / scanForAttributes',
'08' => 'CompositeFilter / InterfaceFilter / NamespaceFilter / StructuralFilter',
'09' => 'ChainCacheStrategy — Memory (L1) + File (L2)',
'10' => 'DirectoryScanner — maxDepth, setPattern, setFollowSymlinks',
'11' => 'DependencyAnalyzer + CircularDetector',
'12' => 'DiscoveryResult — filter, merge, hasClass, getErrors',
'13' => 'PSR11Integration + ConfiguratorBridge',
];
$examplesDir = __DIR__ . '/examples';
$passed = 0;
$failed = 0;
echo "\n";
echo "╔══════════════════════════════════════════════════════════════╗\n";
echo "║ kariricode/classdiscovery — Example Validation ║\n";
echo "╚══════════════════════════════════════════════════════════════╝\n";
foreach ($examples as $number => $name) {
$file = "{$examplesDir}/{$number}-*.php";
$files = glob($file);
if (empty($files)) {
echo "\n ⚠ [{$number}] {$name} — file not found\n";
++$failed;
continue;
}
$script = $files[0];
$output = null;
$exitCode = null;
exec("php -f " . escapeshellarg($script) . " 2>&1", $output, $exitCode);
if ($exitCode === 0) {
echo implode("\n", $output) . "\n";
++$passed;
} else {
echo "\n ✗ [{$number}] {$name} FAILED (exit {$exitCode}):\n";
foreach ($output as $line) {
echo " {$line}\n";
}
++$failed;
}
}
echo "╔══════════════════════════════════════════════════════════════╗\n";
echo "║ Results: {$passed} passed";
if ($failed > 0) {
echo " / {$failed} failed";
}
$total = $passed + $failed;
echo " ({$total} total)";
$padding = str_repeat(' ', max(0, 43 - strlen("{$passed} passed") - strlen($failed > 0 ? " / {$failed} failed" : "") - strlen("({$total} total)")));
echo "{$padding}║\n";
echo "╚══════════════════════════════════════════════════════════════╝\n\n";
exit($failed > 0 ? 1 : 0);