Skip to content

Commit

Permalink
Fixes for PHP 8.4 deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Mar 31, 2024
1 parent bcab7c0 commit 3d4081e
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 59 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
->setRules([
'@PHP71Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PSR12:risky' => true,
'@Symfony' => true,
'declare_strict_types' => false,
'global_namespace_import' => false,
Expand Down
10 changes: 5 additions & 5 deletions src/GuzzleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -96,7 +96,7 @@ public function getDescription()
*
* @param callable|null $commandToRequestTransformer
*
* @return \GuzzleHttp\Command\Guzzle\Serializer
* @return Serializer
*/
private function getSerializer($commandToRequestTransformer)
{
Expand All @@ -110,7 +110,7 @@ private function getSerializer($commandToRequestTransformer)
*
* @param callable|null $responseToResultTransformer
*
* @return \GuzzleHttp\Command\Guzzle\Deserializer
* @return Deserializer
*/
private function getDeserializer($responseToResultTransformer)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/ValidatedDescriptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand Down
2 changes: 1 addition & 1 deletion src/RequestLocation/QueryLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/ResponseLocation/JsonLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($locationName = 'json')
}

/**
* @return \GuzzleHttp\Command\ResultInterface
* @return ResultInterface
*/
public function before(
ResultInterface $result,
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
96 changes: 48 additions & 48 deletions tests/GuzzleClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 3d4081e

Please sign in to comment.