Skip to content

Commit f205a0c

Browse files
sandermarechalweynhamz
authored andcommitted
Add support for -R option
1 parent 38e2a94 commit f205a0c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

phpctags

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (is_dir($vendor = __DIR__ . '/vendor')) {
1212
);
1313
}
1414

15-
$options = getopt('af:',array(
15+
$options = getopt('af:R',array(
1616
'append::',
1717
'debug',
1818
'excmd::',
@@ -57,7 +57,28 @@ if(isset($options['append'])) {
5757
}
5858

5959
$ctags = new PHPCtags();
60-
$result = $ctags->export($file, $options);
60+
$result = '';
61+
if (isset($options['R'])) {
62+
$iterator = new RecursiveIteratorIterator(
63+
new RecursiveDirectoryIterator(
64+
$file,
65+
FilesystemIterator::SKIP_DOTS |
66+
FilesystemIterator::FOLLOW_SYMLINKS
67+
)
68+
);
69+
70+
$extensions = array('.php', '.php3', '.php4', '.php5', '.phps');
71+
72+
foreach ($iterator as $filename) {
73+
if (!in_array(substr($filename, strrpos($filename, '.')), $extensions)) {
74+
continue;
75+
}
76+
77+
$result .= $ctags->export($filename, $options);
78+
}
79+
} else {
80+
$result = $ctags->export($file, $options);
81+
}
6182

6283
if (isset($options['f']) && $options['f'] !== '-') {
6384
$tagfile = fopen($options['f'], isset($options['a']) ? 'a' : 'w');

0 commit comments

Comments
 (0)