-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-funcs.php
More file actions
46 lines (38 loc) · 966 Bytes
/
parse-funcs.php
File metadata and controls
46 lines (38 loc) · 966 Bytes
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
<?php
$contents = file_get_contents($argv[1]);
$lines = explode("\n", $contents);
$res = array_filter($lines, function($line) {
if (stripos($line, ' function ') !== false) {
return true;
}
return false;
});
$clean = array_map(function($x) {
$strip = str_replace(' function ', ' ', $x);
$rem = str_replace('{', '', $strip);
$rem2 = str_replace('}', '', $rem);
$split = explode(' ', $rem2);
$filt = array_filter($split);
return array('access' => trim($filt[0]), 'name' => $filt[1]);
}, $res);
$pub = array_filter($clean, function($res) {
if ($res['access'] == 'public') {
return true;
}
return false;
});
$pro = array_filter($clean, function($res) {
if ($res['access'] == 'protected') {
return true;
}
return false;
});
printf("\n--%s--\n", basename($argv[1]));
printf("public\n");
foreach ($pub as $p) {
printf("\t%s\n", trim($p['name']));
}
printf("protected\n");
foreach ($pro as $p) {
printf("\t%s\n", trim($p['name']));
}