Skip to content

Commit 68f4bb3

Browse files
sandermarechalweynhamz
authored andcommitted
Make -f option work as expected
1 parent 56399c1 commit 68f4bb3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

PHPCtags.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,6 @@ public function export($file, $options)
228228
//@todo Check for existence
229229
$this->mFile = $file;
230230
$structs = $this->struct($this->mParser->parse(file_get_contents($this->mFile)), TRUE);
231-
echo $this->render($structs, $options);
231+
return $this->render($structs, $options);
232232
}
233233
}

phpctags

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ if(!isset($options['fields'])) {
4848
}
4949

5050
$ctags = new PHPCtags();
51-
$ctags->export($file, $options);
51+
$result = $ctags->export($file, $options);
52+
53+
if (isset($options['f']) && $options['f'] !== '-') {
54+
$tagfile = fopen($options['f'], 'w');
55+
} else {
56+
$tagfile = fopen('php://stdout', 'w');
57+
}
58+
fwrite($tagfile, $result);
59+
fclose($tagfile);

tests/PHPCtagsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testExport($testcase)
6161
ob_start();
6262
$testcase_example = $testcase_object->getExample();
6363
$testcase_options = $testcase_object->getOptions();
64-
$this->object->export($testcase_example, $testcase_options);
64+
echo $this->object->export($testcase_example, $testcase_options);
6565
$testcase_result = ob_get_contents();
6666
ob_end_clean();
6767

0 commit comments

Comments
 (0)