From 3b1dd126b65f1b348ac7d9180e69e5914ea48a88 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 21 Aug 2023 12:30:31 +0530 Subject: [PATCH 1/5] CHnages to solve DeprecatedInterface error on composer analyze --- psalm.xml.dist | 3 --- src/Client.php | 8 ++++---- src/ClientInterface.php | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/psalm.xml.dist b/psalm.xml.dist index b0582145..103f8c77 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -49,8 +49,5 @@ - - - diff --git a/src/Client.php b/src/Client.php index 8268e572..a3acd582 100644 --- a/src/Client.php +++ b/src/Client.php @@ -36,7 +36,7 @@ use Http\Discovery\MessageFactoryDiscovery; use Http\Discovery\UriFactoryDiscovery; use Http\Message\Authentication; -use Http\Message\UriFactory; +use Psr\Http\Message\UriFactoryInterface as UriFactory; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -66,7 +66,7 @@ class Client implements ClientInterface public const CONFIG_RETRY_PLUGIN_CONFIG = 'retry_plugin_config'; - /** @var \Http\Message\UriFactory */ + /** @var \Psr\Http\Message\UriFactoryInterface */ private $uriFactory; /** @var string|null */ @@ -122,7 +122,7 @@ class Client implements ClientInterface * User agent prefix. * - Apigee\Edge\Client::CONFIG_HTTP_CLIENT_BUILDER: \Apigee\Edge\HttpClient\Utility\BuilderInterface|null * Http client builder. - * - Apigee\Edge\Client::CONFIG_URI_FACTORY: \Http\Message\UriFactory|null + * - Apigee\Edge\Client::CONFIG_URI_FACTORY: Psr\Http\Message\UriFactoryInterface|null * Factory for PSR-7 URIs. * - Apigee\Edge\Client::CONFIG_REQUEST_FACTORY: \Http\Message\RequestFactory|null * Factory for PSR-7 Requests. @@ -266,7 +266,7 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes(static::CONFIG_USER_AGENT_PREFIX, ['null', 'string']); $resolver->setAllowedTypes(static::CONFIG_HTTP_CLIENT_BUILDER, ['null', '\Apigee\Edge\HttpClient\Utility\BuilderInterface']); $resolver->setAllowedTypes(static::CONFIG_JOURNAL, ['null', '\Apigee\Edge\HttpClient\Utility\JournalInterface']); - $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Http\Message\UriFactory']); + $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Psr\Http\Message\UriFactoryInterface']); $resolver->setAllowedTypes(static::CONFIG_REQUEST_FACTORY, ['null', '\Http\Message\RequestFactory']); $resolver->setAllowedTypes(static::CONFIG_ERROR_FORMATTER, ['null', '\Http\Message\Formatter']); $resolver->setAllowedTypes(static::CONFIG_RETRY_PLUGIN_CONFIG, ['null', 'array']); diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 75a4ff56..49a7691a 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -19,9 +19,9 @@ namespace Apigee\Edge; use Apigee\Edge\HttpClient\Utility\JournalInterface; -use Http\Message\UriFactory; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\UriFactoryInterface as UriFactory; /** * Interface ClientInterface. From a130e35913ea4b6cf5e8a9eda49953a0eeb7baa6 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 21 Aug 2023 20:01:54 +0530 Subject: [PATCH 2/5] Changes added for Test and lint errors --- src/Client.php | 4 ++-- src/ClientInterface.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index a3acd582..df48f8fd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -36,7 +36,7 @@ use Http\Discovery\MessageFactoryDiscovery; use Http\Discovery\UriFactoryDiscovery; use Http\Message\Authentication; -use Psr\Http\Message\UriFactoryInterface as UriFactory; +use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -155,7 +155,7 @@ public function getJournal(): JournalInterface /** * {@inheritdoc} */ - public function getUriFactory(): UriFactory + public function getUriFactory(): UriFactoryInterface { return $this->uriFactory; } diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 49a7691a..84cb087e 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -21,7 +21,7 @@ use Apigee\Edge\HttpClient\Utility\JournalInterface; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriFactoryInterface as UriFactory; +use Psr\Http\Message\UriFactoryInterface; /** * Interface ClientInterface. @@ -75,8 +75,10 @@ public function getJournal(): JournalInterface; /** * Returns the URI factory used by the Client. + * + * @return \Psr\Http\Message\UriFactoryInterface */ - public function getUriFactory(): UriFactory; + public function getUriFactory(): UriFactoryInterface; /** * Returns the version of the API client. From 364340164c482db2b57ed346133190e3a055ca28 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 22 Aug 2023 21:34:09 +0530 Subject: [PATCH 3/5] Test passed --- src/Client.php | 11 ++++++----- src/ClientInterface.php | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Client.php b/src/Client.php index df48f8fd..12a49a79 100644 --- a/src/Client.php +++ b/src/Client.php @@ -36,7 +36,7 @@ use Http\Discovery\MessageFactoryDiscovery; use Http\Discovery\UriFactoryDiscovery; use Http\Message\Authentication; -use Psr\Http\Message\UriFactoryInterface; +use Http\Message\UriFactory; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -66,7 +66,7 @@ class Client implements ClientInterface public const CONFIG_RETRY_PLUGIN_CONFIG = 'retry_plugin_config'; - /** @var \Psr\Http\Message\UriFactoryInterface */ + /** @var \Http\Message\UriFactory */ private $uriFactory; /** @var string|null */ @@ -122,7 +122,7 @@ class Client implements ClientInterface * User agent prefix. * - Apigee\Edge\Client::CONFIG_HTTP_CLIENT_BUILDER: \Apigee\Edge\HttpClient\Utility\BuilderInterface|null * Http client builder. - * - Apigee\Edge\Client::CONFIG_URI_FACTORY: Psr\Http\Message\UriFactoryInterface|null + * - Apigee\Edge\Client::CONFIG_URI_FACTORY: Http\Message\UriFactory|null * Factory for PSR-7 URIs. * - Apigee\Edge\Client::CONFIG_REQUEST_FACTORY: \Http\Message\RequestFactory|null * Factory for PSR-7 Requests. @@ -155,7 +155,8 @@ public function getJournal(): JournalInterface /** * {@inheritdoc} */ - public function getUriFactory(): UriFactoryInterface + #[\ReturnTypeWillChange] + public function getUriFactory(): UriFactory { return $this->uriFactory; } @@ -266,7 +267,7 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes(static::CONFIG_USER_AGENT_PREFIX, ['null', 'string']); $resolver->setAllowedTypes(static::CONFIG_HTTP_CLIENT_BUILDER, ['null', '\Apigee\Edge\HttpClient\Utility\BuilderInterface']); $resolver->setAllowedTypes(static::CONFIG_JOURNAL, ['null', '\Apigee\Edge\HttpClient\Utility\JournalInterface']); - $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Psr\Http\Message\UriFactoryInterface']); + $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Http\Message\UriFactory']); $resolver->setAllowedTypes(static::CONFIG_REQUEST_FACTORY, ['null', '\Http\Message\RequestFactory']); $resolver->setAllowedTypes(static::CONFIG_ERROR_FORMATTER, ['null', '\Http\Message\Formatter']); $resolver->setAllowedTypes(static::CONFIG_RETRY_PLUGIN_CONFIG, ['null', 'array']); diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 84cb087e..3d266e0b 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -21,7 +21,7 @@ use Apigee\Edge\HttpClient\Utility\JournalInterface; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriFactoryInterface; +use Http\Message\UriFactory; /** * Interface ClientInterface. @@ -76,9 +76,10 @@ public function getJournal(): JournalInterface; /** * Returns the URI factory used by the Client. * - * @return \Psr\Http\Message\UriFactoryInterface + * @return UriFactory */ - public function getUriFactory(): UriFactoryInterface; + #[\ReturnTypeWillChange] + public function getUriFactory(): UriFactory; /** * Returns the version of the API client. From 9a49ddb3a6f318d06c34211ea967519c663c4864 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 22 Aug 2023 21:44:34 +0530 Subject: [PATCH 4/5] Added missing slash --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 12a49a79..10f66f90 100644 --- a/src/Client.php +++ b/src/Client.php @@ -122,7 +122,7 @@ class Client implements ClientInterface * User agent prefix. * - Apigee\Edge\Client::CONFIG_HTTP_CLIENT_BUILDER: \Apigee\Edge\HttpClient\Utility\BuilderInterface|null * Http client builder. - * - Apigee\Edge\Client::CONFIG_URI_FACTORY: Http\Message\UriFactory|null + * - Apigee\Edge\Client::CONFIG_URI_FACTORY: \Http\Message\UriFactory|null * Factory for PSR-7 URIs. * - Apigee\Edge\Client::CONFIG_REQUEST_FACTORY: \Http\Message\RequestFactory|null * Factory for PSR-7 Requests. From f3d50a1b1caaf014d744357be8bf980094a193b4 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 22 Aug 2023 22:22:03 +0530 Subject: [PATCH 5/5] Reverted to UrifactoryInterface --- src/Client.php | 14 ++++++++------ src/ClientInterface.php | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Client.php b/src/Client.php index 10f66f90..a3ebdd07 100644 --- a/src/Client.php +++ b/src/Client.php @@ -36,7 +36,7 @@ use Http\Discovery\MessageFactoryDiscovery; use Http\Discovery\UriFactoryDiscovery; use Http\Message\Authentication; -use Http\Message\UriFactory; +use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -66,7 +66,7 @@ class Client implements ClientInterface public const CONFIG_RETRY_PLUGIN_CONFIG = 'retry_plugin_config'; - /** @var \Http\Message\UriFactory */ + /** @var UriFactoryInterface */ private $uriFactory; /** @var string|null */ @@ -122,7 +122,7 @@ class Client implements ClientInterface * User agent prefix. * - Apigee\Edge\Client::CONFIG_HTTP_CLIENT_BUILDER: \Apigee\Edge\HttpClient\Utility\BuilderInterface|null * Http client builder. - * - Apigee\Edge\Client::CONFIG_URI_FACTORY: \Http\Message\UriFactory|null + * - Apigee\Edge\Client::CONFIG_URI_FACTORY: \Psr\Http\Message\UriFactoryInterface|null * Factory for PSR-7 URIs. * - Apigee\Edge\Client::CONFIG_REQUEST_FACTORY: \Http\Message\RequestFactory|null * Factory for PSR-7 Requests. @@ -153,10 +153,12 @@ public function getJournal(): JournalInterface } /** - * {@inheritdoc} + * Create a new URI. + * + * @return UriFactoryInterface */ #[\ReturnTypeWillChange] - public function getUriFactory(): UriFactory + public function getUriFactory(): UriFactoryInterface { return $this->uriFactory; } @@ -267,7 +269,7 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes(static::CONFIG_USER_AGENT_PREFIX, ['null', 'string']); $resolver->setAllowedTypes(static::CONFIG_HTTP_CLIENT_BUILDER, ['null', '\Apigee\Edge\HttpClient\Utility\BuilderInterface']); $resolver->setAllowedTypes(static::CONFIG_JOURNAL, ['null', '\Apigee\Edge\HttpClient\Utility\JournalInterface']); - $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Http\Message\UriFactory']); + $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Psr\Http\Message\UriFactoryInterface']); $resolver->setAllowedTypes(static::CONFIG_REQUEST_FACTORY, ['null', '\Http\Message\RequestFactory']); $resolver->setAllowedTypes(static::CONFIG_ERROR_FORMATTER, ['null', '\Http\Message\Formatter']); $resolver->setAllowedTypes(static::CONFIG_RETRY_PLUGIN_CONFIG, ['null', 'array']); diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 3d266e0b..c6818bed 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -21,7 +21,7 @@ use Apigee\Edge\HttpClient\Utility\JournalInterface; use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\ResponseInterface; -use Http\Message\UriFactory; +use Psr\Http\Message\UriFactoryInterface; /** * Interface ClientInterface. @@ -76,10 +76,10 @@ public function getJournal(): JournalInterface; /** * Returns the URI factory used by the Client. * - * @return UriFactory + * @return UriFactoryInterface */ #[\ReturnTypeWillChange] - public function getUriFactory(): UriFactory; + public function getUriFactory(): UriFactoryInterface; /** * Returns the version of the API client.