Skip to content

Commit d0a8eee

Browse files
committed
Clean up the coding style
1 parent 220a755 commit d0a8eee

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

PHPCtags.class.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,34 @@ class PHPCtags
33
{
44
private $mFile;
55

6-
private $mParser;
7-
86
private static $mKinds = array(
9-
'c' => 'class',
10-
'm' => 'method',
11-
'f' => 'function',
12-
'p' => 'property',
13-
'd' => 'constant',
14-
'v' => 'variable',
15-
'i' => 'interface',
16-
);
7+
'c' => 'class',
8+
'm' => 'method',
9+
'f' => 'function',
10+
'p' => 'property',
11+
'd' => 'constant',
12+
'v' => 'variable',
13+
'i' => 'interface',
14+
);
15+
16+
private $mParser;
1717

1818
public function __construct()
1919
{
2020
$this->mParser = new PHPParser_Parser(new PHPParser_Lexer);
2121
}
2222

23-
public function setMFile($file) {
24-
if(empty($file)) {
23+
public function setMFile($file)
24+
{
25+
if (empty($file)) {
2526
throw new PHPCtagsException('No File specified.');
2627
}
2728

28-
if(!file_exists($file)) {
29+
if (!file_exists($file)) {
2930
throw new PHPCtagsException('Warning: cannot open source file "' . $file . '" : No such file');
3031
}
3132

32-
if(!is_readable($file)) {
33+
if (!is_readable($file)) {
3334
throw new PHPCtagsException('Warning: cannot open source file "' . $file . '" : File is not readable');
3435
}
3536

@@ -74,7 +75,8 @@ public static function stringSortByLine($str, $foldcase=FALSE)
7475
return $str;
7576
}
7677

77-
private static function helperSortByLine($a, $b) {
78+
private static function helperSortByLine($a, $b)
79+
{
7880
return $a['line'] > $b['line'] ? 1 : 0;
7981
}
8082

@@ -89,7 +91,7 @@ private function struct($node, $reset=FALSE, $parent=array())
8991

9092
$kind = $name = $line = $access = '';
9193

92-
if(!empty($parent)) array_push($scope, $parent);
94+
if (!empty($parent)) array_push($scope, $parent);
9395

9496
if (is_array($node)) {
9597
foreach ($node as $subNode) {
@@ -163,7 +165,7 @@ private function struct($node, $reset=FALSE, $parent=array())
163165
$this->struct($subNode);
164166
}
165167
} elseif ($node instanceof PHPParser_Node_Expr_Assign) {
166-
if(is_string($node->var->name)) {
168+
if (is_string($node->var->name)) {
167169
$kind = 'v';
168170
$node = $node->var;
169171
$name = $node->name;
@@ -193,7 +195,7 @@ private function struct($node, $reset=FALSE, $parent=array())
193195
);
194196
}
195197

196-
if(!empty($parent)) array_pop($scope);
198+
if (!empty($parent)) array_pop($scope);
197199

198200
// if no --sort is given, sort by occurrence
199201
if (!isset($options['sort']) || $options['sort'] == 'no') {
@@ -257,11 +259,11 @@ private function render($structs, $options)
257259
#field=s
258260
if (in_array('s', $options['fields']) && !empty($struct['scope'])) {
259261
$scope = array_pop($struct['scope']);
260-
list($type,$name) = each($scope);
262+
list($type, $name) = each($scope);
261263
switch ($type) {
262264
case 'method':
263265
$scope = array_pop($struct['scope']);
264-
list($p_type,$p_name) = each($scope);
266+
list($p_type, $p_name) = each($scope);
265267
$scope = 'method:' . $p_name . '::' . $name;
266268
break;
267269
default:

phpctags

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

15-
$options = getopt('af:Nno:RuV',array(
15+
$options = getopt('af:Nno:RuV', array(
1616
'append::',
1717
'debug',
1818
'exclude:',
@@ -30,11 +30,11 @@ if (isset($options['V'])) {
3030
$options['version'] = FALSE;
3131
}
3232

33-
if(!isset($options['debug'])) {
33+
if (!isset($options['debug'])) {
3434
error_reporting(0);
3535
}
3636

37-
if(isset($options['version'])) {
37+
if (isset($options['version'])) {
3838
echo <<<'EOF'
3939
Version: 0.2
4040
@@ -73,14 +73,14 @@ if (isset($options['N']) && !isset($options['n'])) {
7373
$options['excmd'] = 'pattern';
7474
}
7575

76-
if(!isset($options['excmd']))
76+
if (!isset($options['excmd']))
7777
$options['excmd'] = 'pattern';
78-
if(!isset($options['format']))
78+
if (!isset($options['format']))
7979
$options['format'] = 2;
80-
if(!isset($options['memory']))
80+
if (!isset($options['memory']))
8181
$options['memory'] = '128M';
82-
if(!isset($options['fields'])) {
83-
$options['fields'] = array('n', 'k','s', 'a');
82+
if (!isset($options['fields'])) {
83+
$options['fields'] = array('n', 'k', 's', 'a');
8484
} else {
8585
$options['fields'] = str_split($options['fields']);
8686
}
@@ -115,15 +115,15 @@ if (isset($options['memory'])) {
115115
}
116116
}
117117

118-
if(isset($options['append'])) {
118+
if (isset($options['append'])) {
119119
if ($options['append'] === FALSE || yes_or_no($options['append']) == 'yes') {
120120
$options['a'] = FALSE;
121121
} else if (yes_or_no($options['append']) != 'no') {
122122
die('phpctags: Invalid value for "append" option');
123123
}
124124
}
125125

126-
if(isset($options['recurse'])) {
126+
if (isset($options['recurse'])) {
127127
if ($options['recurse'] === FALSE || yes_or_no($options['recurse']) == 'yes') {
128128
$options['R'] = FALSE;
129129
} else if (yes_or_no($options['recurse']) != 'no') {

0 commit comments

Comments
 (0)