Skip to content

Commit 7a11808

Browse files
committed
Merge branch 'develop' into feature/standalone-phar-executable
2 parents b87357e + da69a6a commit 7a11808

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

PHPCtags.class.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
class PHPCtags
33
{
4+
const VERSION = 0.3;
5+
46
private $mFile;
57

68
private $mFiles;
@@ -343,18 +345,26 @@ private function process($file)
343345
continue;
344346
}
345347

346-
$this->setMFile((string) $filename);
348+
try {
349+
$this->setMFile((string) $filename);
350+
$this->mStructs = array_merge(
351+
$this->mStructs,
352+
$this->struct($this->mParser->parse(file_get_contents($this->mFile)), TRUE)
353+
);
354+
} catch(Exception $e) {
355+
echo "PHPParser: {$e->getMessage()} - {$filename}".PHP_EOL;
356+
}
357+
}
358+
} else {
359+
try {
360+
$this->setMFile($file);
347361
$this->mStructs = array_merge(
348362
$this->mStructs,
349363
$this->struct($this->mParser->parse(file_get_contents($this->mFile)), TRUE)
350364
);
365+
} catch(Exception $e) {
366+
echo "PHPParser: {$e->getMessage()} - {$filename}".PHP_EOL;
351367
}
352-
} else {
353-
$this->setMFile($file);
354-
$this->mStructs = array_merge(
355-
$this->mStructs,
356-
$this->struct($this->mParser->parse(file_get_contents($this->mFile)), TRUE)
357-
);
358368
}
359369
}
360370
}

bootstrap.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
);
1212
}
1313

14-
$version = <<<'EOF'
15-
Version: 0.3
14+
$version = PHPCtags::VERSION;
1615

16+
$copyright = <<<'EOF'
1717
Exuberant Ctags compatiable PHP enhancement, Copyright (C) 2012 Techlive Zheng
1818
Addresses: <techlivezheng@gmail.com>, https://github.com/techlivezheng/phpctags
1919
EOF;
@@ -95,15 +95,17 @@
9595
}
9696

9797
if (isset($options['help'])) {
98-
echo $version;
98+
echo "Version: ".$version."\n\n".$copyright;
9999
echo PHP_EOL;
100100
echo PHP_EOL;
101101
echo $options_info;
102+
echo PHP_EOL;
102103
exit;
103104
}
104105

105106
if (isset($options['version'])) {
106-
echo $version;
107+
echo "Version: ".$version."\n\n".$copyright;
108+
echo PHP_EOL;
107109
exit;
108110
}
109111

@@ -157,7 +159,7 @@
157159
} else if ($options['sort'] == 'foldcase') {
158160
$options['sort'] = 'foldcase';
159161
} else {
160-
die('phpctags: Invalid value for "sort" option');
162+
die('phpctags: Invalid value for "sort" option'.PHP_EOL);
161163
}
162164
// option -n is equivalent to --sort=no
163165
} else if (isset($options['u'])) {
@@ -179,15 +181,15 @@
179181
if ($options['append'] === FALSE || yes_or_no($options['append']) == 'yes') {
180182
$options['a'] = FALSE;
181183
} else if (yes_or_no($options['append']) != 'no') {
182-
die('phpctags: Invalid value for "append" option');
184+
die('phpctags: Invalid value for "append" option'.PHP_EOL);
183185
}
184186
}
185187

186188
if (isset($options['recurse'])) {
187189
if ($options['recurse'] === FALSE || yes_or_no($options['recurse']) == 'yes') {
188190
$options['R'] = FALSE;
189191
} else if (yes_or_no($options['recurse']) != 'no') {
190-
die('phpctags: Invalid value for "recurse" option');
192+
die('phpctags: Invalid value for "recurse" option'.PHP_EOL);
191193
}
192194
}
193195

@@ -201,7 +203,7 @@
201203
$ctags->addFiles($argv);
202204
$result = $ctags->export();
203205
} catch (Exception $e) {
204-
die("phpctags: {$e->getMessage()}");
206+
die("phpctags: {$e->getMessage()}".PHP_EOL);
205207
}
206208

207209
// write to a specified file
@@ -214,7 +216,18 @@
214216
} else {
215217
$tagfile = fopen('tags', isset($options['a']) ? 'a' : 'w');
216218
}
217-
fwrite($tagfile, $result);
219+
220+
$mode = ($options['sort'] == 'yes' ? 1 : ($options['sort'] == 'foldcase' ? 2 : 0));
221+
$tagline = <<<EOF
222+
!_TAG_FILE_FORMAT\t2\t/extended format; --format=1 will not append ;" to lines/
223+
!_TAG_FILE_SORTED\t{$mode}\t/0=unsorted, 1=sorted, 2=foldcase/
224+
!_TAG_PROGRAM_AUTHOR\ttechlivezheng\t/techlivezheng@gmail.com/
225+
!_TAG_PROGRAM_NAME\tphpctags\t//
226+
!_TAG_PROGRAM_URL\thttps://github.com/techlivezheng/phpctags\t/official site/
227+
!_TAG_PROGRAM_VERSION\t${version}\t//\n
228+
EOF;
229+
230+
fwrite($tagfile, $tagline.$result);
218231
fclose($tagfile);
219232

220233
function yes_or_no($arg) {

0 commit comments

Comments
 (0)