22
33namespace Moox \Build \Console \Commands ;
44
5+ use RuntimeException ;
6+ use Throwable ;
7+ use ReflectionClass ;
8+ use ReflectionMethod ;
9+ use Exception ;
10+ use RecursiveIteratorIterator ;
11+ use RecursiveDirectoryIterator ;
12+ use finfo ;
513use Illuminate \Console \Command ;
614use Moox \Core \Console \Traits \ArtLeft ;
715
@@ -187,7 +195,7 @@ protected function askForPackageType(): void
187195 $ selectedTemplate = $ templates [$ type ] ?? null ;
188196
189197 if (! $ selectedTemplate ) {
190- throw new \ RuntimeException ('Selected template not found ' );
198+ throw new RuntimeException ('Selected template not found ' );
191199 }
192200
193201 $ this ->subject = $ selectedTemplate ['subject ' ];
@@ -409,7 +417,7 @@ protected function getServiceProviderFromPackage(string $packageName): ?object
409417 }
410418
411419 return new $ fullyQualifiedClassName (app ());
412- } catch (\ Throwable $ e ) {
420+ } catch (Throwable $ e ) {
413421 $ this ->line ('Debug: Error loading provider: ' .$ e ->getMessage ());
414422 }
415423 }
@@ -432,10 +440,10 @@ protected function getTemplateRenameFromProvider(object $provider): array
432440
433441 // If we couldn't get the config through methods, try reflection
434442 try {
435- $ reflection = new \ ReflectionClass ($ provider );
443+ $ reflection = new ReflectionClass ($ provider );
436444
437445 // Try to find a method that returns the templateRename configuration
438- $ methods = $ reflection ->getMethods (\ ReflectionMethod::IS_PUBLIC );
446+ $ methods = $ reflection ->getMethods (ReflectionMethod::IS_PUBLIC );
439447 foreach ($ methods as $ method ) {
440448 $ methodName = $ method ->getName ();
441449 if (strpos ($ methodName , 'getTemplateRename ' ) === 0 ) {
@@ -450,7 +458,7 @@ protected function getTemplateRenameFromProvider(object $provider): array
450458 $ mooxPackage = $ mooxPackageProperty ->getValue ($ provider );
451459
452460 if ($ mooxPackage ) {
453- $ mooxPackageReflection = new \ ReflectionClass ($ mooxPackage );
461+ $ mooxPackageReflection = new ReflectionClass ($ mooxPackage );
454462 if ($ mooxPackageReflection ->hasProperty ('templateRename ' )) {
455463 $ templateRenameProperty = $ mooxPackageReflection ->getProperty ('templateRename ' );
456464 $ templateRenameProperty ->setAccessible (true );
@@ -459,7 +467,7 @@ protected function getTemplateRenameFromProvider(object $provider): array
459467 }
460468 }
461469 }
462- } catch (\ Throwable $ e ) {
470+ } catch (Throwable $ e ) {
463471 $ this ->line ('Debug: Reflection error: ' .$ e ->getMessage ());
464472 }
465473
@@ -480,10 +488,10 @@ protected function getTemplateReplacementsFromProvider(object $provider): array
480488
481489 // If we couldn't get the config through methods, try reflection
482490 try {
483- $ reflection = new \ ReflectionClass ($ provider );
491+ $ reflection = new ReflectionClass ($ provider );
484492
485493 // Try to find a method that returns the templateReplace configuration
486- $ methods = $ reflection ->getMethods (\ ReflectionMethod::IS_PUBLIC );
494+ $ methods = $ reflection ->getMethods (ReflectionMethod::IS_PUBLIC );
487495 foreach ($ methods as $ method ) {
488496 $ methodName = $ method ->getName ();
489497 if (strpos ($ methodName , 'getTemplateReplace ' ) === 0 ) {
@@ -498,7 +506,7 @@ protected function getTemplateReplacementsFromProvider(object $provider): array
498506 $ mooxPackage = $ mooxPackageProperty ->getValue ($ provider );
499507
500508 if ($ mooxPackage ) {
501- $ mooxPackageReflection = new \ ReflectionClass ($ mooxPackage );
509+ $ mooxPackageReflection = new ReflectionClass ($ mooxPackage );
502510 if ($ mooxPackageReflection ->hasProperty ('templateReplace ' )) {
503511 $ templateReplaceProperty = $ mooxPackageReflection ->getProperty ('templateReplace ' );
504512 $ templateReplaceProperty ->setAccessible (true );
@@ -507,7 +515,7 @@ protected function getTemplateReplacementsFromProvider(object $provider): array
507515 }
508516 }
509517 }
510- } catch (\ Throwable $ e ) {
518+ } catch (Throwable $ e ) {
511519 $ this ->line ('Debug: Reflection error: ' .$ e ->getMessage ());
512520 }
513521
@@ -528,10 +536,10 @@ protected function getTemplateSectionReplacementsFromProvider(object $provider):
528536
529537 // If we couldn't get the config through methods, try reflection
530538 try {
531- $ reflection = new \ ReflectionClass ($ provider );
539+ $ reflection = new ReflectionClass ($ provider );
532540
533541 // Try to find a method that returns the templateSectionReplace configuration
534- $ methods = $ reflection ->getMethods (\ ReflectionMethod::IS_PUBLIC );
542+ $ methods = $ reflection ->getMethods (ReflectionMethod::IS_PUBLIC );
535543 foreach ($ methods as $ method ) {
536544 $ methodName = $ method ->getName ();
537545 if (strpos ($ methodName , 'getTemplateSectionReplace ' ) === 0 ) {
@@ -546,7 +554,7 @@ protected function getTemplateSectionReplacementsFromProvider(object $provider):
546554 $ mooxPackage = $ mooxPackageProperty ->getValue ($ provider );
547555
548556 if ($ mooxPackage ) {
549- $ mooxPackageReflection = new \ ReflectionClass ($ mooxPackage );
557+ $ mooxPackageReflection = new ReflectionClass ($ mooxPackage );
550558 if ($ mooxPackageReflection ->hasProperty ('templateSectionReplace ' )) {
551559 $ templateSectionReplaceProperty = $ mooxPackageReflection ->getProperty ('templateSectionReplace ' );
552560 $ templateSectionReplaceProperty ->setAccessible (true );
@@ -555,7 +563,7 @@ protected function getTemplateSectionReplacementsFromProvider(object $provider):
555563 }
556564 }
557565 }
558- } catch (\ Throwable $ e ) {
566+ } catch (Throwable $ e ) {
559567 $ this ->line ('Debug: Reflection error: ' .$ e ->getMessage ());
560568 }
561569
@@ -649,7 +657,7 @@ protected function copyDirectory(string $source, string $destination): bool
649657 closedir ($ directory );
650658
651659 return true ;
652- } catch (\ Exception $ e ) {
660+ } catch (Exception $ e ) {
653661 error (' Error copying directory: ' .$ e ->getMessage ().' ' .$ this ->emojiNoSee );
654662
655663 return false ;
@@ -807,9 +815,9 @@ protected function findAllFiles(string $directory): array
807815 {
808816 $ files = [];
809817
810- $ iterator = new \ RecursiveIteratorIterator (
811- new \ RecursiveDirectoryIterator ($ directory , \ RecursiveDirectoryIterator::SKIP_DOTS ),
812- \ RecursiveIteratorIterator::SELF_FIRST
818+ $ iterator = new RecursiveIteratorIterator (
819+ new RecursiveDirectoryIterator ($ directory , RecursiveDirectoryIterator::SKIP_DOTS ),
820+ RecursiveIteratorIterator::SELF_FIRST
813821 );
814822
815823 foreach ($ iterator as $ file ) {
@@ -832,7 +840,7 @@ protected function isBinaryFile(string $file): bool
832840 }
833841
834842 // Check file content
835- $ finfo = new \ finfo (FILEINFO_MIME );
843+ $ finfo = new finfo (FILEINFO_MIME );
836844 $ mime = $ finfo ->file ($ file );
837845
838846 return strpos ($ mime , 'text/ ' ) !== 0 && strpos ($ mime , 'application/json ' ) !== 0 ;
0 commit comments