Browse Source

Resolve PHP 8.4 deprecations (#929)

Mark Walet 4 months ago
parent
commit
fcc0f5ce84

+ 4 - 4
src/Config/Extracting.php

@@ -23,7 +23,7 @@ class Extracting
         bool   $default = false,
         string $in = 'bearer',
         string $name = 'key',
-        string $useValue = null,
+        ?string $useValue = null,
         string $placeholder = '{YOUR_AUTH_KEY}',
         string $extraInfo = ''
     ): array
@@ -48,10 +48,10 @@ class Extracting
         Routes $routes,
         string $defaultGroup = 'Endpoints',
         array $databaseConnectionsToTransact = [],
-        int $fakerSeedForExamples = null,
+        ?int $fakerSeedForExamples = null,
         array $dataSourcesForExampleModels = ['factoryCreate', 'factoryMake', 'databaseFirst'],
-        string $routeMatcher = null,
-        string $fractalSerializer = null,
+        ?string $routeMatcher = null,
+        ?string $fractalSerializer = null,
         array   $auth = [],
         array   $strategies = [],
     ): Extracting

+ 3 - 3
src/Config/Output.php

@@ -6,7 +6,7 @@ class Output
 {
     public static function with(
         string $theme = 'default',
-        string $title = null,
+        ?string $title = null,
         string $description = '',
         array  $baseUrls = [],
         array  $exampleLanguages = ['bash', 'javascript'],
@@ -45,7 +45,7 @@ class Output
     public static function laravelType(
         bool   $addRoutes = true,
         string $docsUrl = '/docs',
-        string $assetsDirectory = null,
+        ?string $assetsDirectory = null,
         array  $middleware = [],
     ): array
     {
@@ -93,7 +93,7 @@ class Output
 
     public static function tryItOut(
         bool   $enabled = true,
-        string $baseUrl = null,
+        ?string $baseUrl = null,
         bool   $useCsrf = false,
         string $csrfUrl = '/sanctum/csrf-cookie',
     ): array

+ 1 - 1
src/Extracting/ApiDetails.php

@@ -26,7 +26,7 @@ class ApiDetails
 
     public function __construct(
         PathConfig          $paths,
-        DocumentationConfig $config = null,
+        ?DocumentationConfig $config = null,
         bool                $preserveUserChanges = true
     ) {
         $this->markdownOutputPath = $paths->intermediateOutputPath(); //.scribe by default

+ 1 - 1
src/Extracting/Extractor.php

@@ -25,7 +25,7 @@ class Extractor
 
     private static ?Route $routeBeingProcessed = null;
 
-    public function __construct(DocumentationConfig $config = null)
+    public function __construct(?DocumentationConfig $config = null)
     {
         // If no config is injected, pull from global
         $this->config = $config ?: new DocumentationConfig(config('scribe'));

+ 1 - 1
src/Extracting/ParamHelpers.php

@@ -103,7 +103,7 @@ trait ParamHelpers
         return $fakeFactoriesByType[$baseType] ?? $fakeFactoriesByType['string'];
     }
 
-    private function getDummyDataGeneratorBetween(string $type, $min, $max = 90, string $fieldName = null): \Closure
+    private function getDummyDataGeneratorBetween(string $type, $min, $max = 90, ?string $fieldName = null): \Closure
     {
         $hints = [
             'name' => $fieldName,

+ 1 - 1
src/Extracting/Shared/UrlParamsNormalizer.php

@@ -145,7 +145,7 @@ class UrlParamsNormalizer
      * @return string|null
      */
     protected static function getRouteKeyForUrlParam(
-        Route $route, string $paramName, array $typeHintedEloquentModels = [], string $default = null
+        Route $route, string $paramName, array $typeHintedEloquentModels = [], ?string $default = null
     ): ?string
     {
         if ($binding = self::getInlineRouteKey($route, $paramName)) {

+ 1 - 1
src/Extracting/Strategies/Metadata/GetFromDocBlocks.php

@@ -36,7 +36,7 @@ class GetFromDocBlocks extends Strategy
         return $metadata;
     }
 
-    protected function getAuthStatusFromDocBlock(DocBlock $methodDocBlock, DocBlock $classDocBlock = null): ?bool
+    protected function getAuthStatusFromDocBlock(DocBlock $methodDocBlock, ?DocBlock $classDocBlock = null): ?bool
     {
         foreach ($methodDocBlock->getTags() as $tag) {
             if (strtolower($tag->getName()) === 'authenticated') {

+ 1 - 1
src/Extracting/Strategies/UrlParameters/GetFromLaravelAPI.php

@@ -186,7 +186,7 @@ class GetFromLaravelAPI extends Strategy
      *
      * @return string|null
      */
-    protected function getNameOfUrlThing(string $url, string $paramName, string $alternateParamName = null): ?string
+    protected function getNameOfUrlThing(string $url, string $paramName, ?string $alternateParamName = null): ?string
     {
         $parts = explode("/", $url);
         if (count($parts) === 1) return null; // URL was "/{thing}"

+ 1 - 1
src/Tools/BladeMarkdownEngine.php

@@ -12,7 +12,7 @@ class BladeMarkdownEngine extends CompilerEngine
 {
     private Parsedown $markdown;
 
-    public function __construct(CompilerInterface $compiler, Filesystem $files = null)
+    public function __construct(CompilerInterface $compiler, ?Filesystem $files = null)
     {
         parent::__construct($compiler, $files ?: new Filesystem);
         $this->markdown = Parsedown::instance();

+ 2 - 2
src/Tools/PathConfig.php

@@ -19,7 +19,7 @@ class PathConfig
         }
     }
 
-    public function outputPath(string $resolvePath = null, string $separator = '/'): string
+    public function outputPath(?string $resolvePath = null, string $separator = '/'): string
     {
         if (is_null($resolvePath)) {
             return $this->configName;
@@ -36,7 +36,7 @@ class PathConfig
     /**
      * The directory where Scribe writes its intermediate output (default is .<config> ie .scribe)
      */
-    public function intermediateOutputPath(string $resolvePath = null, string $separator = '/'): string
+    public function intermediateOutputPath(?string $resolvePath = null, string $separator = '/'): string
     {
         if (is_null($resolvePath)) {
             return $this->scribeDir;

+ 1 - 1
src/Writing/HtmlWriter.php

@@ -22,7 +22,7 @@ class HtmlWriter
     protected string $assetPathPrefix;
     protected MarkdownParser $markdownParser;
 
-    public function __construct(DocumentationConfig $config = null)
+    public function __construct(?DocumentationConfig $config = null)
     {
         $this->config = $config ?: new DocumentationConfig(config('scribe', []));
         $this->markdownParser = new MarkdownParser();

+ 3 - 3
src/Writing/OpenAPISpecWriter.php

@@ -22,7 +22,7 @@ class OpenAPISpecWriter
 
     private DocumentationConfig $config;
 
-    public function __construct(DocumentationConfig $config = null)
+    public function __construct(?DocumentationConfig $config = null)
     {
         $this->config = $config ?: new DocumentationConfig(config('scribe', []));
     }
@@ -400,7 +400,7 @@ class OpenAPISpecWriter
                             ],
                             'example' => $decoded,
                         ],
-                    ], 
+                    ],
                 ];
 
             case 'object':
@@ -661,7 +661,7 @@ class OpenAPISpecWriter
 
         return $required;
     }
-  
+
     /*
      * Set the description for the schema. If the field has a description, it is set in the schema.
      */

+ 1 - 1
src/Writing/PostmanCollectionWriter.php

@@ -21,7 +21,7 @@ class PostmanCollectionWriter
 
     protected string $baseUrl;
 
-    public function __construct(DocumentationConfig $config = null)
+    public function __construct(?DocumentationConfig $config = null)
     {
         $this->config = $config ?: new DocumentationConfig(config('scribe', []));
         $this->baseUrl = $this->config->get('base_url') ?: config('app.url');