Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix | Remove Saloon::fake() deprecations but deprecate methods #60

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.php-cs-fixer.cache
.phpunit.result.cache
tests/Fixtures/Saloon/Testing
.phpunit.cache/test-results

# environments/configs
phpstan.neon
6 changes: 6 additions & 0 deletions phpstan.baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^PHPDoc tag \\@mixin contains invalid type Saloon\\\\Laravel\\\\Traits\\\\HasDeprecatedFacadeMethods.$#"
count: 1
path: src/Facades/Saloon.php
18 changes: 5 additions & 13 deletions src/Facades/Saloon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
14 changes: 13 additions & 1 deletion src/Saloon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
Expand All @@ -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
{
Expand Down
87 changes: 87 additions & 0 deletions src/Traits/HasDeprecatedFacadeMethods.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

declare(strict_types=1);

namespace Saloon\Laravel\Traits;

use Saloon\Http\Response;

/**
* @internal This trait is only used to present deprecations.
*/
trait HasDeprecatedFacadeMethods
{
/**
* Assert JSON response data was received
*
* @param array<string, mixed> $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.
}
}
Loading