Skip to content

Commit

Permalink
cs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed Jul 5, 2019
1 parent 6d29e27 commit 5deb06f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -10,7 +10,7 @@
"php": "^7.1.3",
"ext-json": "*",
"psr/log": "^1.0",
"symfony/http-client": "^4.3",
"symfony/http-client": "^4.3"
},
"require-dev": {
"symfony/form": "^2.1|^3.0|^4.0",
Expand Down
11 changes: 7 additions & 4 deletions src/SymfonyCorp/Connect/Api/Api.php
Expand Up @@ -12,12 +12,12 @@
namespace SymfonyCorp\Connect\Api;

use Buzz\Browser;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Contracts\HttpClient\ResponseInterface;
use SymfonyCorp\Connect\Api\Parser\ParserInterface;
use SymfonyCorp\Connect\Api\Parser\VndComSymfonyConnectXmlParser as Parser;
Expand All @@ -40,13 +40,16 @@ class Api
private $endpoint;
private $accessToken;

/**
* @param HttpClientInterface|null $httpClient
*/
public function __construct($endpoint = null, $httpClient = null, ParserInterface $parser = null, LoggerInterface $logger = null)
{
if ($httpClient instanceof Browser) {
@trigger_error(sprintf('Passing a "%s" to "%s()" is deprecated since symfonycorp/connect 5.1, use "%s" instead.', Browser::class, __METHOD__, HttpClientInterface::class), E_USER_DEPRECATED);
$httpClient = null;
} elseif ($httpClient && !$httpClient instanceof HttpClientInterface) {
throw new \InvalidArgumentException(sprintf('Argument 2 passed to %s() must be an instance of %s or null, %s given', __METHOD__, HttpClientInterface::class, is_object($httpClient) ? get_class($httpClient) : gettype($httpClient)));
} elseif (null !== $httpClient && !$httpClient instanceof HttpClientInterface) {
throw new \TypeError(sprintf('Argument 2 passed to %s() must be an instance of %s or null, %s given', __METHOD__, HttpClientInterface::class, \is_object($httpClient) ? \get_class($httpClient) : \gettype($httpClient)));
}

$this->httpClient = $httpClient ?: HttpClient::create();
Expand Down
14 changes: 10 additions & 4 deletions src/SymfonyCorp/Connect/OAuthConsumer.php
Expand Up @@ -13,8 +13,8 @@

use Buzz\Browser;
use Buzz\Client\Curl;
use Psr\Log\NullLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand Down Expand Up @@ -42,13 +42,16 @@ class OAuthConsumer
'authorize' => '/oauth/authorize',
];

/**
* @param HttpClientInterface|null $httpClient
*/
public function __construct($appId, $appSecret, $scope, $endpoint = null, $httpClient = null, LoggerInterface $logger = null)
{
if ($httpClient instanceof Browser) {
@trigger_error(sprintf('Passing a "%s" to "%s()" is deprecated since symfonycorp/connect 5.1, use "%s" instead.', Browser::class, __METHOD__, HttpClientInterface::class), E_USER_DEPRECATED);
$httpClient = null;
} elseif ($httpClient && !$httpClient instanceof HttpClientInterface) {
throw new \InvalidArgumentException(sprintf('Argument 5 passed to %s() must be an instance of %s or null, %s given', __METHOD__, HttpClientInterface::class, is_object($httpClient) ? get_class($httpClient) : gettype($httpClient)));
} elseif (null !== $httpClient && !$httpClient instanceof HttpClientInterface) {
throw new \TypeError(sprintf('Argument 5 passed to %s() must be an instance of %s or null, %s given', __METHOD__, HttpClientInterface::class, \is_object($httpClient) ? \get_class($httpClient) : \gettype($httpClient)));
}

$this->httpClient = $httpClient ?: HttpClient::create();
Expand Down Expand Up @@ -164,9 +167,12 @@ public function getEndpoint()
return $this->endpoint;
}

/**
* @deprecated since symfonycorp/connect 5.1
*/
public function getBrowser()
{
@trigger_error(sprintf('"%s()" has been deprecated since symfonycorp/connect 5.1.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('"%s()" is deprecated since symfonycorp/connect 5.1.', __METHOD__), E_USER_DEPRECATED);

if (!class_exists(Browser::class)) {
throw new \LogicException(sprintf('You cannot use "%s()" as the "kriswallsmith/buzz" package is not installed, try running "composer require kriswallsmith/buzz".', Browser::class));
Expand Down
2 changes: 1 addition & 1 deletion tests/SymfonyCorp/Connect/Tests/Api/ApiTest.php
Expand Up @@ -11,12 +11,12 @@

namespace SymfonyCorp\Connect\Test\Api;

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use SymfonyCorp\Connect\Api\Api;
use SymfonyCorp\Connect\Api\Entity\Root;
use PHPUnit\Framework\TestCase;

/**
* ApitTest.
Expand Down

0 comments on commit 5deb06f

Please sign in to comment.