@@ -7,9 +7,7 @@ class PHPCtags
77
88 private $ mParser ;
99
10- private $ mOptions ;
11-
12- public function __construct ($ file , $ options =array ())
10+ public function __construct ($ file )
1311 {
1412 //@todo Check for existence
1513 $ this ->mFile = $ file ;
@@ -23,7 +21,6 @@ public function __construct($file, $options=array())
2321 'i ' => 'interface ' ,
2422 );
2523 $ this ->mParser = new PHPParser_Parser (new PHPParser_Lexer );
26- $ this ->mOptions = $ options ;
2724 }
2825
2926 private function getNodeAccess ($ node )
@@ -143,7 +140,7 @@ private function struct($node, $parent=array())
143140 return $ structs ;
144141 }
145142
146- private function render ($ structs )
143+ private function render ($ structs, $ options )
147144 {
148145 $ str = '' ;
149146 $ lines = file ($ this ->mFile );
@@ -159,37 +156,37 @@ private function render($structs)
159156
160157 $ str .= "\t" . $ this ->mFile ;
161158
162- if ($ this -> mOptions ['excmd ' ] == 'number ' ) {
159+ if ($ options ['excmd ' ] == 'number ' ) {
163160 $ str .= "\t" . $ struct ['line ' ];
164161 } else { //excmd == 'mixed' or 'pattern', default behavior
165162 $ str .= "\t" . "/^ " . rtrim ($ lines [$ struct ['line ' ] - 1 ], "\n" ) . "$/ " ;
166163 }
167164
168- if ($ this -> mOptions ['format ' ] == 1 ) {
165+ if ($ options ['format ' ] == 1 ) {
169166 $ str .= "\n" ;
170167 continue ;
171168 }
172169
173170 $ str .= "; \"" ;
174171
175172 #field=k, kind of tag as single letter
176- if (in_array ('k ' , $ this -> mOptions ['fields ' ])) {
177- in_array ('z ' , $ this -> mOptions ['fields ' ]) && $ str .= "kind: " ;
173+ if (in_array ('k ' , $ options ['fields ' ])) {
174+ in_array ('z ' , $ options ['fields ' ]) && $ str .= "kind: " ;
178175 $ str .= "\t" . $ struct ['kind ' ];
179176 } else
180177 #field=K, kind of tag as fullname
181- if (in_array ('K ' , $ this -> mOptions ['fields ' ])) {
182- in_array ('z ' , $ this -> mOptions ['fields ' ]) && $ str .= "kind: " ;
178+ if (in_array ('K ' , $ options ['fields ' ])) {
179+ in_array ('z ' , $ options ['fields ' ]) && $ str .= "kind: " ;
183180 $ str .= "\t" . $ this ->mKinds [$ struct ['kind ' ]];
184181 }
185182
186183 #field=n
187- if (in_array ('n ' , $ this -> mOptions ['fields ' ])) {
184+ if (in_array ('n ' , $ options ['fields ' ])) {
188185 $ str .= "\t" . "line: " . $ struct ['line ' ];
189186 }
190187
191188 #field=s
192- if (in_array ('s ' , $ this -> mOptions ['fields ' ]) && !empty ($ struct ['scope ' ])) {
189+ if (in_array ('s ' , $ options ['fields ' ]) && !empty ($ struct ['scope ' ])) {
193190 $ scope = array_pop ($ struct ['scope ' ]);
194191 list ($ type ,$ name ) = each ($ scope );
195192 switch ($ type ) {
@@ -206,7 +203,7 @@ private function render($structs)
206203 }
207204
208205 #field=a
209- if (in_array ('a ' , $ this -> mOptions ['fields ' ]) && !empty ($ struct ['access ' ])) {
206+ if (in_array ('a ' , $ options ['fields ' ]) && !empty ($ struct ['access ' ])) {
210207 $ str .= "\t" . "access: " . $ struct ['access ' ];
211208 }
212209
@@ -215,9 +212,9 @@ private function render($structs)
215212 return $ str ;
216213 }
217214
218- public function export ()
215+ public function export ($ options )
219216 {
220217 $ structs = $ this ->struct ($ this ->mParser ->parse (file_get_contents ($ this ->mFile )));
221- echo $ this ->render ($ structs );
218+ echo $ this ->render ($ structs, $ options );
222219 }
223220}
0 commit comments