shalvah 5 년 전
부모
커밋
93b201418f
3개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 2
      resources/views/partials/example-requests/php.blade.php
  2. 2 2
      src/Extracting/ValidationRuleDescriptionParser.php
  3. 4 2
      src/Tools/WritingUtils.php

+ 2 - 2
resources/views/partials/example-requests/php.blade.php

@@ -6,7 +6,7 @@ $response = $client->{{ strtolower($route['methods'][0]) }}(
     '{{ rtrim($baseUrl, '/') . '/' . ltrim($route['boundUri'], '/') }}',
     [
 @if(!empty($route['headers']))
-        'headers' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpArray($route['headers'], 8) !!},
+        'headers' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpValue($route['headers'], 8) !!},
 @endif
 @if(!empty($route['cleanQueryParameters']))
         'query' => {!! \Knuckles\Scribe\Tools\WritingUtils::printQueryParamsAsKeyValue($route['cleanQueryParameters'], "'", "=>", 12, "[]", 8) !!},
@@ -29,7 +29,7 @@ $response = $client->{{ strtolower($route['methods'][0]) }}(
 @endforeach
         ],
 @elseif(!empty($route['cleanBodyParameters']))
-        'json' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpArray($route['cleanBodyParameters'], 8) !!},
+        'json' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpValue($route['cleanBodyParameters'], 8) !!},
 @endif
     ]
 );

+ 2 - 2
src/Extracting/ValidationRuleDescriptionParser.php

@@ -25,14 +25,14 @@ class ValidationRuleDescriptionParser
         return $instance->makeDescription($type);
     }
 
-    protected function makeDescription($type = 'string'): string
+    protected function makeDescription($baseType = 'string'): string
     {
         $description = trans("validation.{$this->rule}");
         // For rules that can apply to multiple types (eg 'max' rule), Laravel returns an array of possible messages
         // 'numeric' => 'The :attribute must not be greater than :max'
         // 'file' => 'The :attribute must have a size less than :max kilobytes'
         if (is_array($description)) {
-            $description = $description[$type];
+            $description = $description[$baseType];
         }
 
         // Convert messages from failure type ("The value is not a valid date.") to info ("The value must be a valid date.")

+ 4 - 2
src/Tools/WritingUtils.php

@@ -17,14 +17,16 @@ class WritingUtils
     ];
 
     /**
-     * @param array $value
+     * Print a value as valid PHP, handling arrays and proper indentation.
+     *
+     * @param $value
      * @param int $indentationLevel
      *
      * @return string
      * @throws \Symfony\Component\VarExporter\Exception\ExceptionInterface
      *
      */
-    public static function printPhpArray($value, int $indentationLevel = 0): string
+    public static function printPhpValue($value, int $indentationLevel = 0): string
     {
         $output = VarExporter::export($value);
         // Padding with x spaces so they align