Shalvah 2 years ago
parent
commit
d2433334ec

+ 1 - 1
src/Extracting/InstantiatesExampleModels.php

@@ -24,7 +24,7 @@ trait InstantiatesExampleModels
         array   $relations = [], ?ReflectionFunctionAbstract $transformationMethod = null
     )
     {
-        // Early return if JsonResource working with empty resource, there won't have an example model
+        // If the API Resource uses an empty resource, there won't be an example model
         if($type == null && $transformationMethod == null)
             return null;
 

+ 2 - 2
src/Extracting/Shared/ApiResourceResponseTools.php

@@ -54,8 +54,8 @@ class ApiResourceResponseTools
         array  $paginationStrategy = [], array $additionalData = []
     ): JsonResource
     {
-        // If the JsonResource is working with empty $resource (such like an empty array), the $modelInstantiator will be null
-        // If $modelInstantiator is null set to an empty array as default
+        // If the API Resource uses an empty $resource (e.g. an empty array), the $modelInstantiator will be null
+        // See https://github.com/knuckleswtf/scribe/issues/652
         $modelInstance = $modelInstantiator() ?? [];
         try {
             $resource = new $apiResourceClass($modelInstance);