1
- import phpParser from 'php-parser' ;
1
+ import phpParser from 'php-parser' ;
2
2
import { ParsedResult } from './ParsedResult' ;
3
3
import { ClassInfo } from './ClassInfo' ;
4
4
@@ -18,32 +18,29 @@ export class Parser {
18
18
withPositions : true
19
19
}
20
20
} ) ;
21
-
22
21
}
23
22
24
- parse ( ) : ParsedResult {
23
+ public parse ( ) : ParsedResult {
25
24
return this . getClasses ( ) ;
26
25
}
27
26
28
- getClasses ( ) : ParsedResult {
27
+ private getClasses ( ) : ParsedResult {
29
28
let parsedCode = this . parser . parseCode ( this . text , '' ) ;
30
-
29
+
31
30
return {
32
31
useStatements : this . getUseStatements ( parsedCode ) ,
33
32
classesUsed : this . getClassesInBody ( parsedCode )
34
33
} ;
35
34
}
36
35
37
- getClassesInBody ( parsedCode : object ) : ClassInfo [ ] {
38
-
39
-
36
+ private getClassesInBody ( parsedCode : object ) : ClassInfo [ ] {
40
37
let allClasses = [ ] ;
41
38
this . getBodyElements ( parsedCode ) . forEach ( row => {
42
39
if ( this . isObject ( row ) ) {
43
40
allClasses . push ( ...this . getClassesForObject ( row ) ) ;
44
41
}
45
42
} ) ;
46
-
43
+
47
44
allClasses = this . filterOutFunctions ( allClasses ) ;
48
45
49
46
return allClasses . concat ( this . getExtendedClasses ( parsedCode ) ) ;
@@ -87,13 +84,13 @@ export class Parser {
87
84
88
85
Object . entries ( row ) . forEach ( ( [ key , value ] ) => {
89
86
if ( key === 'kind' && value === 'classreference' ) {
90
- classes . push ( new ClassInfo ( row ) ) ;
87
+ classes . push ( new ClassInfo ( row ) ) ;
91
88
} else if ( Array . isArray ( value ) ) {
92
89
value . forEach ( row => {
93
90
if ( this . isObject ( row ) ) {
94
91
classes . push ( ...this . getClassesForObject ( row ) ) ;
95
92
}
96
- } ) ;
93
+ } ) ;
97
94
} else if ( this . isObject ( value ) ) {
98
95
classes . push ( ...this . getClassesForObject ( value ) ) ;
99
96
}
@@ -109,7 +106,7 @@ export class Parser {
109
106
return typeof value === 'object' ;
110
107
}
111
108
112
- getElements ( parsedCode : any ) : any [ ] {
109
+ private getElements ( parsedCode : any ) : any [ ] {
113
110
let children = parsedCode . children ;
114
111
115
112
const nameSpaceObject = children . find ( row => {
@@ -146,10 +143,10 @@ export class Parser {
146
143
return [ ] ;
147
144
}
148
145
149
- getUseStatements ( parsedCode : object ) : ClassInfo [ ] {
146
+ private getUseStatements ( parsedCode : object ) : ClassInfo [ ] {
150
147
return this . getElements ( parsedCode ) . flatMap ( child => {
151
148
if ( child . kind === 'usegroup' ) {
152
- return child . items . map ( item => {
149
+ return child . items . map ( item => {
153
150
return new ClassInfo ( item ) ;
154
151
} ) ;
155
152
}
0 commit comments