@@ -159,20 +159,43 @@ protected function createComponent(): bool
159
159
@rename ( $ base_old_filename . '.php ' , $ base_new_filename . '.php ' );
160
160
@rename ( $ base_old_filename . '.yaml ' , $ base_new_filename . '.yaml ' );
161
161
162
- $ regex_array = [
163
- $ new_theme . '.php ' => [
164
- ['/class ' . $ this ->inflector ::camelize ($ current_theme ) . ' extends/i ' ],
165
- ['class ' . $ this ->inflector ::camelize ($ name ) . ' extends ' ]
166
- ],
167
- 'blueprints.yaml ' => [
168
- ['/ ' .$ this ->inflector ::camelize ($ current_theme ).'/ ' , '/ ' .$ this ->inflector ::hyphenize ($ current_theme ).'/ ' , '/ ' .$ this ->inflector ::titleize ($ current_theme ).'/ ' , '/ ' .$ this ->inflector ::underscorize ($ current_theme ).'/ ' ],
169
- [$ this ->inflector ::camelize ($ name ), $ this ->inflector ::hyphenize ($ name ),$ this ->inflector ::titleize ($ name ), $ this ->inflector ::underscorize ($ name )]
170
- ],
171
- 'README.md ' => [
172
- ['/ ' .$ this ->inflector ::camelize ($ current_theme ).'/ ' , '/ ' .$ this ->inflector ::hyphenize ($ current_theme ).'/ ' , '/ ' .$ this ->inflector ::titleize ($ current_theme ).'/ ' , '/ ' .$ this ->inflector ::underscorize ($ current_theme ).'/ ' ],
173
- [$ this ->inflector ::camelize ($ name ), $ this ->inflector ::hyphenize ($ name ),$ this ->inflector ::titleize ($ name ), $ this ->inflector ::underscorize ($ name )]
174
- ]
162
+ $ camelized_current = $ this ->inflector ::camelize ($ current_theme );
163
+ $ camelized_new = $ this ->inflector ::camelize ($ name );
164
+
165
+ $ hyphenized_current = $ this ->inflector ::hyphenize ($ current_theme );
166
+ $ hyphenized_new = $ this ->inflector ::hyphenize ($ name );
167
+
168
+ $ titleized_current = $ this ->inflector ::titleize ($ current_theme );
169
+ $ titleized_new = $ this ->inflector ::titleize ($ name );
170
+
171
+ $ underscoreized_current = $ this ->inflector ::underscorize ($ current_theme );
172
+ $ underscoreized_new = $ this ->inflector ::underscorize ($ name );
173
+
174
+ $ variations_regex = [
175
+ ["/ $ camelized_current/ " , "/ $ hyphenized_current/ " ],
176
+ [$ camelized_new , $ hyphenized_new ]
177
+ ];
175
178
179
+ if (!in_array ("/ $ titleized_current/ " , array_values ($ variations_regex [0 ]))) {
180
+ $ current_regex = $ variations_regex [0 ];
181
+ $ new_regex = $ variations_regex [1 ];
182
+ $ current_regex [] = "/ $ titleized_current/ " ;
183
+ $ new_regex [] = $ titleized_new ;
184
+ $ variations_regex = [$ current_regex , $ new_regex ];
185
+ }
186
+
187
+ if (!in_array ("/ $ underscoreized_current/ " , array_values ($ variations_regex [0 ]))) {
188
+ $ current_regex = $ variations_regex [0 ];
189
+ $ new_regex = $ variations_regex [1 ];
190
+ $ current_regex [] = "/ $ underscoreized_current/ " ;
191
+ $ new_regex [] = $ underscoreized_new ;
192
+ $ variations_regex = [$ current_regex , $ new_regex ];
193
+ }
194
+
195
+ $ regex_array = [
196
+ $ new_theme . '.php ' => $ variations_regex ,
197
+ 'blueprints.yaml ' => $ variations_regex ,
198
+ 'README.md ' => $ variations_regex ,
176
199
];
177
200
178
201
foreach ($ regex_array as $ filename => $ data ) {
0 commit comments