diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 800bad1a..48dee738 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -5,6 +5,7 @@ ->setRules([ '@PHP71Migration:risky' => true, '@PHPUnit75Migration:risky' => true, + '@PSR12:risky' => true, '@Symfony' => true, 'declare_strict_types' => false, 'global_namespace_import' => false, diff --git a/src/GuzzleClient.php b/src/GuzzleClient.php index 168c88fa..b935480c 100644 --- a/src/GuzzleClient.php +++ b/src/GuzzleClient.php @@ -41,9 +41,9 @@ class GuzzleClient extends ServiceClient public function __construct( ClientInterface $client, DescriptionInterface $description, - callable $commandToRequestTransformer = null, - callable $responseToResultTransformer = null, - HandlerStack $commandHandlerStack = null, + ?callable $commandToRequestTransformer = null, + ?callable $responseToResultTransformer = null, + ?HandlerStack $commandHandlerStack = null, array $config = [] ) { $this->config = $config; @@ -96,7 +96,7 @@ public function getDescription() * * @param callable|null $commandToRequestTransformer * - * @return \GuzzleHttp\Command\Guzzle\Serializer + * @return Serializer */ private function getSerializer($commandToRequestTransformer) { @@ -110,7 +110,7 @@ private function getSerializer($commandToRequestTransformer) * * @param callable|null $responseToResultTransformer * - * @return \GuzzleHttp\Command\Guzzle\Deserializer + * @return Deserializer */ private function getDeserializer($responseToResultTransformer) { diff --git a/src/Handler/ValidatedDescriptionHandler.php b/src/Handler/ValidatedDescriptionHandler.php index 49b4dc95..9289eeca 100644 --- a/src/Handler/ValidatedDescriptionHandler.php +++ b/src/Handler/ValidatedDescriptionHandler.php @@ -23,7 +23,7 @@ class ValidatedDescriptionHandler /** * ValidatedDescriptionHandler constructor. */ - public function __construct(DescriptionInterface $description, SchemaValidator $schemaValidator = null) + public function __construct(DescriptionInterface $description, ?SchemaValidator $schemaValidator = null) { $this->description = $description; $this->validator = $schemaValidator ?: new SchemaValidator(); diff --git a/src/Operation.php b/src/Operation.php index 0fbaa217..cca755b4 100644 --- a/src/Operation.php +++ b/src/Operation.php @@ -51,7 +51,7 @@ class Operation implements ToArrayInterface * * @throws \InvalidArgumentException */ - public function __construct(array $config = [], DescriptionInterface $description = null) + public function __construct(array $config = [], ?DescriptionInterface $description = null) { static $defaults = [ 'name' => '', diff --git a/src/RequestLocation/QueryLocation.php b/src/RequestLocation/QueryLocation.php index 9e9e090b..53cdb060 100644 --- a/src/RequestLocation/QueryLocation.php +++ b/src/RequestLocation/QueryLocation.php @@ -25,7 +25,7 @@ class QueryLocation extends AbstractLocation * * @param string $locationName */ - public function __construct($locationName = 'query', QuerySerializerInterface $querySerializer = null) + public function __construct($locationName = 'query', ?QuerySerializerInterface $querySerializer = null) { parent::__construct($locationName); diff --git a/src/ResponseLocation/JsonLocation.php b/src/ResponseLocation/JsonLocation.php index 126ee469..ae1c8e0a 100644 --- a/src/ResponseLocation/JsonLocation.php +++ b/src/ResponseLocation/JsonLocation.php @@ -26,7 +26,7 @@ public function __construct($locationName = 'json') } /** - * @return \GuzzleHttp\Command\ResultInterface + * @return ResultInterface */ public function before( ResultInterface $result, diff --git a/src/Serializer.php b/src/Serializer.php index d9090118..f3dc8f21 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -132,7 +132,7 @@ protected function createRequest(CommandInterface $command) /** * Create a request for an operation with a uri merged onto a base URI * - * @return \GuzzleHttp\Psr7\Request + * @return Request */ private function createCommandWithUri( Operation $operation, diff --git a/tests/GuzzleClientTest.php b/tests/GuzzleClientTest.php index 8d315e74..a2595627 100644 --- a/tests/GuzzleClientTest.php +++ b/tests/GuzzleClientTest.php @@ -716,8 +716,8 @@ public function testReturnsProcessedResponse() private function getServiceClient( array $responses, - MockHandler $mock = null, - callable $commandToRequestTransformer = null + ?MockHandler $mock = null, + ?callable $commandToRequestTransformer = null ) { $mock = $mock ?: new MockHandler(); @@ -954,31 +954,31 @@ public function testDocumentationExampleFromReadme() $client = new HttpClient(); $description = new Description([ 'baseUrl' => 'http://httpbin.org/', - 'operations' => [ - 'testing' => [ - 'httpMethod' => 'GET', - 'uri' => '/get{?foo}', - 'responseModel' => 'getResponse', - 'parameters' => [ - 'foo' => [ - 'type' => 'string', - 'location' => 'uri', - ], - 'bar' => [ - 'type' => 'string', - 'location' => 'query', - ], + 'operations' => [ + 'testing' => [ + 'httpMethod' => 'GET', + 'uri' => '/get{?foo}', + 'responseModel' => 'getResponse', + 'parameters' => [ + 'foo' => [ + 'type' => 'string', + 'location' => 'uri', + ], + 'bar' => [ + 'type' => 'string', + 'location' => 'query', ], ], ], - 'models' => [ - 'getResponse' => [ - 'type' => 'object', - 'additionalProperties' => [ - 'location' => 'json', - ], + ], + 'models' => [ + 'getResponse' => [ + 'type' => 'object', + 'additionalProperties' => [ + 'location' => 'json', ], ], + ], ]); $guzzle = new GuzzleClient($client, $description); @@ -991,39 +991,39 @@ public function testDescriptionWithExtends() { $client = new HttpClient(); $description = new Description([ - 'baseUrl' => 'http://httpbin.org/', - 'operations' => [ - 'testing' => [ - 'httpMethod' => 'GET', - 'uri' => '/get', - 'responseModel' => 'getResponse', - 'parameters' => [ - 'foo' => [ - 'type' => 'string', - 'default' => 'foo', - 'location' => 'query', - ], + 'baseUrl' => 'http://httpbin.org/', + 'operations' => [ + 'testing' => [ + 'httpMethod' => 'GET', + 'uri' => '/get', + 'responseModel' => 'getResponse', + 'parameters' => [ + 'foo' => [ + 'type' => 'string', + 'default' => 'foo', + 'location' => 'query', ], ], - 'testing_extends' => [ - 'extends' => 'testing', - 'responseModel' => 'getResponse', - 'parameters' => [ - 'bar' => [ - 'type' => 'string', - 'location' => 'query', - ], + ], + 'testing_extends' => [ + 'extends' => 'testing', + 'responseModel' => 'getResponse', + 'parameters' => [ + 'bar' => [ + 'type' => 'string', + 'location' => 'query', ], ], ], - 'models' => [ - 'getResponse' => [ - 'type' => 'object', - 'additionalProperties' => [ - 'location' => 'json', - ], + ], + 'models' => [ + 'getResponse' => [ + 'type' => 'object', + 'additionalProperties' => [ + 'location' => 'json', ], ], + ], ]); $guzzle = new GuzzleClient($client, $description); $result = $guzzle->testing_extends(['bar' => 'bar']); diff --git a/vendor-bin/php-cs-fixer/composer.json b/vendor-bin/php-cs-fixer/composer.json index 3e8c9dfb..049eacf1 100644 --- a/vendor-bin/php-cs-fixer/composer.json +++ b/vendor-bin/php-cs-fixer/composer.json @@ -1,7 +1,7 @@ { "require": { "php": "^7.4 || ^8.0", - "friendsofphp/php-cs-fixer": "3.40.2" + "friendsofphp/php-cs-fixer": "3.52.1" }, "config": { "preferred-install": "dist"