@@ -21,10 +21,16 @@ class ClassResolver
2121 const RESOLVED_TYPE_CLASS = 'RESOLVED_TYPE_CLASS ' ;
2222 const RESOLVED_TYPE_IMITATION = 'RESOLVED_TYPE_IMITATION ' ;
2323
24- private static $ resolves = [];
25- private static $ resolvedPaths = [];
24+ private $ resolves = [];
25+ private $ resolvedPaths = [];
26+ private $ options = [];
2627
27- public static function resolve (string $ javaPath , JavaClass $ class = null ): array
28+ public function __construct (array $ options )
29+ {
30+ $ this ->options = $ options ;
31+ }
32+
33+ public function resolve (string $ javaPath , JavaClass $ class = null ): array
2834 {
2935 $ namespaces = explode ('. ' , str_replace ('/ ' , '. ' , $ javaPath ));
3036 $ buildClassPath = [];
@@ -34,19 +40,22 @@ public static function resolve(string $javaPath, JavaClass $class = null): array
3440
3541 // resolve something approaching
3642 $ relativePath = implode ('/ ' , $ namespaces );
37- foreach (static :: $ resolves as [$ resourceType , $ value ]) {
43+ foreach ($ this -> resolves as [$ resourceType , $ value ]) {
3844 switch ($ resourceType ) {
3945 case static ::RESOURCE_TYPE_FILE :
4046 $ path = realpath ($ value . '/ ' . $ relativePath . '.class ' );
41- if (($ key = array_search ($ path , static :: $ resolvedPaths , true )) !== false ) {
42- return static :: $ resolvedPaths [$ key ];
47+ if (($ key = array_search ($ path , $ this -> resolvedPaths , true )) !== false ) {
48+ return $ this -> resolvedPaths [$ key ];
4349 }
4450 if (is_file ($ path )) {
45- $ initiatedClass = new JavaClass (new FileReader ($ path ));
51+ $ initiatedClass = new JavaClass (
52+ new FileReader ($ path ),
53+ $ this ->options
54+ );
4655 if (strpos ($ relativePath , '$ ' ) !== false && $ class !== null ) {
4756 $ initiatedClass ->setParentClass ($ class );
4857 }
49- return $ resolvedPaths [] = [
58+ return $ this -> resolvedPaths [] = [
5059 static ::RESOLVED_TYPE_CLASS ,
5160 $ initiatedClass ,
5261 ];
@@ -57,7 +66,7 @@ public static function resolve(string $javaPath, JavaClass $class = null): array
5766 * @var JavaArchive $value
5867 */
5968 try {
60- return $ resolvedPaths [] = [
69+ return $ this -> resolvedPaths [] = [
6170 static ::RESOLVED_TYPE_CLASS ,
6271 $ value ->getClassByName ($ relativePath ),
6372 ];
@@ -69,9 +78,12 @@ public static function resolve(string $javaPath, JavaClass $class = null): array
6978 * @var ReaderInterface $value
7079 */
7180 try {
72- return $ resolvedPaths [] = [
81+ return $ this -> resolvedPaths [] = [
7382 static ::RESOLVED_TYPE_CLASS ,
74- new JavaClass ($ value ),
83+ new JavaClass (
84+ $ value ,
85+ $ this ->options
86+ ),
7587 ];
7688 } catch (ClassNotFoundException $ e ) {
7789 }
@@ -97,19 +109,18 @@ public static function resolve(string $javaPath, JavaClass $class = null): array
97109 ];
98110 }
99111
100- public static function add ($ valuesOrResourceType = self ::RESOURCE_TYPE_FILE , $ value = null ): void
112+ public function add ($ valuesOrResourceType = self ::RESOURCE_TYPE_FILE , $ value = null ): void
101113 {
102114 if (is_array ($ valuesOrResourceType )) {
103115 foreach ($ valuesOrResourceType as [$ resourceType , $ value ]) {
104- static :: add ($ resourceType , $ value );
116+ $ this -> add ($ resourceType , $ value );
105117 }
106118 return ;
107119 }
108-
109- if (in_array ([$ valuesOrResourceType , $ value ], static ::$ resolves , true )) {
120+ if (in_array ([$ valuesOrResourceType , $ value ], $ this ->resolves , true )) {
110121 return ;
111122 }
112- static :: $ resolves [] = [$ valuesOrResourceType , $ value ];
123+ $ this -> resolves [] = [$ valuesOrResourceType , $ value ];
113124 }
114125
115126 public static function resolveNameByPath ($ path )
0 commit comments