@@ -43,7 +43,14 @@ trait ColocatedMappingDriver
43
43
*/
44
44
protected array $ excludePaths = [];
45
45
46
- /** The file extension of mapping documents. */
46
+ /** The regex used to match mapping files. */
47
+ protected string $ fileRegex = '/^.+\.php$/i ' ;
48
+
49
+ /**
50
+ * The file extension of mapping documents.
51
+ *
52
+ * @deprecated Use {@see $fileRegex} instead.
53
+ */
47
54
protected string $ fileExtension = '.php ' ;
48
55
49
56
/**
@@ -94,16 +101,38 @@ public function getExcludePaths(): array
94
101
return $ this ->excludePaths ;
95
102
}
96
103
97
- /** Gets the file extension used to look for mapping files under. */
104
+ /** Gets the file regex used to look for mapping files under. */
105
+ public function getFileRegex (): string
106
+ {
107
+ return $ this ->fileRegex ;
108
+ }
109
+
110
+ /** Sets the file regex used to look for mapping files under. */
111
+ public function setFileRegex (string $ fileRegex ): void
112
+ {
113
+ $ this ->fileRegex = $ fileRegex ;
114
+ $ this ->fileExtension = '' ;
115
+ }
116
+
117
+ /**
118
+ * Gets the file extension used to look for mapping files under.
119
+ *
120
+ * @deprecated Use {@see getFileRegex()} instead.
121
+ */
98
122
public function getFileExtension (): string
99
123
{
100
124
return $ this ->fileExtension ;
101
125
}
102
126
103
- /** Sets the file extension used to look for mapping files under. */
127
+ /**
128
+ * Sets the file extension used to look for mapping files under.
129
+ *
130
+ * @deprecated Use {@see setFileRegex()} instead.
131
+ */
104
132
public function setFileExtension (string $ fileExtension ): void
105
133
{
106
134
$ this ->fileExtension = $ fileExtension ;
135
+ $ this ->fileRegex = '/^.+ ' . preg_quote ($ fileExtension ) . '$/i ' ;
107
136
}
108
137
109
138
/**
@@ -145,7 +174,7 @@ public function getAllClassNames(): array
145
174
new RecursiveDirectoryIterator ($ path , FilesystemIterator::SKIP_DOTS ),
146
175
RecursiveIteratorIterator::LEAVES_ONLY ,
147
176
),
148
- ' /^.+ ' . preg_quote ( $ this ->fileExtension ) . ' $/i ' ,
177
+ $ this ->fileRegex ,
149
178
RecursiveRegexIterator::GET_MATCH ,
150
179
);
151
180
0 commit comments