فهرست منبع

Rename hook from BeforeGenerateCommandStarts to bootstrap

Peter Ragheb 2 سال پیش
والد
کامیت
4926dab1ae
4فایلهای تغییر یافته به همراه10 افزوده شده و 15 حذف شده
  1. 4 9
      src/Commands/GenerateDocumentation.php
  2. 2 2
      src/Scribe.php
  3. 1 1
      src/Tools/Globals.php
  4. 3 3
      tests/GenerateDocumentation/BehavioursTest.php

+ 4 - 9
src/Commands/GenerateDocumentation.php

@@ -86,16 +86,11 @@ class GenerateDocumentation extends Command
         return $this->docConfig;
     }
 
-    public function setDocConfig(DocumentationConfig $config)
+    protected function runBootstrapHook()
     {
-        $this->docConfig = $config;
-    }
-
-    protected function runBeforeGenerateCommandStartsHook()
-    {
-        if (is_callable(Globals::$__beforeGenerateCommandStarts)) {
+        if (is_callable(Globals::$__bootstrap)) {
             c::info("Running `beforeGenerating()` hook...");
-            call_user_func_array(Globals::$__beforeGenerateCommandStarts, [$this]);
+            call_user_func_array(Globals::$__bootstrap, [$this]);
         }
     }
 
@@ -124,7 +119,7 @@ class GenerateDocumentation extends Command
             throw new \InvalidArgumentException("Can't use --force and --no-extraction together.");
         }
 
-        $this->runBeforeGenerateCommandStartsHook();
+        $this->runBootstrapHook();
     }
 
     protected function mergeUserDefinedEndpoints(array $groupedEndpoints, array $userDefinedEndpoints): array

+ 2 - 2
src/Scribe.php

@@ -27,9 +27,9 @@ class Scribe
      *
      * @param callable(GenerateDocumentation): mixed $callable
      */
-    public static function beforeGenerateCommandStarts(callable $callable)
+    public static function bootstrap(callable $callable)
     {
-        Globals::$__beforeGenerateCommandStarts = $callable;
+        Globals::$__bootstrap = $callable;
     }
 
     /**

+ 1 - 1
src/Tools/Globals.php

@@ -12,7 +12,7 @@ class Globals
 
     public static $__beforeResponseCall;
 
-    public static $__beforeGenerateCommandStarts;
+    public static $__bootstrap;
 
     public static $__afterGenerating;
 

+ 3 - 3
tests/GenerateDocumentation/BehavioursTest.php

@@ -127,11 +127,11 @@ class BehavioursTest extends BaseLaravelTest
     }
 
     /** @test */
-    public function calls_beforeGenerating_hook()
+    public function calls_bootstrap_hook()
     {
         $commandInstance = null;
 
-        Scribe::beforeGenerateCommandStarts(function (GenerateDocumentation $command) use (&$commandInstance){
+        Scribe::bootstrap(function (GenerateDocumentation $command) use (&$commandInstance){
             $commandInstance = $command;
         });
 
@@ -141,7 +141,7 @@ class BehavioursTest extends BaseLaravelTest
 
         $this->assertTrue($commandInstance instanceof GenerateDocumentation);
 
-        Scribe::beforeGenerateCommandStarts(fn() => null);
+        Scribe::bootstrap(fn() => null);
     }
 
     /** @test */