-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
100 lines (72 loc) · 2.38 KB
/
test.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
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
<?php
require(sprintf(
'%s/vendor/autoload.php',
dirname(__FILE__)
));
$Files = [];
$Directory = NULL;
$Finder = NULL;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
$Files = [
//'class.php',
//'src/Nether/Senpai/Statement.php',
//'src/Nether/Senpai/Statements/ClassStatement.php',
//'src/Nether/Senpai/Statements/MethodStatement.php'
];
$Directory = new RecursiveDirectoryIterator(
'src',
FilesystemIterator::SKIP_DOTS
);
$Finder = new RegexIterator(
new RecursiveIteratorIterator($Directory),
'/\.php$/i'
);
foreach($Finder as $File) {
$Files[] = $File->GetPathname();
}
/*
print_r($Files);
echo PHP_EOL;
*/
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// index all the code.
$Indexer = new Nether\Senpai\Indexers\IndexIndexer;
foreach($Files as $File) {
$FileIndexer = new Nether\Senpai\Indexers\FileIndexer($File);
$Result = $FileIndexer->Run();
$Indexer->AddNamespace($Result->GetNamespace());
}
// print an overview.
$Namespaces = $Indexer->Run();
foreach($Namespaces as $Namespace) {
echo PHP_EOL;
echo "namespace\n{$Namespace->GetName()} {\n", PHP_EOL;
foreach($Namespace->GetTraits() as $Trait) {
echo "\ttrait\n\t{$Trait->GetName()} {\n", PHP_EOL;
if($Trait->GetAnnotation()->GetData())
echo "\t\t".str_replace("\n","\n\t\t",$Trait->GetAnnotation()->GetData())."\n\n";
foreach($Trait->GetMethods() as $Method) {
echo "\t\tmethod {$Method->GetAccessWords()}\n";
echo "\t\t{$Method->GetName()};\n", PHP_EOL;
if($Method->GetAnnotation()->GetData())
echo "\t\t".str_replace("\n","\n\t\t",$Method->GetAnnotation()->GetData())."\n\n";
}
echo "\t};\n", PHP_EOL;
}
foreach($Namespace->GetClasses() as $Class) {
echo "\tclass\n\t{$Class->GetName()} {\n", PHP_EOL;
if($Class->GetAnnotation()->GetData())
echo "\t\t".str_replace("\n","\n\t\t",$Class->GetAnnotation()->GetData())."\n\n";
foreach($Class->GetMethods() as $Method) {
echo "\t\tmethod {$Method->GetAccessWords()}\n";
echo "\t\t{$Method->GetName()};\n", PHP_EOL;
if($Method->GetAnnotation()->GetData())
echo "\t\t".str_replace("\n","\n\t\t",$Method->GetAnnotation()->GetData())."\n\n";
}
echo "\t};\n", PHP_EOL;
}
echo "};\n";
echo PHP_EOL;
}