File tree 4 files changed +31
-1
lines changed
tests/Functional/Transformer/SyntaxErrorInTransformedClass
4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,13 @@ public function __construct() {}
73
73
*/
74
74
protected ?string $ cacheDir = null ;
75
75
76
+ /**
77
+ * The exclude paths. Paths/directories in this array will be excluded
78
+ *
79
+ * @var array
80
+ */
81
+ protected array $ excludePaths = [];
82
+
76
83
/**
77
84
* The cache file mode.
78
85
* <br><b>Default:</b> 0777 & ~{@link umask()}<br>
@@ -187,6 +194,7 @@ protected function preInit(): void
187
194
cacheFileMode: $ this ->cacheFileMode ,
188
195
debug: $ this ->debug ,
189
196
environment: $ this ->environment ,
197
+ excludePaths: $ this ->excludePaths ,
190
198
);
191
199
192
200
// Add the transformers
Original file line number Diff line number Diff line change @@ -107,6 +107,11 @@ public function findFile($namespacedClass): false|string
107
107
108
108
$ filePath = Path::resolve ($ filePath );
109
109
110
+ foreach ($ this ->options ->getExcludePaths () as $ path ) {
111
+ if (str_starts_with ($ filePath , Path::resolve ($ path ))) {
112
+ return $ filePath ;
113
+ }
114
+ }
110
115
111
116
// Query cache state
112
117
$ cacheState = $ this ->cacheStateManager ->queryCacheState ($ filePath );
Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ class Options implements ServiceInterface
32
32
*/
33
33
private string $ cacheDir ;
34
34
35
+ /**
36
+ * The exclude paths.
37
+ *
38
+ * @var array
39
+ */
40
+ private array $ excludePaths ;
41
+
35
42
/**
36
43
* The cache file mode.
37
44
*
@@ -79,6 +86,7 @@ public function setOptions(
79
86
?int $ cacheFileMode ,
80
87
bool $ debug ,
81
88
Environment $ environment ,
89
+ array $ excludePaths = [],
82
90
): void {
83
91
$ composerRef = new ReflectionClass (ClassLoader::class);
84
92
$ composerDir = $ composerRef ->getFileName ();
@@ -89,6 +97,7 @@ public function setOptions(
89
97
$ this ->cacheFileMode = $ cacheFileMode ?? (0777 & ~umask ());
90
98
$ this ->debug = $ debug ;
91
99
$ this ->environment = $ environment ;
100
+ $ this ->excludePaths = $ excludePaths ;
92
101
}
93
102
94
103
// endregion
@@ -121,6 +130,14 @@ public function getCacheDir(): string
121
130
return $ this ->cacheDir ;
122
131
}
123
132
133
+ /**
134
+ * Get the exclude paths.
135
+ */
136
+ public function getExcludePaths (): array
137
+ {
138
+ return $ this ->excludePaths ;
139
+ }
140
+
124
141
/**
125
142
* Get the cache file mode.
126
143
*/
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public function transform(Code $code): void
19
19
$ refClass = $ code ->getReflectionClass ();
20
20
assert ($ refClass ->getName () === Target::class);
21
21
22
- $ className = $ code ->getClassName ();
22
+ $ className = $ code ->getNewSource ();
23
23
assert ($ className === 'SyntaxErrorClass ' );
24
24
}
25
25
}
You can’t perform that action at this time.
0 commit comments