diff --git a/.gitignore b/.gitignore index 271dc0b..37943be 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ .php-cs-fixer.cache .phpunit.result.cache tests/Fixtures/Saloon/Testing +.phpunit.cache/test-results # environments/configs phpstan.neon diff --git a/phpstan.baseline.neon b/phpstan.baseline.neon index e69de29..94bee2c 100644 --- a/phpstan.baseline.neon +++ b/phpstan.baseline.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^PHPDoc tag \\@mixin contains invalid type Saloon\\\\Laravel\\\\Traits\\\\HasDeprecatedFacadeMethods.$#" + count: 1 + path: src/Facades/Saloon.php diff --git a/src/Facades/Saloon.php b/src/Facades/Saloon.php index 47039e6..bb5c931 100644 --- a/src/Facades/Saloon.php +++ b/src/Facades/Saloon.php @@ -4,28 +4,20 @@ namespace Saloon\Laravel\Facades; -use Saloon\Http\Response; +use Saloon\Http\Faking\MockClient; use Illuminate\Support\Facades\Facade; -use Saloon\Laravel\Http\Faking\MockClient; /** - * @deprecated You should use MockClient::global() instead. This facade will be removed in Saloon v4. - * * @see \Saloon\Laravel\Saloon * - * @method static MockClient fake(array $responses) - * @method static MockClient mockClient() + * @mixin \Saloon\Laravel\Traits\HasDeprecatedFacadeMethods + * + * @method static MockClient fake(array $responses) Alias of MockClient::global() + * @method static MockClient mockClient() Alias of MockClient::global() * @method static void assertSent(string|callable $value) * @method static void assertNotSent(string|callable $value) - * @method static void assertSentJson(string $request, array $data) * @method static void assertNothingSent() * @method static void assertSentCount(int $count) - * @method static void record() - * @method static void stopRecording() - * @method static bool isRecording() - * @method static void recordResponse(Response $response) - * @method static \Saloon\Http\Response[] getRecordedResponses() - * @method static \Saloon\Http\Response getLastRecordedResponse() */ class Saloon extends Facade { diff --git a/src/Saloon.php b/src/Saloon.php index ded0f72..40c9672 100644 --- a/src/Saloon.php +++ b/src/Saloon.php @@ -8,7 +8,7 @@ use Saloon\Http\Faking\MockClient; /** - * @deprecated You should use MockClient::global() instead. This class will be removed in Saloon v4. + * @internal You should use the Saloon facade instead (Saloon\Laravel\Facades\Saloon) */ class Saloon { @@ -95,6 +95,8 @@ public static function assertSentCount(int $count): void /** * Start Saloon recording responses. + * + * @deprecated This method will be removed in Saloon v4. */ public function record(): void { @@ -103,6 +105,8 @@ public function record(): void /** * Stop Saloon recording responses. + * + * @deprecated This method will be removed in Saloon v4. */ public function stopRecording(): void { @@ -111,6 +115,8 @@ public function stopRecording(): void /** * Check if Saloon is recording + * + * @deprecated This method will be removed in Saloon v4. */ public function isRecording(): bool { @@ -119,6 +125,8 @@ public function isRecording(): bool /** * Record a response. + * + * @deprecated This method will be removed in Saloon v4. */ public function recordResponse(Response $response): void { @@ -128,6 +136,8 @@ public function recordResponse(Response $response): void /** * Get all the recorded responses. * + * @deprecated This method will be removed in Saloon v4. + * * @return array<\Saloon\Http\Response> */ public function getRecordedResponses(): array @@ -137,6 +147,8 @@ public function getRecordedResponses(): array /** * Get the last response that Saloon recorded. + * + * @deprecated This method will be removed in Saloon v4. */ public function getLastRecordedResponse(): ?Response { diff --git a/src/Traits/HasDeprecatedFacadeMethods.php b/src/Traits/HasDeprecatedFacadeMethods.php new file mode 100644 index 0000000..6c15b10 --- /dev/null +++ b/src/Traits/HasDeprecatedFacadeMethods.php @@ -0,0 +1,87 @@ + $data + * + * @deprecated This method will be removed in Saloon v4. + */ + public static function assertSentJson(string $request, array $data): void + { + // This trait is only used to present deprecations. + } + + /** + * Start Saloon recording responses. + * + * @deprecated This method will be removed in Saloon v4. + */ + public function record(): void + { + // This trait is only used to present deprecations. + } + + /** + * Stop Saloon recording responses. + * + * @deprecated This method will be removed in Saloon v4. + */ + public function stopRecording(): void + { + // This trait is only used to present deprecations. + } + + /** + * Check if Saloon is recording + * + * @deprecated This method will be removed in Saloon v4. + */ + public function isRecording(): bool + { + // This trait is only used to present deprecations. + } + + /** + * Record a response. + * + * @deprecated This method will be removed in Saloon v4. + */ + public function recordResponse(Response $response): void + { + // This trait is only used to present deprecations. + } + + /** + * Get all the recorded responses. + * + * @deprecated This method will be removed in Saloon v4. + * + * @return array<\Saloon\Http\Response> + */ + public function getRecordedResponses(): array + { + // This trait is only used to present deprecations. + } + + /** + * Get the last response that Saloon recorded. + * + * @deprecated This method will be removed in Saloon v4. + */ + public function getLastRecordedResponse(): ?Response + { + // This trait is only used to present deprecations. + } +}