@@ -656,36 +656,42 @@ public function onPostUpdate(Event $event, array $operations = []): void
656
656
*/
657
657
public function executeAutoScripts (Event $ event ): void
658
658
{
659
- $ event ->stopPropagation ();
660
-
661
659
// force reloading scripts as we might have added and removed during this run
662
660
$ json = new JsonFile (Factory::getComposerFile ());
663
661
$ jsonContents = $ json ->read ();
664
662
665
- if (isset ($ jsonContents ['scripts ' ][ScriptEvents::AUTO_SCRIPTS ])) {
666
- /** @var \Narrowspark\Automatic\ScriptExecutor $scriptExecutor */
667
- $ scriptExecutor = $ this ->container ->get (ScriptExecutor::class);
663
+ if (! isset ($ jsonContents ['scripts ' ][ScriptEvents::AUTO_SCRIPTS ])) {
664
+ $ this ->container ->get (IOInterface::class)->write ('No auto-scripts section was found under scripts ' , true , IOInterface::VERBOSE );
668
665
669
- foreach ((array ) $ this ->container ->get (Lock::class)->get (ScriptExecutor::TYPE ) as $ extenders ) {
670
- foreach ($ extenders as $ class => $ path ) {
671
- if (! \class_exists ($ class )) {
672
- require_once $ path ;
673
- }
666
+ return ;
667
+ }
674
668
675
- /** @var \Narrowspark\Automatic\Common\Contract\ScriptExtender $class */
676
- $ reflectionClass = new ReflectionClass ($ class );
669
+ if (\in_array (true , \array_map ('\is_numeric ' , \array_keys ($ jsonContents ['scripts ' ][ScriptEvents::AUTO_SCRIPTS ])), true )) {
670
+ return ;
671
+ }
677
672
678
- if ($ reflectionClass ->isInstantiable () && $ reflectionClass ->hasMethod ('getType ' )) {
679
- $ scriptExecutor ->add ($ class ::getType (), $ class );
680
- }
673
+ $ event ->stopPropagation ();
674
+
675
+ /** @var \Narrowspark\Automatic\ScriptExecutor $scriptExecutor */
676
+ $ scriptExecutor = $ this ->container ->get (ScriptExecutor::class);
677
+
678
+ foreach ((array ) $ this ->container ->get (Lock::class)->get (ScriptExecutor::TYPE ) as $ extenders ) {
679
+ foreach ($ extenders as $ class => $ path ) {
680
+ if (! \class_exists ($ class )) {
681
+ require_once $ path ;
681
682
}
682
- }
683
683
684
- foreach ($ jsonContents ['scripts ' ][ScriptEvents::AUTO_SCRIPTS ] as $ cmd => $ type ) {
685
- $ scriptExecutor ->execute ($ type , $ cmd );
684
+ /** @var \Narrowspark\Automatic\Common\Contract\ScriptExtender $class */
685
+ $ reflectionClass = new ReflectionClass ($ class );
686
+
687
+ if ($ reflectionClass ->isInstantiable () && $ reflectionClass ->hasMethod ('getType ' )) {
688
+ $ scriptExecutor ->add ($ class ::getType (), $ class );
689
+ }
686
690
}
687
- } else {
688
- $ this ->container ->get (IOInterface::class)->write ('No auto-scripts section was found under scripts ' , true , IOInterface::VERBOSE );
691
+ }
692
+
693
+ foreach ($ jsonContents ['scripts ' ][ScriptEvents::AUTO_SCRIPTS ] as $ cmd => $ type ) {
694
+ $ scriptExecutor ->execute ($ type , $ cmd );
689
695
}
690
696
}
691
697
0 commit comments