Repository: laravel/framework
File: src/Illuminate/Collections/Traits/TransformsToResourceCollection.php (PHP)

Code before:
        $resourceClasses = $className::guessResourceName();

        foreach ($resourceClasses as $resourceClass) {
            $resourceCollection = $resourceClass.'Collection';

            if (is_string($resourceCollection) && class_exists($resourceCollection)) {
                return new $resourceCollection($this);
            }
        }

        foreach ($resourceClasses as $resourceClass) {
            if (is_string($resourceClass) && class_exists($resourceClass)) {
                return $resourceClass::collection($this);
            }
        }

        throw new LogicException(sprintf('Failed to find resource class for model [%s].', $className));
    }

    /**
     * Get the resource class from the class attribute.
     *
     * @param  class-string<*>  $class
     * @return class-string<*>|null
     */
    protected function resolveResourceFromAttribute(string $class): ?string
    {
        if (! class_exists($class)) {
            return null;
        }

        $attributes = (new ReflectionClass($class))->getAttributes(UseResource::class);

        return $attributes !== []
            ? $attributes[0]->newInstance()->class
            : null;
    }

    /**
     * Get the resource collection class from the class attribute.
     *
     * @param  class-string<*>  $class
     * @return class-string<*>|null
     */
    protected function resolveResourceCollectionFromAttribute(string $class): ?string
    {
        if (! class_exists($class)) {
            return null;
        }

        $attributes = (new ReflectionClass($class))->getAttributes(UseResourceCollection::class);

Review comment (suggestion):
While this is correct for the `@param $class` as this is `use`d in `\Illuminate\Support\Collection`, this is not correct for the `@return`:
```suggestion
     * @return class-string<\Illuminate\Http\Resources\Json\JsonResource>|null
```

Code after:
        }

        $resourceClasses = $className::guessResourceName();

        foreach ($resourceClasses as $resourceClass) {
            $resourceCollection = $resourceClass.'Collection';

            if (is_string($resourceCollection) && class_exists($resourceCollection)) {
                return new $resourceCollection($this);
            }
        }

        foreach ($resourceClasses as $resourceClass) {
            if (is_string($resourceClass) && class_exists($resourceClass)) {
                return $resourceClass::collection($this);
            }
        }

        throw new LogicException(sprintf('Failed to find resource class for model [%s].', $className));
    }

    /**
     * Get the resource class from the class attribute.
     *
     * @param  class-string<\Illuminate\Http\Resources\Json\JsonResource>  $class
     * @return class-string<*>|null
     */
    protected function resolveResourceFromAttribute(string $class): ?string
    {
        if (! class_exists($class)) {
            return null;
        }

        $attributes = (new ReflectionClass($class))->getAttributes(UseResource::class);

        return $attributes !== []
            ? $attributes[0]->newInstance()->class
            : null;
    }

    /**
     * Get the resource collection class from the class attribute.
     *
     * @param  class-string<\Illuminate\Http\Resources\Json\ResourceCollection>  $class
     * @return class-string<*>|null
     */
    protected function resolveResourceCollectionFromAttribute(string $class): ?string
    {
        if (! class_exists($class)) {
            return null;
        }