134134 if (!$ constant ->isPublic ()) {
135135 continue ;
136136 }
137- Env::unset ($ constant ->getValue ());
137+ /** @var string */
138+ $ value = $ constant ->getValue ();
139+ Env::unset ($ value );
138140}
139141
140142$ args = [
143145 ...array_slice ($ _SERVER ['argv ' ], 1 ),
144146];
145147
148+ $ online = array_search ('--online ' , $ args );
149+ if ($ online !== false ) {
150+ unset($ args [$ online ]);
151+ $ online = true ;
152+ }
153+
146154/**
147155 * @param AbstractGenerateCommand|string $commandOrFile
148156 */
@@ -158,7 +166,7 @@ function generated($commandOrFile): void
158166 throw new LogicException ('No file generated ' );
159167 }
160168
161- $ generated [] = '/ ' . File::relativeToParent ($ file , Package::path ());
169+ $ generated [] = '/ ' . File::getRelativePath ($ file , Package::path ());
162170}
163171
164172$ status = 0 ;
@@ -170,8 +178,10 @@ function generated($commandOrFile): void
170178 if (is_array ($ class )) {
171179 $ facadeArgs = $ class ;
172180 $ class = array_shift ($ facadeArgs );
173- if (is_array (reset ($ facadeArgs ))) {
174- $ aliases = array_shift ($ facadeArgs );
181+ $ first = reset ($ facadeArgs );
182+ if (is_array ($ first )) {
183+ $ aliases = $ first ;
184+ array_shift ($ facadeArgs );
175185 }
176186 }
177187 $ status |= $ generateFacade (...[...$ args , ...$ facadeArgs , $ class , ...$ aliases , $ facade ]);
@@ -215,10 +225,18 @@ function generated($commandOrFile): void
215225
216226foreach ($ data as $ file => $ uri ) {
217227 $ file = "{$ dir }/tests/data/ {$ file }" ;
218- if (!in_array ('--check ' , $ args )) {
228+ $ exists = file_exists ($ file );
229+ if ($ exists && !$ online ) {
230+ Console::log ('Skipping ' , $ file );
231+ } elseif (!$ exists && in_array ('--check ' , $ args )) {
232+ Console::info ('Would create ' , $ file );
233+ Console::count (Level::ERROR );
234+ $ status |= 1 ;
235+ continue ;
236+ } elseif (!in_array ('--check ' , $ args )) {
219237 Console::log ('Downloading ' , $ uri );
220238 $ content = File::getContents ($ uri );
221- if (!file_exists ( $ file ) || File::getContents ($ file ) !== $ content ) {
239+ if (!$ exists || File::getContents ($ file ) !== $ content ) {
222240 Console::info ('Replacing ' , $ file );
223241 File::createDir (dirname ($ file ));
224242 File::writeContents ($ file , $ content );
@@ -239,7 +257,7 @@ function generated($commandOrFile): void
239257$ file = "$ dir/.gitattributes " ;
240258$ attributes = Regex::grep (
241259 '/(^#| linguist-generated$)/ ' ,
242- Arr::trim (file ($ file )),
260+ Arr::trim (File:: getLines ($ file )),
243261 \PREG_GREP_INVERT
244262);
245263// @phpstan-ignore-next-line
0 commit comments