diff --git a/src/Abstracts/Transformers/Transformer.php b/src/Abstracts/Transformers/Transformer.php index d7ac7e622..1e7e070fe 100644 --- a/src/Abstracts/Transformers/Transformer.php +++ b/src/Abstracts/Transformers/Transformer.php @@ -19,7 +19,7 @@ public function nullableItem($data, $transformer, $resourceKey = null): Primitiv return $this->primitive(null); } - return $this->item($data, $transformer, $resourceKey = null); + return $this->item($data, $transformer, $resourceKey); } public function item($data, $transformer, $resourceKey = null): Item diff --git a/src/Traits/CanEagerLoadTrait.php b/src/Traits/CanEagerLoadTrait.php index a4f151403..a0de3c225 100644 --- a/src/Traits/CanEagerLoadTrait.php +++ b/src/Traits/CanEagerLoadTrait.php @@ -8,6 +8,9 @@ use Illuminate\Support\Facades\Request; use Illuminate\Support\Str; +/** + * @internal + */ trait CanEagerLoadTrait { /** diff --git a/src/Traits/HasResourceKeyTrait.php b/src/Traits/HasResourceKeyTrait.php index b39caa7d2..bee6f49ce 100644 --- a/src/Traits/HasResourceKeyTrait.php +++ b/src/Traits/HasResourceKeyTrait.php @@ -9,11 +9,14 @@ trait HasResourceKeyTrait /** * @var string|null */ - #[Deprecated(reason: 'Override the getResourceKey method in the respective model class instead of using the $resourceKey property.')] + #[Deprecated(reason: 'Override the getResourceKey method in the respective model class instead of using the $resourceKey property')] protected $resourceKey; /** - * Returns the type for JSON API Serializer. Can be overwritten with the protected $resourceKey in respective model class. + * Returns the type for JSON API Serializer. + * + * If the $resourceKey property is set, it will be used as the resource key. + * Otherwise, the class name will be used. */ public function getResourceKey(): string { diff --git a/src/Traits/ResponseTrait.php b/src/Traits/ResponseTrait.php index 9b031c8e3..06e7b7933 100644 --- a/src/Traits/ResponseTrait.php +++ b/src/Traits/ResponseTrait.php @@ -13,6 +13,10 @@ use JetBrains\PhpStorm\Deprecated; use Spatie\Fractal\Facades\Fractal; +#[Deprecated( + reason: 'All methods in this trait are deprecated and will be removed in the next major release.', + replacement: 'Use the Response facade instead.', +)] trait ResponseTrait { protected array $metaData = []; @@ -21,8 +25,8 @@ trait ResponseTrait * @throws InvalidTransformerException */ #[Deprecated( - reason: 'This method is the cause of many bugs and its functionality is already covered by the Fractal package.', - replacement: '\Spatie\Fractal\Facades\Fractal::create(%parameter0%,%parameter1%)->parseIncludes(%parameter2%)->addMeta(%parameter3%)->toArray();', + reason: 'This method is the cause of many bugs and its functionality is already covered by the Response facade. Use the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%,%parameter1%)->parseIncludes(%parameter2%)->addMeta(%parameter3%)->toArray();', )] public function transform( $data, @@ -126,8 +130,8 @@ private function filterResponse(array $responseArray, array $filters): array } #[Deprecated( - reason: 'Its functionality is already covered by the Fractal package. Use the addMeta() method on the Fractal instance instead.', - replacement: '\Spatie\Fractal\Facades\Fractal::create()->addMeta(%parameter0%)->toArray();', + reason: 'Its functionality is already covered by the Response facade. Use the addMeta method from the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom()->addMeta(%parameter0%)->toArray();', )] public function withMeta($data): self { @@ -136,19 +140,29 @@ public function withMeta($data): self return $this; } + #[Deprecated( + reason: 'Its functionality is already covered by the Response facade. Use the toJson method from the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->toJson();', + )] public function json($data, $status = 200, array $headers = [], $options = 0): JsonResponse { return new JsonResponse($data, $status, $headers, $options); } + #[Deprecated( + reason: 'Its functionality is already covered by the Response facade. Use the created method from the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->created();', + )] public function created($data = null, $status = 201, array $headers = [], $options = 0): JsonResponse { return new JsonResponse($data, $status, $headers, $options); } - /** - * @throws \ReflectionException - */ + + #[Deprecated( + reason: 'Use the noContent method from the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->noContent();', + )] public function deleted(Model|null $deletedModel = null): JsonResponse { if (!$deletedModel) { @@ -163,11 +177,19 @@ public function deleted(Model|null $deletedModel = null): JsonResponse ]); } + #[Deprecated( + reason: 'Its functionality is already covered by the Response facade. Use the accepted method from the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom(%parameter0%)->accepted();', + )] public function accepted($data = null, $status = 202, array $headers = [], $options = 0): JsonResponse { return new JsonResponse($data, $status, $headers, $options); } + #[Deprecated( + reason: 'Its functionality is already covered by the Response facade. Use the noContent method from the Response facade instead.', + replacement: '\Apiato\Core\Facades\Response::createFrom()->noContent();', + )] public function noContent($status = 204): JsonResponse { return new JsonResponse(null, $status);