From a815421376f2c6f27b4d5210405227df16255194 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Fri, 18 Oct 2024 18:57:03 +0530 Subject: [PATCH 01/23] PHP 8.4 support added Signed-off-by: manishranjan-adobe --- README.md | 13 ++++++------- composer.json | 2 +- composer.lock | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9ce6133..2f86d7f 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,21 @@ # laminas-oauth > ## πŸ‡·πŸ‡Ί Русским Π³Ρ€Π°ΠΆΠ΄Π°Π½Π°ΠΌ -> +> > ΠœΡ‹, участники Laminas, Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ ΠΈ ΠΆΠΈΠ²Π΅ΠΌ Π² Ρ€Π°Π·Π½Ρ‹Ρ… странах. Π£ ΠΌΠ½ΠΎΠ³ΠΈΡ… ΠΈΠ· нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, родствСнники ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΊΠ°ΠΊ Π² России, Ρ‚Π°ΠΊ ΠΈ Π² Π£ΠΊΡ€Π°ΠΈΠ½Π΅. НСкоторыС ΠΈΠ· нас Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ Π² России. НСкоторыС ΠΈΠ· нас ΠΆΠΈΠ²ΡƒΡ‚ Π² России. Π£ Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Ρ… Π±Π°Π±ΡƒΡˆΠΊΠΈ ΠΈ Π΄Π΅Π΄ΡƒΡˆΠΊΠΈ ΡΡ€Π°ΠΆΠ°Π»ΠΈΡΡŒ с Ρ„Π°ΡˆΠΈΡΡ‚Π°ΠΌΠΈ Π²ΠΎ Π’Ρ‚ΠΎΡ€ΠΎΠΉ ΠΌΠΈΡ€ΠΎΠ²ΠΎΠΉ Π²ΠΎΠΉΠ½Π΅. Π—Π΄Π΅ΡΡŒ Π½ΠΈΠΊΡ‚ΠΎ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅Ρ‚ Ρ„Π°ΡˆΠΈΠ·ΠΌ. -> +> > Π£ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ· нас Π΅ΡΡ‚ΡŒ украинская родствСнница, которая спаслась ΠΈΠ· Π΄ΠΎΠΌΠ° вмСстС с сыном. ПоСзд задСрТался ΠΈΠ·-Π·Π° Π±ΠΎΠΌΠ±Π΅ΠΆΠΊΠΈ Π½Π° Π΄ΠΎΡ€ΠΎΠ³Π΅ Π²ΠΏΠ΅Ρ€Π΅Π΄ΠΈ. Π£ нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ прячутся Π² Π±ΠΎΠΌΠ±ΠΎΡƒΠ±Π΅ΠΆΠΈΡ‰Π°Ρ…. ΠœΡ‹ с Ρ‚Ρ€Π΅Π²ΠΎΠ³ΠΎΠΉ ΠΆΠ΄Π΅ΠΌ вСсточки ΠΎΡ‚ Π½ΠΈΡ… послС Π²ΠΎΠ·Π΄ΡƒΡˆΠ½Ρ‹Ρ… Π½Π°Π»Π΅Ρ‚ΠΎΠ², ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ бСспорядочно наносят ΡƒΠ΄Π°Ρ€Ρ‹ ΠΈ ΠΏΠΎΠΏΠ°Π΄Π°ΡŽΡ‚ ΠΏΠΎ Π±ΠΎΠ»ΡŒΠ½ΠΈΡ†Π°ΠΌ, школам, дСтским садам ΠΈ Π΄ΠΎΠΌΠ°ΠΌ. ΠœΡ‹ Π½Π΅ Π±Π΅Ρ€Π΅ΠΌ это ΠΈΠ· ΠΊΠ°ΠΊΠΈΡ…-Π»ΠΈΠ±ΠΎ БМИ. ΠœΡ‹ наблюдаСм это Π½Π°ΠΏΡ€ΡΠΌΡƒΡŽ. -> +> > Π’Ρ‹ довСряСтС Π½Π°ΠΌ достаточно, Ρ‡Ρ‚ΠΎΠ± ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ наши ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹, ΠΈ ΠΌΡ‹ просим вас Π΄ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒΡΡ Π½Π°ΠΌ вновь. ΠœΡ‹ нуТдаСмся Π² ΠΏΠΎΠΌΠΎΡ‰ΠΈ. Π’Ρ‹Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ ΠΈ протСстуйтС ΠΏΡ€ΠΎΡ‚ΠΈΠ² этой бСсполСзной Π²ΠΎΠΉΠ½Ρ‹. ΠžΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚Π΅ ΠΊΡ€ΠΎΠ²ΠΎΠΏΡ€ΠΎΠ»ΠΈΡ‚ΠΈΠ΅. Π‘ΠΊΠ°ΠΆΠΈΡ‚Π΅ "НСт Π²ΠΎΠΉΠ½Π΅!" -> +> > ## πŸ‡ΊπŸ‡Έ To Citizens of Russia -> +> > We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism. > > One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences. -> +> > You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!" - > This package is considered feature-complete, and is now in **security-only** maintenance mode, following a [decision by the Technical Steering Committee](https://github.com/laminas/technical-steering-committee/blob/2b55453e172a1b8c9c4c212be7cf7e7a58b9352c/meetings/minutes/2020-08-03-TSC-Minutes.md#vote-on-components-to-mark-as-security-only). > If you have a security issue, please [follow our security reporting guidelines](https://getlaminas.org/security/). > If you wish to take on the role of maintainer, please [nominate yourself](https://github.com/laminas/technical-steering-committee/issues/new?assignees=&labels=Nomination&template=Maintainer_Nomination.md&title=%5BNOMINATION%5D%5BMAINTAINER%5D%3A+%7Bname+of+person+being+nominated%7D) diff --git a/composer.json b/composer.json index 6f0dcd5..8289af9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "laminas/laminas-config": "^3.7", "laminas/laminas-crypt": "^3.6.0", "laminas/laminas-http": "^2.15", diff --git a/composer.lock b/composer.lock index 9b4e08d..a8527cb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a9f93855548b096a915df8efc4ff2c2b", + "content-hash": "ade21801c2cacc28ce8dfec0bb00e614", "packages": [ { "name": "laminas/laminas-config", @@ -2658,12 +2658,12 @@ "version": "2.9.2", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "reference": "2acf168de78487db620ab4bc524135a13cfe6745" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", "reference": "2acf168de78487db620ab4bc524135a13cfe6745", "shasum": "" }, @@ -2793,7 +2793,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" }, "platform-dev": [], "platform-overrides": { From 82d6eac620365801403cf115eb72a3e8e930c977 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Fri, 18 Oct 2024 19:01:23 +0530 Subject: [PATCH 02/23] MD file linting issue fix Signed-off-by: manishranjan-adobe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f86d7f..eb46c9f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ > ## πŸ‡ΊπŸ‡Έ To Citizens of Russia > > We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism. -> +> > One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences. > > You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!" From b5750c1732114421d9e27ce9559897f44ea89492 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Fri, 18 Oct 2024 19:10:58 +0530 Subject: [PATCH 03/23] composer.lock PHP_Codesniffer fix Signed-off-by: manishranjan-adobe --- composer.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index a8527cb..08dc45b 100644 --- a/composer.lock +++ b/composer.lock @@ -2658,12 +2658,12 @@ "version": "2.9.2", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "reference": "2acf168de78487db620ab4bc524135a13cfe6745" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", "reference": "2acf168de78487db620ab4bc524135a13cfe6745", "shasum": "" }, From 7938522b72269f583312e92754ba8ab4669d736d Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Fri, 18 Oct 2024 19:16:01 +0530 Subject: [PATCH 04/23] Ignore pathform dependency Signed-off-by: manishranjan-adobe --- .laminas-ci.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.laminas-ci.json b/.laminas-ci.json index 7c4c9b8..24c03b5 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -5,6 +5,7 @@ {"name": "PHPUnit on PHP 7.1 with locked dependencies"} ], "ignore_php_platform_requirements": { - "8.2": true + "8.2": true, + "8.4": true } } From 7a1039b5f0cec1fc88837864cb7afe27eab57016 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Mon, 21 Oct 2024 10:42:06 +0530 Subject: [PATCH 05/23] Fix PHP 8.4 deprecation: Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead Signed-off-by: manishranjan-adobe --- src/Client.php | 2 +- src/Consumer.php | 18 +++++++++--------- src/Http.php | 6 +++--- src/Http/Utility.php | 2 +- src/Token/AbstractToken.php | 4 ++-- src/Token/Access.php | 6 +++--- src/Token/AuthorizedRequest.php | 2 +- src/Token/Request.php | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Client.php b/src/Client.php index 9541bad..28d0119 100644 --- a/src/Client.php +++ b/src/Client.php @@ -162,7 +162,7 @@ public function setMethod($method = HttpRequest::METHOD_GET) * @param null|Laminas\Http\Request $method * @return HttpResponse */ - public function send(HttpRequest $request = null) + public function send(?HttpRequest $request = null) { $this->prepareOAuth(); return parent::send($request); diff --git a/src/Consumer.php b/src/Consumer.php index d7b1309..5956fc7 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -60,9 +60,9 @@ public function __construct($options = null) * @return Laminas\OAuth\Token\Request */ public function getRequestToken( - array $customServiceParameters = null, - $httpMethod = null, - Http\RequestToken $request = null + ?array $customServiceParameters = null, + ?string $httpMethod = null, + ?Http\RequestToken $request = null ) { if ($request === null) { $request = new Http\RequestToken($this, $customServiceParameters); @@ -93,9 +93,9 @@ public function getRequestToken( * @return string */ public function getRedirectUrl( - array $customServiceParameters = null, - Token\Request $token = null, - Http\UserAuthorization $redirect = null + ?array $customServiceParameters = null, + ?Token\Request $token = null, + ?Http\UserAuthorization $redirect = null ) { if ($redirect === null) { $redirect = new Http\UserAuthorization($this, $customServiceParameters); @@ -119,8 +119,8 @@ public function getRedirectUrl( * @return void */ public function redirect( - array $customServiceParameters = null, - Http\UserAuthorization $request = null + ?array $customServiceParameters = null, + ?Http\UserAuthorization $request = null ) { $redirectUrl = $this->getRedirectUrl($customServiceParameters, $request); header('Location: ' . $redirectUrl); @@ -144,7 +144,7 @@ public function getAccessToken( $queryData, Token\Request $token, $httpMethod = null, - Http\AccessToken $request = null + ?Http\AccessToken $request = null ) { $authorizedToken = new Token\AuthorizedRequest($queryData); if (! $authorizedToken->isValid()) { diff --git a/src/Http.php b/src/Http.php index 0e76823..6bc3348 100644 --- a/src/Http.php +++ b/src/Http.php @@ -56,8 +56,8 @@ class Http */ public function __construct( Consumer $consumer, - array $parameters = null, - Http\Utility $utility = null + ?array $parameters = null, + ?Http\Utility $utility = null ) { $this->consumer = $consumer; $this->preferredRequestScheme = $this->consumer->getRequestScheme(); @@ -197,7 +197,7 @@ public function getRequestSchemeQueryStringClient(array $params, $url) * @return void * @throws Exception\RuntimeException if unable to retrieve valid token response */ - protected function assessRequestAttempt(\Laminas\Http\Response $response = null) + protected function assessRequestAttempt(?\Laminas\Http\Response $response = null) { switch ($this->preferredRequestScheme) { case OAuth::REQUEST_SCHEME_HEADER: diff --git a/src/Http/Utility.php b/src/Http/Utility.php index 5831038..a2ce82d 100644 --- a/src/Http/Utility.php +++ b/src/Http/Utility.php @@ -22,7 +22,7 @@ class Utility public function assembleParams( $url, ConfigInterface $config, - array $serviceProviderParams = null + ?array $serviceProviderParams = null ) { $params = [ 'oauth_consumer_key' => $config->getConsumerKey(), diff --git a/src/Token/AbstractToken.php b/src/Token/AbstractToken.php index b2de55a..bb0d8f6 100644 --- a/src/Token/AbstractToken.php +++ b/src/Token/AbstractToken.php @@ -46,8 +46,8 @@ abstract class AbstractToken implements TokenInterface * @return void */ public function __construct( - HTTPResponse $response = null, - HTTPUtility $utility = null + ?HTTPResponse $response = null, + ?HTTPUtility $utility = null ) { if ($response !== null) { $this->response = $response; diff --git a/src/Token/Access.php b/src/Token/Access.php index ed1c8f5..fe45cc3 100644 --- a/src/Token/Access.php +++ b/src/Token/Access.php @@ -26,8 +26,8 @@ class Access extends AbstractToken public function toHeader( $url, Config $config, - array $customParams = null, - $realm = null + ?array $customParams = null, + ?string $realm = null ) { $uri = Uri\UriFactory::factory($url); if (! $uri->isValid() @@ -50,7 +50,7 @@ public function toHeader( * @return string * @throws Exception\InvalidArgumentException */ - public function toQueryString($url, Config $config, array $params = null) + public function toQueryString($url, Config $config, ?array $params = null) { $uri = Uri\UriFactory::factory($url); if (! $uri->isValid() diff --git a/src/Token/AuthorizedRequest.php b/src/Token/AuthorizedRequest.php index df6d8c6..80711d1 100644 --- a/src/Token/AuthorizedRequest.php +++ b/src/Token/AuthorizedRequest.php @@ -22,7 +22,7 @@ class AuthorizedRequest extends AbstractToken * @param null|\Laminas\OAuth\Http\Utility $utility * @return void */ - public function __construct(array $data = null, Http\Utility $utility = null) + public function __construct(?array $data = null, ?Http\Utility $utility = null) { if ($data !== null) { $this->data = $data; diff --git a/src/Token/Request.php b/src/Token/Request.php index 50dc408..3bba4ef 100644 --- a/src/Token/Request.php +++ b/src/Token/Request.php @@ -19,8 +19,8 @@ class Request extends AbstractToken * @param null|Laminas\OAuth\Http\Utility $utility */ public function __construct( - HTTPResponse $response = null, - HTTPUtility $utility = null + ?HTTPResponse $response = null, + ?HTTPUtility $utility = null ) { parent::__construct($response, $utility); From 7a8df59e36d7296a4b4c83bc97735ed2223665f2 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Mon, 21 Oct 2024 17:18:23 +0530 Subject: [PATCH 06/23] Backward compatibility fix Signed-off-by: manishranjan-adobe --- composer.json | 4 ++-- composer.lock | 2 +- src/Consumer.php | 2 +- src/Token/Access.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 8289af9..5565c7b 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,8 @@ "laminas/laminas-uri": "^2.9" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", - "phpunit/phpunit": "^9.5.5" + "laminas/laminas-coding-standard": "~1", + "phpunit/phpunit": "^9.6.13" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 08dc45b..60795a2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ade21801c2cacc28ce8dfec0bb00e614", + "content-hash": "70349f225b828c0349eabf35bd82d5c3", "packages": [ { "name": "laminas/laminas-config", diff --git a/src/Consumer.php b/src/Consumer.php index 5956fc7..afa0339 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -61,7 +61,7 @@ public function __construct($options = null) */ public function getRequestToken( ?array $customServiceParameters = null, - ?string $httpMethod = null, + $httpMethod = null, ?Http\RequestToken $request = null ) { if ($request === null) { diff --git a/src/Token/Access.php b/src/Token/Access.php index fe45cc3..4e8b10e 100644 --- a/src/Token/Access.php +++ b/src/Token/Access.php @@ -27,7 +27,7 @@ public function toHeader( $url, Config $config, ?array $customParams = null, - ?string $realm = null + $realm = null ) { $uri = Uri\UriFactory::factory($url); if (! $uri->isValid() From 8f887b37fb5020540b5b27485dbacf2f061b310b Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 13:27:15 +0530 Subject: [PATCH 07/23] Updated outdated laminas/laminas-coding-standard and squizlabs/php_codesniffer Signed-off-by: manishranjan-adobe --- composer.json | 2 +- composer.lock | 408 ++++++++++++++++++++++++++++++++++++-------------- phpcs.xml | 20 +++ phpunit.xml | 25 ++++ 4 files changed, 342 insertions(+), 113 deletions(-) create mode 100644 phpcs.xml create mode 100644 phpunit.xml diff --git a/composer.json b/composer.json index 5565c7b..a4c8b5b 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "laminas/laminas-uri": "^2.9" }, "require-dev": { - "laminas/laminas-coding-standard": "~1", + "laminas/laminas-coding-standard": "~2.5.0", "phpunit/phpunit": "^9.6.13" }, "autoload": { diff --git a/composer.lock b/composer.lock index 60795a2..ec49f6d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "70349f225b828c0349eabf35bd82d5c3", + "content-hash": "e9c0660b49aaa1a673f6e6a05c996c07", "packages": [ { "name": "laminas/laminas-config", @@ -867,6 +867,81 @@ } ], "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2022-02-04T12:51:07+00:00" + }, { "name": "doctrine/instantiator", "version": "2.0.0", @@ -939,31 +1014,39 @@ }, { "name": "laminas/laminas-coding-standard", - "version": "1.0.0", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "08880ce2fbfe62d471cd3cb766a91da630b32539" + "reference": "c1aaa18a7c860c6932677a3e4ec13161f9fc7d61" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/08880ce2fbfe62d471cd3cb766a91da630b32539", - "reference": "08880ce2fbfe62d471cd3cb766a91da630b32539", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/c1aaa18a7c860c6932677a3e4ec13161f9fc7d61", + "reference": "c1aaa18a7c860c6932677a3e4ec13161f9fc7d61", "shasum": "" }, "require": { - "laminas/laminas-zendframework-bridge": "^1.0", - "squizlabs/php_codesniffer": "^2.7" + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", + "php": "^7.4 || ^8.0", + "slevomat/coding-standard": "^7.0", + "squizlabs/php_codesniffer": "^3.6", + "webimpress/coding-standard": "^1.2" }, - "replace": { - "zendframework/zend-coding-standard": "self.version" + "conflict": { + "phpstan/phpdoc-parser": ">=1.6.0" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "LaminasCodingStandard\\": "src/LaminasCodingStandard/" + } }, - "type": "library", "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "description": "Laminas coding standard", + "description": "Laminas Coding Standard", "homepage": "https://laminas.dev", "keywords": [ "Coding Standard", @@ -977,69 +1060,13 @@ "rss": "https://github.com/laminas/laminas-coding-standard/releases.atom", "source": "https://github.com/laminas/laminas-coding-standard" }, - "time": "2019-12-31T16:28:26+00:00" - }, - { - "name": "laminas/laminas-zendframework-bridge", - "version": "1.7.0", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "5ef52e26392777a26dbb8f20fe24f91b406459f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/5ef52e26392777a26dbb8f20fe24f91b406459f6", - "reference": "5ef52e26392777a26dbb8f20fe24f91b406459f6", - "shasum": "" - }, - "require": { - "php": "~8.0.0 || ~8.1.0 || ~8.2.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.5.26", - "psalm/plugin-phpunit": "^0.18.0", - "squizlabs/php_codesniffer": "^3.7.1", - "vimeo/psalm": "^4.29.0" - }, - "type": "library", - "extra": { - "laminas": { - "module": "Laminas\\ZendFrameworkBridge" - } - }, - "autoload": { - "files": [ - "src/autoload.php" - ], - "psr-4": { - "Laminas\\ZendFrameworkBridge\\": "src//" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Alias legacy ZF class names to Laminas Project equivalents.", - "keywords": [ - "ZendFramework", - "autoloading", - "laminas", - "zf" - ], - "support": { - "forum": "https://discourse.laminas.dev/", - "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", - "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", - "source": "https://github.com/laminas/laminas-zendframework-bridge" - }, "funding": [ { "url": "https://funding.communitybridge.org/projects/laminas-project", "type": "community_bridge" } ], - "time": "2022-12-12T11:44:10+00:00" + "time": "2023-01-05T15:53:40+00:00" }, { "name": "myclabs/deep-copy", @@ -1267,6 +1294,50 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "981cc368a216c988e862a75e526b6076987d1b50" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", + "reference": "981cc368a216c988e862a75e526b6076987d1b50", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" + }, + "time": "2022-05-05T11:32:40+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.29", @@ -2653,66 +2724,100 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "slevomat/coding-standard", + "version": "7.2.1", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.2 || ^8.0", + "phpstan/phpdoc-parser": "^1.5.1", + "squizlabs/php_codesniffer": "^3.6.2" + }, + "require-dev": { + "phing/phing": "2.17.3", + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpstan/phpstan": "1.4.10|1.7.1", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0|1.1.1", + "phpstan/phpstan-strict-rules": "1.2.3", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2022-05-25T10:58:12+00:00" + }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.2", + "version": "3.10.3", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", + "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", "shasum": "" }, "require": { "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.1.2" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "scripts/phpcs", - "scripts/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -2720,21 +2825,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2018-11-07T22:31:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-09-18T10:38:58+00:00" }, { "name": "theseer/tokenizer", @@ -2785,6 +2914,61 @@ } ], "time": "2023-11-20T00:12:19+00:00" + }, + { + "name": "webimpress/coding-standard", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/webimpress/coding-standard.git", + "reference": "6f6a1a90bd9e18fc8bee0660dd1d1ce68cf9fc53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webimpress/coding-standard/zipball/6f6a1a90bd9e18fc8bee0660dd1d1ce68cf9fc53", + "reference": "6f6a1a90bd9e18fc8bee0660dd1d1ce68cf9fc53", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "squizlabs/php_codesniffer": "^3.10.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6.15" + }, + "type": "phpcodesniffer-standard", + "extra": { + "dev-master": "1.2.x-dev", + "dev-develop": "1.3.x-dev" + }, + "autoload": { + "psr-4": { + "WebimpressCodingStandard\\": "src/WebimpressCodingStandard/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "description": "Webimpress Coding Standard", + "keywords": [ + "Coding Standard", + "PSR-2", + "phpcs", + "psr-12", + "webimpress" + ], + "support": { + "issues": "https://github.com/webimpress/coding-standard/issues", + "source": "https://github.com/webimpress/coding-standard/tree/1.4.0" + }, + "funding": [ + { + "url": "https://github.com/michalbundyra", + "type": "github" + } + ], + "time": "2024-10-16T06:55:17+00:00" } ], "aliases": [], diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..cd255f3 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,20 @@ +ο»Ώ + + + + + + + + + + + + + src + test + + + + diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..d278018 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,25 @@ + + + + + ./src + + + + + ./test + + + + + + + + + + + + + + + From 34c4a1247ee38f9138698e6b2bfc2bc85bc17532 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 14:08:56 +0530 Subject: [PATCH 08/23] Upgraded phpunit version slightly to support PHP8.4 Signed-off-by: manishranjan-adobe --- composer.json | 2 +- composer.lock | 239 ++++++++++++++++++++++++++------------------------ 2 files changed, 125 insertions(+), 116 deletions(-) diff --git a/composer.json b/composer.json index a4c8b5b..46286ba 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ }, "require-dev": { "laminas/laminas-coding-standard": "~2.5.0", - "phpunit/phpunit": "^9.6.13" + "phpunit/phpunit": "^9.6.20" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index ec49f6d..cd0b854 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e9c0660b49aaa1a673f6e6a05c996c07", + "content-hash": "fbd13fd7ec34e3700b8f316897cd86df", "packages": [ { "name": "laminas/laminas-config", @@ -1070,16 +1070,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -1087,11 +1087,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -1117,7 +1118,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -1125,29 +1126,31 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -1155,7 +1158,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1179,26 +1182,27 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -1239,9 +1243,15 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -1340,35 +1350,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -1377,7 +1387,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -1406,7 +1416,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -1414,7 +1424,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1659,45 +1669,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.13", + "version": "9.6.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -1742,7 +1752,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" }, "funding": [ { @@ -1758,20 +1768,20 @@ "type": "tidelift" } ], - "time": "2023-09-19T05:39:22+00:00" + "time": "2024-09-19T10:50:18+00:00" }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -1806,7 +1816,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -1814,7 +1824,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -2003,20 +2013,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -2048,7 +2058,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -2056,20 +2066,20 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -2114,7 +2124,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -2122,7 +2132,7 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", @@ -2189,16 +2199,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -2254,7 +2264,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -2262,20 +2272,20 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.6", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -2318,7 +2328,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -2326,24 +2336,24 @@ "type": "github" } ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -2375,7 +2385,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -2383,7 +2393,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -2562,16 +2572,16 @@ }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -2583,7 +2593,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -2604,8 +2614,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -2613,7 +2622,7 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", @@ -2867,16 +2876,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", - "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -2905,7 +2914,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.2" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -2913,7 +2922,7 @@ "type": "github" } ], - "time": "2023-11-20T00:12:19+00:00" + "time": "2024-03-03T12:36:25+00:00" }, { "name": "webimpress/coding-standard", From 09281fbe78c7816f353c7f2f9b8a5191a1d3fa4c Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 14:11:18 +0530 Subject: [PATCH 09/23] Fix PHP 8.4 deprecation: Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead Signed-off-by: manishranjan-adobe --- test/TestAsset/AccessToken48231.php | 2 +- test/TestAsset/RequestToken48231.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/TestAsset/AccessToken48231.php b/test/TestAsset/AccessToken48231.php index a4315ad..fa38471 100644 --- a/test/TestAsset/AccessToken48231.php +++ b/test/TestAsset/AccessToken48231.php @@ -11,7 +11,7 @@ public function __construct() { } - public function execute(array $params = null) + public function execute(?array $params = null) { $return = new Access(); return $return; diff --git a/test/TestAsset/RequestToken48231.php b/test/TestAsset/RequestToken48231.php index 7201c3f..21c6237 100644 --- a/test/TestAsset/RequestToken48231.php +++ b/test/TestAsset/RequestToken48231.php @@ -11,7 +11,7 @@ public function __construct() { } - public function execute(array $params = null) + public function execute(?array $params = null) { $return = new Request(); return $return; From 79b87c3b749480c16e4650d952ba1f776be55ac4 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 15:13:26 +0530 Subject: [PATCH 10/23] Fixed PHPCS issues Signed-off-by: manishranjan-adobe --- src/Client.php | 52 +++++++------ src/Config/ConfigInterface.php | 26 +++---- src/Config/StandardConfig.php | 91 ++++++++++++---------- src/Consumer.php | 69 +++++++++------- src/Exception/BadMethodCallException.php | 3 +- src/Exception/ExceptionInterface.php | 7 +- src/Exception/InvalidArgumentException.php | 3 +- src/Exception/RuntimeException.php | 3 +- src/Http.php | 64 ++++++++------- src/Http/AccessToken.php | 20 ++--- src/Http/RequestToken.php | 13 ++-- src/Http/UserAuthorization.php | 11 +-- src/Http/Utility.php | 29 ++++--- src/OAuth.php | 26 +++---- src/Signature/AbstractSignature.php | 27 ++++--- src/Signature/Hmac.php | 8 +- src/Signature/Plaintext.php | 11 ++- src/Signature/Rsa.php | 8 +- src/Signature/SignatureInterface.php | 2 + src/Token/AbstractToken.php | 59 +++++++------- src/Token/Access.php | 18 +++-- src/Token/AuthorizedRequest.php | 21 +++-- src/Token/Request.php | 6 +- src/Token/TokenInterface.php | 4 +- 24 files changed, 317 insertions(+), 264 deletions(-) diff --git a/src/Client.php b/src/Client.php index 28d0119..0af8c5d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1,22 +1,27 @@ streamingRequest) { - $this->setHeaders(['Content-Length' => - $this->raw_post_data->getTotalSize()]); + $this->setHeaders([ + 'Content-Length' + => $this->raw_post_data->getTotalSize(), + ]); return $this->raw_post_data; } return parent::prepareBody(); } /** - * Clear all custom parameters we set. + * Clear all custom parameters we set * + * @param bool $clearAll * @return HttpClient */ public function resetParameters($clearAll = false) @@ -140,15 +148,15 @@ public function setRawDataStream($data, $enctype = null) */ public function setMethod($method = HttpRequest::METHOD_GET) { - if ($method == HttpRequest::METHOD_GET) { + if ($method === HttpRequest::METHOD_GET) { $this->setRequestMethod(HttpRequest::METHOD_GET); - } elseif ($method == HttpRequest::METHOD_POST) { + } elseif ($method === HttpRequest::METHOD_POST) { $this->setRequestMethod(HttpRequest::METHOD_POST); - } elseif ($method == HttpRequest::METHOD_PUT) { + } elseif ($method === HttpRequest::METHOD_PUT) { $this->setRequestMethod(HttpRequest::METHOD_PUT); - } elseif ($method == HttpRequest::METHOD_DELETE) { + } elseif ($method === HttpRequest::METHOD_DELETE) { $this->setRequestMethod(HttpRequest::METHOD_DELETE); - } elseif ($method == HttpRequest::METHOD_HEAD) { + } elseif ($method === HttpRequest::METHOD_HEAD) { $this->setRequestMethod(HttpRequest::METHOD_HEAD); } return parent::setMethod($method); @@ -178,7 +186,7 @@ public function send(?HttpRequest $request = null) * @return void * @throws \Laminas\OAuth\Exception\RuntimeException If POSTBODY scheme * requested, but GET request method used; or if invalid request scheme - * provided + * provided. */ public function prepareOAuth() { @@ -190,18 +198,18 @@ public function prepareOAuth() $this->oauthConfig, $this->getSignableParameters() ); - $requestHeaders = $this->getRequest()->getHeaders(); + $requestHeaders = $this->getRequest()->getHeaders(); $requestHeaders->addHeaders(['Authorization' => $oauthHeaderValue]); break; case OAuth::REQUEST_SCHEME_POSTBODY: - if ($this->getRequestMethod() == HttpRequest::METHOD_GET) { + if ($this->getRequestMethod() === HttpRequest::METHOD_GET) { throw new Exception\RuntimeException( 'The client is configured to' . ' pass OAuth parameters through a POST body but request method' . ' is set to GET' ); } - $query = $this->getToken()->toQueryString( + $query = $this->getToken()->toQueryString( $this->getRequest()->getUriString(), $this->oauthConfig, $this->getSignableParameters() @@ -210,7 +218,7 @@ public function prepareOAuth() $this->setRawBody($query); break; case OAuth::REQUEST_SCHEME_QUERYSTRING: - $query = $this->getToken()->toQueryString( + $query = $this->getToken()->toQueryString( $this->getRequest()->getUriString(), $this->oauthConfig, $this->getSignableParameters() @@ -251,7 +259,7 @@ protected function getSignableParameters() * @param string $method * @param array $args * @return mixed - * @throws Exception\BadMethodCallException if method does not exist in config object + * @throws Exception\BadMethodCallException If method does not exist in config object. */ public function __call($method, array $args) { diff --git a/src/Config/ConfigInterface.php b/src/Config/ConfigInterface.php index 92c565d..5ed7434 100644 --- a/src/Config/ConfigInterface.php +++ b/src/Config/ConfigInterface.php @@ -1,54 +1,52 @@ getRequestMethod() == OAuth::GET + if ( + $scheme === OAuth::REQUEST_SCHEME_POSTBODY + && $this->getRequestMethod() === OAuth::GET ) { throw new Exception\InvalidArgumentException( 'Cannot set POSTBODY request method if HTTP method set to GET' @@ -358,7 +371,7 @@ public function getVersion() * * @param string $url Valid URI or Out-Of-Band constant 'oob' * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid URLs + * @throws Exception\InvalidArgumentException For invalid URLs. */ public function setCallbackUrl($url) { @@ -384,7 +397,7 @@ public function getCallbackUrl() * * @param string $url * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid URLs + * @throws Exception\InvalidArgumentException For invalid URLs. */ public function setSiteUrl($url) { @@ -408,7 +421,7 @@ public function getSiteUrl() * * @param string $url * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid URLs + * @throws Exception\InvalidArgumentException For invalid URLs. */ public function setRequestTokenUrl($url) { @@ -438,7 +451,7 @@ public function getRequestTokenUrl() * * @param string $url * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid URLs + * @throws Exception\InvalidArgumentException For invalid URLs. */ public function setAccessTokenUrl($url) { @@ -468,7 +481,7 @@ public function getAccessTokenUrl() * * @param string $url * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid URLs + * @throws Exception\InvalidArgumentException For invalid URLs. */ public function setUserAuthorizationUrl($url) { @@ -480,7 +493,7 @@ public function setUserAuthorizationUrl($url) * * @param string $url * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid URLs + * @throws Exception\InvalidArgumentException For invalid URLs. */ public function setAuthorizeUrl($url) { @@ -520,12 +533,13 @@ public function getAuthorizeUrl() * * @param string $method * @return StandardConfig - * @throws Exception\InvalidArgumentException for invalid request methods + * @throws Exception\InvalidArgumentException For invalid request methods. */ public function setRequestMethod($method) { $method = strtoupper($method); - if (! in_array($method, [ + if ( + ! in_array($method, [ OAuth::GET, OAuth::POST, OAuth::PUT, @@ -551,10 +565,9 @@ public function getRequestMethod() /** * Set RSA public key * - * @param \Laminas\Crypt\PublicKey\Rsa\PublicKey $key * @return StandardConfig */ - public function setRsaPublicKey(\Laminas\Crypt\PublicKey\Rsa\PublicKey $key) + public function setRsaPublicKey(PublicKey $key) { $this->rsaPublicKey = $key; return $this; @@ -563,7 +576,7 @@ public function setRsaPublicKey(\Laminas\Crypt\PublicKey\Rsa\PublicKey $key) /** * Get RSA public key * - * @return \Laminas\Crypt\PublicKey\Rsa\PublicKey + * @return PublicKey */ public function getRsaPublicKey() { @@ -573,10 +586,9 @@ public function getRsaPublicKey() /** * Set RSA private key * - * @param \Laminas\Crypt\PublicKey\Rsa\PrivateKey $key * @return StandardConfig */ - public function setRsaPrivateKey(\Laminas\Crypt\PublicKey\Rsa\PrivateKey $key) + public function setRsaPrivateKey(PrivateKey $key) { $this->rsaPrivateKey = $key; return $this; @@ -585,7 +597,7 @@ public function setRsaPrivateKey(\Laminas\Crypt\PublicKey\Rsa\PrivateKey $key) /** * Get RSA private key * - * @return \Laminas\Crypt\PublicKey\Rsa\PrivateKey + * @return PrivateKey */ public function getRsaPrivateKey() { @@ -595,7 +607,6 @@ public function getRsaPrivateKey() /** * Set OAuth token * - * @param TokenInterface $token * @return StandardConfig */ public function setToken(TokenInterface $token) diff --git a/src/Consumer.php b/src/Consumer.php index afa0339..3d511f1 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -1,36 +1,46 @@ config = new Config\StandardConfig; + $this->config = new Config\StandardConfig(); if ($options !== null) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); @@ -61,7 +71,7 @@ public function __construct($options = null) */ public function getRequestToken( ?array $customServiceParameters = null, - $httpMethod = null, + $httpMethod = null, ?Http\RequestToken $request = null ) { if ($request === null) { @@ -131,18 +141,17 @@ public function redirect( * Retrieve an Access Token in exchange for a previously received/authorized * Request Token. * - * @param array $queryData GET data returned in user's redirect from Provider - * @param \Laminas\OAuth\Token\Request Request Token information - * @param string $httpMethod - * @param \Laminas\OAuth\Http\AccessToken $request - * @return \Laminas\OAuth\Token\Access - * @throws Exception\InvalidArgumentException on invalid authorization + * @param array $queryData GET data returned in user's redirect from Provider + * @param Request $token Request Token information + * @param string $httpMethod + * @return Access + * @throws Exception\InvalidArgumentException On invalid authorization * token, non-matching response authorization token, or unprovided - * authorization token + * authorization token. */ public function getAccessToken( $queryData, - Token\Request $token, + Request $token, $httpMethod = null, ?Http\AccessToken $request = null ) { @@ -153,13 +162,13 @@ public function getAccessToken( ); } if ($request === null) { - $request = new Http\AccessToken($this); + $request = new AccessToken($this); } // OAuth 1.0a Verifier if ($authorizedToken->getParam('oauth_verifier') !== null) { $params = array_merge($request->getParameters(), [ - 'oauth_verifier' => $authorizedToken->getParam('oauth_verifier') + 'oauth_verifier' => $authorizedToken->getParam('oauth_verifier'), ]); $request->setParameters($params); } @@ -179,7 +188,7 @@ public function getAccessToken( throw new Exception\InvalidArgumentException('Request token must be passed to method'); } $this->requestToken = $token; - $this->accessToken = $request->execute(); + $this->accessToken = $request->execute(); return $this->accessToken; } @@ -187,7 +196,7 @@ public function getAccessToken( * Return whatever the last Request Token retrieved was while using the * current Consumer instance. * - * @return \Laminas\OAuth\Token\Request + * @return Request */ public function getLastRequestToken() { @@ -198,7 +207,7 @@ public function getLastRequestToken() * Return whatever the last Access Token retrieved was while using the * current Consumer instance. * - * @return \Laminas\OAuth\Token\Access + * @return Access */ public function getLastAccessToken() { @@ -208,7 +217,7 @@ public function getLastAccessToken() /** * Alias to self::getLastAccessToken() * - * @return \Laminas\OAuth\Token\Access + * @return Access */ public function getToken() { @@ -223,12 +232,12 @@ public function getToken() * @param string $method * @param array $args * @return mixed - * @throws Exception\BadMethodCallException if method does not exist in config object + * @throws Exception\BadMethodCallException If method does not exist in config object. */ public function __call($method, array $args) { if (! method_exists($this->config, $method)) { - throw new Exception\BadMethodCallException('Method does not exist: '.$method); + throw new Exception\BadMethodCallException('Method does not exist: ' . $method); } return call_user_func_array([$this->config, $method], $args); } diff --git a/src/Exception/BadMethodCallException.php b/src/Exception/BadMethodCallException.php index 340e19a..c488a1e 100644 --- a/src/Exception/BadMethodCallException.php +++ b/src/Exception/BadMethodCallException.php @@ -1,8 +1,9 @@ consumer = $consumer; + $this->consumer = $consumer; $this->preferredRequestScheme = $this->consumer->getRequestScheme(); if ($parameters !== null) { $this->setParameters($parameters); @@ -67,7 +76,7 @@ public function __construct( if ($utility !== null) { $this->httpUtility = $utility; } else { - $this->httpUtility = new Http\Utility; + $this->httpUtility = new Utility(); } } @@ -138,8 +147,8 @@ public function getConsumer() * * @todo Remove cycling?; Replace with upfront do-or-die configuration * @param array $params - * @return \Laminas\Http\Response - * @throws Exception\InvalidArgumentException on HTTP request errors + * @return Response + * @throws Exception\InvalidArgumentException On HTTP request errors. */ public function startRequestCycle(array $params) { @@ -148,7 +157,7 @@ public function startRequestCycle(array $params) $status = null; try { $response = $this->attemptRequest($params); - } catch (\Laminas\Http\Client\Exception\ExceptionInterface $e) { + } catch (ExceptionInterface $e) { throw new Exception\InvalidArgumentException(sprintf( 'Error in HTTP request: %s', $e->getMessage() @@ -158,10 +167,11 @@ public function startRequestCycle(array $params) $body = $response->getBody(); $status = $response->getStatusCode(); } - if ($response === null // Request failure/exception - || $status == 500 // Internal Server Error - || $status == 400 // Bad Request - || $status == 401 // Unauthorized + if ( + $response === null // Request failure/exception + || $status === 500 // Internal Server Error + || $status === 400 // Bad Request + || $status === 401 // Unauthorized || empty($body) // Missing token ) { $this->assessRequestAttempt($response); @@ -176,7 +186,7 @@ public function startRequestCycle(array $params) * * @param array $params * @param string $url - * @return \Laminas\Http\Client + * @return Client */ public function getRequestSchemeQueryStringClient(array $params, $url) { @@ -193,11 +203,11 @@ public function getRequestSchemeQueryStringClient(array $params, $url) * Manages the switch from OAuth request scheme to another lower preference * scheme during a request cycle. * - * @param Laminas\Http\Response + * @param Laminas\Http\Response $response * @return void - * @throws Exception\RuntimeException if unable to retrieve valid token response + * @throws Exception\RuntimeException If unable to retrieve valid token response. */ - protected function assessRequestAttempt(?\Laminas\Http\Response $response = null) + protected function assessRequestAttempt(?Response $response = null) { switch ($this->preferredRequestScheme) { case OAuth::REQUEST_SCHEME_HEADER: @@ -226,15 +236,15 @@ protected function assessRequestAttempt(?\Laminas\Http\Response $response = null */ protected function toAuthorizationHeader(array $params, $realm = null) { - $headerValue = []; + $headerValue = []; $headerValue[] = 'OAuth realm="' . $realm . '"'; foreach ($params as $key => $value) { if (! preg_match("/^oauth_/", $key)) { continue; } - $headerValue[] = Http\Utility::urlEncode($key) + $headerValue[] = Utility::urlEncode($key) . '="' - . Http\Utility::urlEncode($value) + . Utility::urlEncode($value) . '"'; } return implode(",", $headerValue); @@ -245,7 +255,7 @@ protected function toAuthorizationHeader(array $params, $realm = null) * return the resulting HTTP Response. * * @param array $params - * @return \Laminas\Http\Response + * @return Response */ protected function attemptRequest(array $params) { diff --git a/src/Http/AccessToken.php b/src/Http/AccessToken.php index a861b3f..241be72 100644 --- a/src/Http/AccessToken.php +++ b/src/Http/AccessToken.php @@ -1,36 +1,38 @@ assembleParams(); $response = $this->startRequestCycle($params); - $return = new Token\Access($response); - return $return; + return new Token\Access($response); } /** diff --git a/src/Http/RequestToken.php b/src/Http/RequestToken.php index f1a16f8..6c48553 100644 --- a/src/Http/RequestToken.php +++ b/src/Http/RequestToken.php @@ -1,5 +1,7 @@ assembleParams(); $response = $this->startRequestCycle($params); - $return = new Token\Request($response); - return $return; + return new Token\Request($response); } /** diff --git a/src/Http/UserAuthorization.php b/src/Http/UserAuthorization.php index 89a1e1a..376407e 100644 --- a/src/Http/UserAuthorization.php +++ b/src/Http/UserAuthorization.php @@ -1,14 +1,15 @@ $this->consumer->getLastRequestToken()->getToken(), ]; - if (! \Laminas\OAuth\Client::$supportsRevisionA) { + if (! Client::$supportsRevisionA) { $callback = $this->consumer->getCallbackUrl(); if (! empty($callback)) { $params['oauth_callback'] = $callback; diff --git a/src/Http/Utility.php b/src/Http/Utility.php index a2ce82d..ec7be74 100644 --- a/src/Http/Utility.php +++ b/src/Http/Utility.php @@ -1,13 +1,26 @@ $config->getVersion(), ]; - if ($config->getToken()->getToken() != null) { + if ($config->getToken()->getToken() !== null) { $params['oauth_token'] = $config->getToken()->getToken(); } - if ($serviceProviderParams !== null) { $params = array_merge($params, $serviceProviderParams); } @@ -86,7 +97,7 @@ public function toEncodedQueryString(array $params, $customParamsOnly = false) * @param array $params * @param null|string $realm * @param bool $excludeCustomParams - * @return void + * @return string */ public function toAuthorizationHeader(array $params, $realm = null, $excludeCustomParams = true) { @@ -157,7 +168,7 @@ public function parseQueryString($query) // periods and uses urldecode, not rawurldecode. $parts = explode('&', $query); foreach ($parts as $pair) { - $kv = explode('=', $pair); + $kv = explode('=', $pair); $params[rawurldecode($kv[0])] = rawurldecode($kv[1]); } return $params; diff --git a/src/OAuth.php b/src/OAuth.php index c75f5ff..db65792 100644 --- a/src/OAuth.php +++ b/src/OAuth.php @@ -1,30 +1,28 @@ getRequest(); $headers = $request->getHeaders(); diff --git a/src/Signature/AbstractSignature.php b/src/Signature/AbstractSignature.php index 94fb24f..41b798a 100644 --- a/src/Signature/AbstractSignature.php +++ b/src/Signature/AbstractSignature.php @@ -1,37 +1,46 @@ normalize(); - if ($uri->getScheme() == 'http' && $uri->getPort() == '80') { + if ($uri->getScheme() === 'http' && $uri->getPort() === '80') { $uri->setPort(''); - } elseif ($uri->getScheme() == 'https' && $uri->getPort() == '443') { + } elseif ($uri->getScheme() === 'https' && $uri->getPort() === '443') { $uri->setPort(''); } elseif (! in_array($uri->getScheme(), ['http', 'https'])) { throw new Exception\InvalidArgumentException('Invalid URL provided; must be an HTTP or HTTPS scheme'); diff --git a/src/Signature/Hmac.php b/src/Signature/Hmac.php index 9324c74..856109b 100644 --- a/src/Signature/Hmac.php +++ b/src/Signature/Hmac.php @@ -1,13 +1,13 @@ tokenSecret === null) { return $this->consumerSecret . '&'; } - $return = implode('&', [$this->consumerSecret, $this->tokenSecret]); - return $return; + return implode('&', [$this->consumerSecret, $this->tokenSecret]); } } diff --git a/src/Signature/Rsa.php b/src/Signature/Rsa.php index 270fdec..eb712b0 100644 --- a/src/Signature/Rsa.php +++ b/src/Signature/Rsa.php @@ -1,14 +1,12 @@ $this->hashAlgorithm, - 'binary_output' => true + 'binary_output' => true, ])); return $rsa->sign($this->getBaseSignatureString($params, $method, $url), $this->key); diff --git a/src/Signature/SignatureInterface.php b/src/Signature/SignatureInterface.php index 9cf5c40..3aa2727 100644 --- a/src/Signature/SignatureInterface.php +++ b/src/Signature/SignatureInterface.php @@ -1,5 +1,7 @@ response = $response; - $params = $this->parseParameters($response); + $params = $this->parseParameters($response); if (count($params) > 0) { $this->setParams($params); } @@ -59,7 +58,7 @@ public function __construct( if ($utility !== null) { $this->httpUtility = $utility; } else { - $this->httpUtility = new HTTPUtility; + $this->httpUtility = new HTTPUtility(); } } @@ -71,7 +70,8 @@ public function __construct( */ public function isValid() { - if (isset($this->params[self::TOKEN_PARAM_KEY]) + if ( + isset($this->params[self::TOKEN_PARAM_KEY]) && ! empty($this->params[self::TOKEN_PARAM_KEY]) && isset($this->params[self::TOKEN_SECRET_PARAM_KEY]) ) { @@ -83,7 +83,7 @@ public function isValid() /** * Return the HTTP response object used to initialise this instance. * - * @return \Laminas\Http\Response + * @return HTTPResponse */ public function getResponse() { @@ -95,7 +95,7 @@ public function getResponse() * requests with this Token. * * @param string $secret - * @return \Laminas\OAuth\Token\AbstractToken + * @return AbstractToken */ public function setTokenSecret($secret) { @@ -120,7 +120,7 @@ public function getTokenSecret() * * @param string $key * @param string $value - * @return \Laminas\OAuth\Token\AbstractToken + * @return AbstractToken */ public function setParam($key, $value) { @@ -133,7 +133,7 @@ public function setParam($key, $value) * a simple filter to remove any trailing newlines. * * @param array $params - * @return \Laminas\OAuth\Token\AbstractToken + * @return AbstractToken */ public function setParams(array $params) { @@ -161,7 +161,7 @@ public function getParam($key) * Sets the value for a Token. * * @param string $token - * @return \Laminas\OAuth\Token\AbstractToken + * @return AbstractToken */ public function setToken($token) { @@ -181,10 +181,8 @@ public function getToken() /** * Generic accessor to enable access as public properties. - * - * @return string */ - public function __get($key) + public function __get(string $key): mixed { return $this->getParam($key); } @@ -226,7 +224,6 @@ public function __toString() * Parse a HTTP response body and collect returned parameters * as raw url decoded key-value pairs in an associative array. * - * @param \Laminas\Http\Response $response * @return array */ protected function parseParameters(HTTPResponse $response) @@ -240,7 +237,7 @@ protected function parseParameters(HTTPResponse $response) // validate body based on acceptable characters...todo $parts = explode('&', $body); foreach ($parts as $kvpair) { - $pair = explode('=', $kvpair); + $pair = explode('=', $kvpair); $params[rawurldecode($pair[0])] = rawurldecode($pair[1]); } return $params; @@ -248,8 +245,10 @@ protected function parseParameters(HTTPResponse $response) /** * Limit serialisation stored data to the parameters + * + * @return array */ - public function __sleep() + public function __sleep(): array { return ['_params']; } @@ -260,7 +259,7 @@ public function __sleep() public function __wakeup() { if ($this->httpUtility === null) { - $this->httpUtility = new HTTPUtility; + $this->httpUtility = new HTTPUtility(); } } } diff --git a/src/Token/Access.php b/src/Token/Access.php index 4e8b10e..abfd0e4 100644 --- a/src/Token/Access.php +++ b/src/Token/Access.php @@ -1,23 +1,23 @@ isValid() + if ( + ! $uri->isValid() || ! in_array($uri->getScheme(), ['http', 'https']) ) { throw new Exception\InvalidArgumentException( @@ -53,7 +54,8 @@ public function toHeader( public function toQueryString($url, Config $config, ?array $params = null) { $uri = Uri\UriFactory::factory($url); - if (! $uri->isValid() + if ( + ! $uri->isValid() || ! in_array($uri->getScheme(), ['http', 'https']) ) { throw new Exception\InvalidArgumentException( @@ -69,7 +71,7 @@ public function toQueryString($url, Config $config, ?array $params = null) * * @param array $oauthOptions * @param null|string $uri - * @param null|array|\Traversable $config + * @param null|array|Traversable $config * @param bool $excludeCustomParamsFromHeader * @return Client */ diff --git a/src/Token/AuthorizedRequest.php b/src/Token/AuthorizedRequest.php index 80711d1..ac4f4a6 100644 --- a/src/Token/AuthorizedRequest.php +++ b/src/Token/AuthorizedRequest.php @@ -1,32 +1,30 @@ data = $data; - $params = $this->parseData(); + $params = $this->parseData(); if (count($params) > 0) { $this->setParams($params); } @@ -34,7 +32,7 @@ public function __construct(?array $data = null, ?Http\Utility $utility = null) if ($utility !== null) { $this->httpUtility = $utility; } else { - $this->httpUtility = new Http\Utility; + $this->httpUtility = new Http\Utility(); } } @@ -55,7 +53,8 @@ public function getData() */ public function isValid() { - if (isset($this->params[self::TOKEN_PARAM_KEY]) + if ( + isset($this->params[self::TOKEN_PARAM_KEY]) && ! empty($this->params[self::TOKEN_PARAM_KEY]) ) { return true; diff --git a/src/Token/Request.php b/src/Token/Request.php index 3bba4ef..adb6f7d 100644 --- a/src/Token/Request.php +++ b/src/Token/Request.php @@ -1,15 +1,13 @@ Date: Tue, 22 Oct 2024 15:26:44 +0530 Subject: [PATCH 11/23] Fixed PHPCS issues Signed-off-by: manishranjan-adobe --- test/Config/StandardConfigurationTest.php | 4 +- test/ConsumerTest.php | 102 ++++++++------- test/Http/AccessTokenTest.php | 125 +++++++++--------- test/Http/RequestTokenTest.php | 147 +++++++++++----------- test/Http/UserAuthorizationTest.php | 12 +- test/Http/UtilityTest.php | 4 + test/OAuthTest.php | 17 +-- test/Signature/AbstractTest.php | 14 ++- test/Signature/HMACTest.php | 26 ++-- test/Signature/PlaintextTest.php | 26 ++-- test/Signature/RSATest.php | 2 + test/TestAsset/AccessToken48231.php | 5 +- test/TestAsset/Config90244.php | 2 + test/TestAsset/Consumer32874.php | 2 + test/TestAsset/Consumer32874b.php | 2 + test/TestAsset/Consumer34879.php | 5 +- test/TestAsset/Consumer39745.php | 5 +- test/TestAsset/Consumer48231.php | 2 + test/TestAsset/HTTPClient19485876.php | 2 + test/TestAsset/HTTPClient32874.php | 2 + test/TestAsset/HTTPClient39745.php | 2 + test/TestAsset/HTTPUtility32874.php | 4 + test/TestAsset/HTTPUtility39745.php | 4 + test/TestAsset/HTTPUtility90244.php | 4 + test/TestAsset/RequestToken39745.php | 2 + test/TestAsset/RequestToken48231.php | 5 +- test/TestAsset/Token34879.php | 2 + test/Token/AccessTest.php | 30 ++--- test/Token/AuthorizedRequestTest.php | 24 ++-- test/Token/RequestTest.php | 26 ++-- 30 files changed, 339 insertions(+), 270 deletions(-) diff --git a/test/Config/StandardConfigurationTest.php b/test/Config/StandardConfigurationTest.php index a726143..dbc807a 100644 --- a/test/Config/StandardConfigurationTest.php +++ b/test/Config/StandardConfigurationTest.php @@ -1,5 +1,7 @@ 'https://example.com/oauth/' + 'siteUrl' => 'https://example.com/oauth/', ] ); $this->assertEquals('https://example.com/oauth/authorize', $config->getAuthorizeUrl()); diff --git a/test/ConsumerTest.php b/test/ConsumerTest.php index d1cfe2c..ced8999 100644 --- a/test/ConsumerTest.php +++ b/test/ConsumerTest.php @@ -1,11 +1,16 @@ '1234567890']; + $config = ['consumerKey' => '1234567890']; $consumer = new Consumer($config); $this->assertEquals('1234567890', $consumer->getConsumerKey()); } public function testConstructorSetsConsumerSecret() { - $config = ['consumerSecret' => '0987654321']; + $config = ['consumerSecret' => '0987654321']; $consumer = new Consumer($config); $this->assertEquals('0987654321', $consumer->getConsumerSecret()); } public function testSetsSignatureMethodFromOptionsArray() { - $options = [ - 'signatureMethod' => 'rsa-sha1' + $options = [ + 'signatureMethod' => 'rsa-sha1', ]; $consumer = new Consumer($options); $this->assertEquals('RSA-SHA1', $consumer->getSignatureMethod()); @@ -43,8 +48,8 @@ public function testSetsSignatureMethodFromOptionsArray() public function testSetsRequestMethodFromOptionsArray() // add back { - $options = [ - 'requestMethod' => OAuth::GET + $options = [ + 'requestMethod' => OAuth::GET, ]; $consumer = new Consumer($options); $this->assertEquals(OAuth::GET, $consumer->getRequestMethod()); @@ -52,8 +57,8 @@ public function testSetsRequestMethodFromOptionsArray() // add back public function testSetsRequestSchemeFromOptionsArray() { - $options = [ - 'requestScheme' => OAuth::REQUEST_SCHEME_POSTBODY + $options = [ + 'requestScheme' => OAuth::REQUEST_SCHEME_POSTBODY, ]; $consumer = new Consumer($options); $this->assertEquals(OAuth::REQUEST_SCHEME_POSTBODY, $consumer->getRequestScheme()); @@ -61,8 +66,8 @@ public function testSetsRequestSchemeFromOptionsArray() public function testSetsVersionFromOptionsArray() { - $options = [ - 'version' => '1.1' + $options = [ + 'version' => '1.1', ]; $consumer = new Consumer($options); $this->assertEquals('1.1', $consumer->getVersion()); @@ -70,8 +75,8 @@ public function testSetsVersionFromOptionsArray() public function testSetsCallbackUrlFromOptionsArray() { - $options = [ - 'callbackUrl' => 'http://www.example.com/local' + $options = [ + 'callbackUrl' => 'http://www.example.com/local', ]; $consumer = new Consumer($options); $this->assertEquals('http://www.example.com/local', $consumer->getCallbackUrl()); @@ -79,8 +84,8 @@ public function testSetsCallbackUrlFromOptionsArray() public function testSetsRequestTokenUrlFromOptionsArray() { - $options = [ - 'requestTokenUrl' => 'http://www.example.com/request' + $options = [ + 'requestTokenUrl' => 'http://www.example.com/request', ]; $consumer = new Consumer($options); $this->assertEquals('http://www.example.com/request', $consumer->getRequestTokenUrl()); @@ -88,8 +93,8 @@ public function testSetsRequestTokenUrlFromOptionsArray() public function testSetsUserAuthorizationUrlFromOptionsArray() { - $options = [ - 'userAuthorizationUrl' => 'http://www.example.com/authorize' + $options = [ + 'userAuthorizationUrl' => 'http://www.example.com/authorize', ]; $consumer = new Consumer($options); $this->assertEquals('http://www.example.com/authorize', $consumer->getUserAuthorizationUrl()); @@ -97,8 +102,8 @@ public function testSetsUserAuthorizationUrlFromOptionsArray() public function testSetsAccessTokenUrlFromOptionsArray() { - $options = [ - 'accessTokenUrl' => 'http://www.example.com/access' + $options = [ + 'accessTokenUrl' => 'http://www.example.com/access', ]; $consumer = new Consumer($options); $this->assertEquals('http://www.example.com/access', $consumer->getAccessTokenUrl()); @@ -106,83 +111,86 @@ public function testSetsAccessTokenUrlFromOptionsArray() public function testSetSignatureMethodThrowsExceptionForInvalidMethod() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setSignatureMethod('buckyball'); } public function testSetRequestMethodThrowsExceptionForInvalidMethod() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setRequestMethod('buckyball'); } public function testSetRequestSchemeThrowsExceptionForInvalidMethod() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setRequestScheme('buckyball'); } public function testSetLocalUrlThrowsExceptionForInvalidUrl() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setLocalUrl('buckyball'); } public function testSetRequestTokenUrlThrowsExceptionForInvalidUrl() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setRequestTokenUrl('buckyball'); } public function testSetUserAuthorizationUrlThrowsExceptionForInvalidUrl() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setUserAuthorizationUrl('buckyball'); } public function testSetAccessTokenUrlThrowsExceptionForInvalidUrl() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $this->expectException('Laminas\OAuth\Exception\ExceptionInterface'); + $this->expectException(ExceptionInterface::class); $consumer->setAccessTokenUrl('buckyball'); } public function testGetRequestTokenReturnsInstanceOfOauthTokenRequest() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $token = $consumer->getRequestToken(null, null, new RequestToken48231()); - $this->assertInstanceOf('Laminas\OAuth\Token\Request', $token); + $token = $consumer->getRequestToken(null, null, new RequestToken48231()); + $this->assertInstanceOf(Request::class, $token); } public function testGetRedirectUrlReturnsUserAuthorizationUrlWithParameters() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321', - 'userAuthorizationUrl' => 'http://www.example.com/authorize']; + $config = [ + 'consumerKey' => '12345', + 'consumerSecret' => '54321', + 'userAuthorizationUrl' => 'http://www.example.com/authorize', + ]; $consumer = new Consumer48231($config); - $params = ['foo' => 'bar']; - $uauth = new Http\UserAuthorization($consumer, $params); - $token = new Token\Request; + $params = ['foo' => 'bar']; + $uauth = new Http\UserAuthorization($consumer, $params); + $token = new Token\Request(); $token->setParams(['oauth_token' => '123456', 'oauth_token_secret' => '654321']); $redirectUrl = $consumer->getRedirectUrl($params, $token, $uauth); $this->assertEquals( @@ -194,25 +202,25 @@ public function testGetRedirectUrlReturnsUserAuthorizationUrlWithParameters() public function testGetAccessTokenReturnsInstanceOfOauthTokenAccess() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer($config); - $rtoken = new Token\Request; + $rtoken = new Token\Request(); $rtoken->setToken('token'); $token = $consumer->getAccessToken(['oauth_token' => 'token'], $rtoken, null, new AccessToken48231()); - $this->assertInstanceOf('Laminas\OAuth\Token\Access', $token); + $this->assertInstanceOf(Access::class, $token); } public function testGetLastRequestTokenReturnsInstanceWhenExists() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer48231($config); - $this->assertInstanceOf('Laminas\OAuth\Token\Request', $consumer->getLastRequestToken()); + $this->assertInstanceOf(Request::class, $consumer->getLastRequestToken()); } public function testGetLastAccessTokenReturnsInstanceWhenExists() { - $config = ['consumerKey' => '12345','consumerSecret' => '54321']; + $config = ['consumerKey' => '12345', 'consumerSecret' => '54321']; $consumer = new Consumer48231($config); - $this->assertInstanceOf('Laminas\OAuth\Token\Access', $consumer->getLastAccessToken()); + $this->assertInstanceOf(Access::class, $consumer->getLastAccessToken()); } } diff --git a/test/Http/AccessTokenTest.php b/test/Http/AccessTokenTest.php index 3267ba6..076e46c 100644 --- a/test/Http/AccessTokenTest.php +++ b/test/Http/AccessTokenTest.php @@ -1,5 +1,7 @@ stubConsumer = new Consumer39745(); + $this->stubConsumer = new Consumer39745(); $this->stubHttpUtility = new HTTPUtility39745(); OAuth::setHttpClient(new HTTPClient39745()); } @@ -34,40 +36,41 @@ public function testConstructorSetsConsumerInstance() public function testConstructorSetsCustomServiceParameters() { - $request = new Http\AccessToken($this->stubConsumer, [1,2,3], $this->stubHttpUtility); - $this->assertEquals([1,2,3], $request->getParameters()); + $request = new Http\AccessToken($this->stubConsumer, [1, 2, 3], $this->stubHttpUtility); + $this->assertEquals([1, 2, 3], $request->getParameters()); } public function testAssembleParametersCorrectlyAggregatesOauthParameters() { - $request = new Http\AccessToken($this->stubConsumer, null, $this->stubHttpUtility); + $request = new Http\AccessToken($this->stubConsumer, null, $this->stubHttpUtility); $expectedParams = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_token' => '0987654321', - 'oauth_version' => '1.0', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c' + 'oauth_timestamp' => '12345678901', + 'oauth_token' => '0987654321', + 'oauth_version' => '1.0', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', ]; $this->assertEquals($expectedParams, $request->assembleParams()); } + public function testAssembleParametersCorrectlyIgnoresCustomParameters() { - $request = new Http\AccessToken($this->stubConsumer, [ + $request = new Http\AccessToken($this->stubConsumer, [ 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'custom_param2' => 'bar', ], $this->stubHttpUtility); $expectedParams = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_token' => '0987654321', - 'oauth_version' => '1.0', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c' + 'oauth_timestamp' => '12345678901', + 'oauth_token' => '0987654321', + 'oauth_version' => '1.0', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', ]; $this->assertEquals($expectedParams, $request->assembleParams()); } @@ -75,23 +78,23 @@ public function testAssembleParametersCorrectlyIgnoresCustomParameters() public function testGetRequestSchemeHeaderClientSetsCorrectlyEncodedAuthorizationHeader() { $request = new Http\AccessToken($this->stubConsumer, null, $this->stubHttpUtility); - $params = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + $params = [ + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_token' => '0987654321', - 'oauth_version' => '1.0', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'oauth_timestamp' => '12345678901', + 'oauth_token' => '0987654321', + 'oauth_version' => '1.0', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', ]; - $client = $request->getRequestSchemeHeaderClient($params); + $client = $request->getRequestSchemeHeaderClient($params); $this->assertEquals( 'OAuth realm="",oauth_consumer_key="1234567890",oauth_nonce="e807f1fcf82d132f9b' - .'b018ca6738a19f",oauth_signature_method="HMAC-SHA1",oauth_timestamp="' - .'12345678901",oauth_token="0987654321",oauth_version="1.0",oauth_sign' - .'ature="6fb42da0e32e07b61c9f0251fe627a9c~"', + . 'b018ca6738a19f",oauth_signature_method="HMAC-SHA1",oauth_timestamp="' + . '12345678901",oauth_token="0987654321",oauth_version="1.0",oauth_sign' + . 'ature="6fb42da0e32e07b61c9f0251fe627a9c~"', $client->getHeader('Authorization') ); } @@ -99,23 +102,23 @@ public function testGetRequestSchemeHeaderClientSetsCorrectlyEncodedAuthorizatio public function testGetRequestSchemePostBodyClientSetsCorrectlyEncodedRawData() { $request = new Http\AccessToken($this->stubConsumer, null, $this->stubHttpUtility); - $params = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + $params = [ + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_token' => '0987654321', - 'oauth_version' => '1.0', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'oauth_timestamp' => '12345678901', + 'oauth_token' => '0987654321', + 'oauth_version' => '1.0', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', ]; - $client = $request->getRequestSchemePostBodyClient($params); + $client = $request->getRequestSchemePostBodyClient($params); $this->assertEquals( 'oauth_consumer_key=1234567890&oauth_nonce=e807f1fcf82d132f9bb018c' - .'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' - .'678901&oauth_token=0987654321&oauth_version=1.0&oauth_signature=' - .'6fb42da0e32e07b61c9f0251fe627a9c~', + . 'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' + . '678901&oauth_token=0987654321&oauth_version=1.0&oauth_signature=' + . '6fb42da0e32e07b61c9f0251fe627a9c~', //$client->getRawData() $client->getRequest()->getContent() ); @@ -124,23 +127,23 @@ public function testGetRequestSchemePostBodyClientSetsCorrectlyEncodedRawData() public function testGetRequestSchemeQueryStringClientSetsCorrectlyEncodedQueryString() { $request = new Http\AccessToken($this->stubConsumer, null, $this->stubHttpUtility); - $params = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + $params = [ + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_token' => '0987654321', - 'oauth_version' => '1.0', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'oauth_timestamp' => '12345678901', + 'oauth_token' => '0987654321', + 'oauth_version' => '1.0', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', ]; - $client = $request->getRequestSchemeQueryStringClient($params, 'http://www.example.com'); + $client = $request->getRequestSchemeQueryStringClient($params, 'http://www.example.com'); $this->assertEquals( 'oauth_consumer_key=1234567890&oauth_nonce=e807f1fcf82d132f9bb018c' - .'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' - .'678901&oauth_token=0987654321&oauth_version=1.0&oauth_signature=' - .'6fb42da0e32e07b61c9f0251fe627a9c', + . 'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' + . '678901&oauth_token=0987654321&oauth_version=1.0&oauth_signature=' + . '6fb42da0e32e07b61c9f0251fe627a9c', $client->getUri()->getQuery() ); } diff --git a/test/Http/RequestTokenTest.php b/test/Http/RequestTokenTest.php index ff0b253..1895e70 100644 --- a/test/Http/RequestTokenTest.php +++ b/test/Http/RequestTokenTest.php @@ -1,5 +1,7 @@ stubConsumer = new Consumer32874(); - $this->stubConsumer2 = new Consumer32874b(); + $this->stubConsumer = new Consumer32874(); + $this->stubConsumer2 = new Consumer32874b(); $this->stubHttpUtility = new HTTPUtility32874(); OAuth::setHttpClient(new HTTPClient32874()); } @@ -37,57 +39,56 @@ public function testConstructorSetsConsumerInstance() public function testConstructorSetsCustomServiceParameters() { - $request = new Http\RequestToken($this->stubConsumer, [1,2,3], $this->stubHttpUtility); - $this->assertEquals([1,2,3], $request->getParameters()); + $request = new Http\RequestToken($this->stubConsumer, [1, 2, 3], $this->stubHttpUtility); + $this->assertEquals([1, 2, 3], $request->getParameters()); } public function testAssembleParametersCorrectlyAggregatesOauthParameters() { - $request = new Http\RequestToken($this->stubConsumer, null, $this->stubHttpUtility); + $request = new Http\RequestToken($this->stubConsumer, null, $this->stubHttpUtility); $expectedParams = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', - 'oauth_timestamp' => '12345678901', + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + 'oauth_timestamp' => '12345678901', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_version' => '1.0', - 'oauth_callback' => 'http://www.example.com/local', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c' + 'oauth_version' => '1.0', + 'oauth_callback' => 'http://www.example.com/local', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', ]; $this->assertEquals($expectedParams, $request->assembleParams()); } public function testAssembleParametersCorrectlyAggregatesOauthParametersIfCallbackUrlMissing() { - $request = new Http\RequestToken($this->stubConsumer2, null, $this->stubHttpUtility); + $request = new Http\RequestToken($this->stubConsumer2, null, $this->stubHttpUtility); $expectedParams = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', - 'oauth_timestamp' => '12345678901', + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + 'oauth_timestamp' => '12345678901', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_version' => '1.0', - 'oauth_callback' => 'oob', // out-of-band when missing callback - 1.0a - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c' - + 'oauth_version' => '1.0', + 'oauth_callback' => 'oob', // out-of-band when missing callback - 1.0a + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', ]; $this->assertEquals($expectedParams, $request->assembleParams()); } public function testAssembleParametersCorrectlyAggregatesCustomParameters() { - $request = new Http\RequestToken($this->stubConsumer, [ + $request = new Http\RequestToken($this->stubConsumer, [ 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'custom_param2' => 'bar', ], $this->stubHttpUtility); $expectedParams = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', - 'oauth_timestamp' => '12345678901', + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + 'oauth_timestamp' => '12345678901', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_version' => '1.0', - 'oauth_callback' => 'http://www.example.com/local', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c' + 'oauth_version' => '1.0', + 'oauth_callback' => 'http://www.example.com/local', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', ]; $this->assertEquals($expectedParams, $request->assembleParams()); } @@ -95,23 +96,23 @@ public function testAssembleParametersCorrectlyAggregatesCustomParameters() public function testGetRequestSchemeHeaderClientSetsCorrectlyEncodedAuthorizationHeader() { $request = new Http\RequestToken($this->stubConsumer, null, $this->stubHttpUtility); - $params = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + $params = [ + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_version' => '1.0', - 'oauth_callback_url' => 'http://www.example.com/local', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'oauth_timestamp' => '12345678901', + 'oauth_version' => '1.0', + 'oauth_callback_url' => 'http://www.example.com/local', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', ]; - $client = $request->getRequestSchemeHeaderClient($params); + $client = $request->getRequestSchemeHeaderClient($params); $this->assertEquals( 'OAuth realm="",oauth_consumer_key="1234567890",oauth_nonce="e807f1fcf82d132f9b' - .'b018ca6738a19f",oauth_signature_method="HMAC-SHA1",oauth_timestamp="' - .'12345678901",oauth_version="1.0",oauth_callback_url=' - .'"http%3A%2F%2Fwww.example.com%2Flocal",oauth_signature="6fb42da0e32e07b61c9f0251fe627a9c~"', + . 'b018ca6738a19f",oauth_signature_method="HMAC-SHA1",oauth_timestamp="' + . '12345678901",oauth_version="1.0",oauth_callback_url=' + . '"http%3A%2F%2Fwww.example.com%2Flocal",oauth_signature="6fb42da0e32e07b61c9f0251fe627a9c~"', $client->getHeader('Authorization') ); } @@ -119,24 +120,24 @@ public function testGetRequestSchemeHeaderClientSetsCorrectlyEncodedAuthorizatio public function testGetRequestSchemePostBodyClientSetsCorrectlyEncodedRawData() { $request = new Http\RequestToken($this->stubConsumer, null, $this->stubHttpUtility); - $params = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + $params = [ + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_version' => '1.0', - 'oauth_callback_url' => 'http://www.example.com/local', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'oauth_timestamp' => '12345678901', + 'oauth_version' => '1.0', + 'oauth_callback_url' => 'http://www.example.com/local', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c~', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', ]; - $client = $request->getRequestSchemePostBodyClient($params); + $client = $request->getRequestSchemePostBodyClient($params); $this->assertEquals( 'oauth_consumer_key=1234567890&oauth_nonce=e807f1fcf82d132f9bb018c' - .'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' - .'678901&oauth_version=1.0&oauth_callback_url=http%3A%2F%2Fwww.example.com%2Flocal' - .'&oauth_signature=6fb42da0e32e07b61c9f0251fe627a9c~' - .'&custom_param1=foo&custom_param2=bar', + . 'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' + . '678901&oauth_version=1.0&oauth_callback_url=http%3A%2F%2Fwww.example.com%2Flocal' + . '&oauth_signature=6fb42da0e32e07b61c9f0251fe627a9c~' + . '&custom_param1=foo&custom_param2=bar', $client->getRawData() ); } @@ -144,24 +145,24 @@ public function testGetRequestSchemePostBodyClientSetsCorrectlyEncodedRawData() public function testGetRequestSchemeQueryStringClientSetsCorrectlyEncodedQueryString() { $request = new Http\RequestToken($this->stubConsumer, null, $this->stubHttpUtility); - $params = [ - 'oauth_consumer_key' => '1234567890', - 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', + $params = [ + 'oauth_consumer_key' => '1234567890', + 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '12345678901', - 'oauth_version' => '1.0', - 'oauth_callback_url' => 'http://www.example.com/local', - 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', - 'custom_param1' => 'foo', - 'custom_param2' => 'bar' + 'oauth_timestamp' => '12345678901', + 'oauth_version' => '1.0', + 'oauth_callback_url' => 'http://www.example.com/local', + 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', + 'custom_param1' => 'foo', + 'custom_param2' => 'bar', ]; - $client = $request->getRequestSchemeQueryStringClient($params, 'http://www.example.com'); + $client = $request->getRequestSchemeQueryStringClient($params, 'http://www.example.com'); $this->assertEquals( 'oauth_consumer_key=1234567890&oauth_nonce=e807f1fcf82d132f9bb018c' - .'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' - .'678901&oauth_version=1.0&oauth_callback_url=http%3A%2F%2Fwww.example.com%2Flocal' - .'&oauth_signature=6fb42da0e32e07b61c9f0251fe627a9c' - .'&custom_param1=foo&custom_param2=bar', + . 'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' + . '678901&oauth_version=1.0&oauth_callback_url=http%3A%2F%2Fwww.example.com%2Flocal' + . '&oauth_signature=6fb42da0e32e07b61c9f0251fe627a9c' + . '&custom_param1=foo&custom_param2=bar', $client->getUri()->getQuery() ); } diff --git a/test/Http/UserAuthorizationTest.php b/test/Http/UserAuthorizationTest.php index 8b57173..1563cbc 100644 --- a/test/Http/UserAuthorizationTest.php +++ b/test/Http/UserAuthorizationTest.php @@ -1,5 +1,7 @@ stubConsumer, [1,2,3]); - $this->assertEquals([1,2,3], $redirect->getParameters()); + $redirect = new Http\UserAuthorization($this->stubConsumer, [1, 2, 3]); + $this->assertEquals([1, 2, 3], $redirect->getParameters()); } public function testAssembleParametersReturnsUserAuthorizationParamArray() { $redirect = new Http\UserAuthorization($this->stubConsumer, ['foo ' => 'bar~']); $expected = [ - 'oauth_token' => '1234567890', + 'oauth_token' => '1234567890', 'oauth_callback' => 'http://www.example.com/local', - 'foo ' => 'bar~' + 'foo ' => 'bar~', ]; $this->assertEquals($expected, $redirect->assembleParams()); } diff --git a/test/Http/UtilityTest.php b/test/Http/UtilityTest.php index 038da2a..fce30bb 100644 --- a/test/Http/UtilityTest.php +++ b/test/Http/UtilityTest.php @@ -1,10 +1,14 @@ 'GET', - 'siteUrl' => 'http://www.example.com' + 'siteUrl' => 'http://www.example.com', ]; $config = new Config($options); @@ -66,7 +68,7 @@ public function testOauthClientPassingArrayInConstructor() { $options = [ 'requestMethod' => 'GET', - 'siteUrl' => 'http://www.example.com' + 'siteUrl' => 'http://www.example.com', ]; $client = new OAuthClient($options); @@ -94,7 +96,7 @@ public function testOauthClientUsingGetRequestParametersForSignature() ->setTokenSecret('456'); $client = new OAuthClient([ - 'token' => $token + 'token' => $token, ], 'http://www.example.com'); $client->getRequest()->getQuery()->set('foo', 'bar'); $client->prepareOAuth(); @@ -124,7 +126,7 @@ public function testOauthClientUsingPostRequestParametersForSignature() ->setTokenSecret('456'); $client = new OAuthClient([ - 'token' => $token + 'token' => $token, ], 'http://www.example.com'); $client->getRequest()->getPost()->set('foo', 'bar'); $client->prepareOAuth(); @@ -154,7 +156,7 @@ public function testOauthClientUsingPostAndGetRequestParametersForSignature() ->setTokenSecret('456'); $client = new OAuthClient([ - 'token' => $token + 'token' => $token, ], 'http://www.example.com'); $client->getRequest()->getPost()->set('foo', 'bar'); $client->getRequest()->getQuery()->set('baz', 'bat'); @@ -165,7 +167,6 @@ public function testOauthClientUsingPostAndGetRequestParametersForSignature() $this->assertEquals($header, $client->getHeader('Authorization')); } - public function testOAuthClientDoesntOverrideExistingHeaders() { $mock = $this->getMockBuilder(Utility::class) @@ -186,11 +187,11 @@ public function testOAuthClientDoesntOverrideExistingHeaders() ->setTokenSecret('456'); $client = new OAuthClient([ - 'token' => $token + 'token' => $token, ], 'http://www.example.com'); $dummyHeader = Header\ContentType::fromString('Content-Type: application/octet-stream'); - $headers = $client->getRequest()->getHeaders(); + $headers = $client->getRequest()->getHeaders(); $headers->addHeaders([$dummyHeader]); $client->prepareOAuth(); diff --git a/test/Signature/AbstractTest.php b/test/Signature/AbstractTest.php index 4c7f326..2054fd6 100644 --- a/test/Signature/AbstractTest.php +++ b/test/Signature/AbstractTest.php @@ -1,5 +1,7 @@ assertEquals('http://www.example.com/REQUEST', $sign->normaliseBaseSignatureUrl($url)); } public function testNormaliseHttpsBaseSignatureUrl() { $sign = new Signature\Plaintext('foo'); - $url = 'HTTPS://WWW.EXAMPLE.COM:443/REQUEST'; + $url = 'HTTPS://WWW.EXAMPLE.COM:443/REQUEST'; $this->assertEquals('https://www.example.com/REQUEST', $sign->normaliseBaseSignatureUrl($url)); } public function testNormaliseHttpPortBaseSignatureUrl() { $sign = new Signature\Plaintext('foo'); - $url = 'HTTP://WWW.EXAMPLE.COM:443/REQUEST'; + $url = 'HTTP://WWW.EXAMPLE.COM:443/REQUEST'; $this->assertEquals('http://www.example.com:443/REQUEST', $sign->normaliseBaseSignatureUrl($url)); } public function testNormaliseHttpsPortBaseSignatureUrl() { $sign = new Signature\Plaintext('foo'); - $url = 'HTTPS://WWW.EXAMPLE.COM:80/REQUEST'; + $url = 'HTTPS://WWW.EXAMPLE.COM:80/REQUEST'; $this->assertEquals('https://www.example.com:80/REQUEST', $sign->normaliseBaseSignatureUrl($url)); } public function testNormaliseHttpsRemovesFragmentFromBaseSignatureUrl() { $sign = new Signature\Plaintext('foo'); - $url = 'https://www.example.com/request#foo'; + $url = 'https://www.example.com/request#foo'; $this->assertEquals('https://www.example.com/request', $sign->normaliseBaseSignatureUrl($url)); } public function testNormaliseHttpsRemovesQueryFromBaseSignatureUrl() { $sign = new Signature\Plaintext('foo'); - $url = 'https://www.example.com/request?foo=bar'; + $url = 'https://www.example.com/request?foo=bar'; $this->assertEquals('https://www.example.com/request', $sign->normaliseBaseSignatureUrl($url)); } } diff --git a/test/Signature/HMACTest.php b/test/Signature/HMACTest.php index d08bf92..1a99c96 100644 --- a/test/Signature/HMACTest.php +++ b/test/Signature/HMACTest.php @@ -1,5 +1,7 @@ '1.0', - 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', + $params = [ + 'oauth_version' => '1.0', + 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '1191242090', - 'oauth_nonce' => 'hsu94j3884jdopsl', - 'oauth_version' => '1.0' + 'oauth_timestamp' => '1191242090', + 'oauth_nonce' => 'hsu94j3884jdopsl', + 'oauth_version' => '1.0', ]; $signature = new Signature\Hmac('1234567890', null, 'SHA1'); $this->assertEquals('XYkaERjLVjp2yP/klDCGQ+hZ2So=', $signature->sign($params)); @@ -23,13 +25,13 @@ public function testSignatureWithoutAccessSecretIsHashedWithConsumerSecret() public function testSignatureWithAccessSecretIsHashedWithConsumerAndAccessSecret() { - $params = [ - 'oauth_version' => '1.0', - 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', + $params = [ + 'oauth_version' => '1.0', + 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_timestamp' => '1191242090', - 'oauth_nonce' => 'hsu94j3884jdopsl', - 'oauth_version' => '1.0' + 'oauth_timestamp' => '1191242090', + 'oauth_nonce' => 'hsu94j3884jdopsl', + 'oauth_version' => '1.0', ]; $signature = new Signature\Hmac('1234567890', '0987654321', 'SHA1'); $this->assertEquals('b0J6H0jCEo+tvzVJy2G615sM6/M=', $signature->sign($params)); diff --git a/test/Signature/PlaintextTest.php b/test/Signature/PlaintextTest.php index 19cff23..683273b 100644 --- a/test/Signature/PlaintextTest.php +++ b/test/Signature/PlaintextTest.php @@ -1,5 +1,7 @@ '1.0', - 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', + $params = [ + 'oauth_version' => '1.0', + 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', 'oauth_signature_method' => 'PLAINTEXT', - 'oauth_timestamp' => '1191242090', - 'oauth_nonce' => 'hsu94j3884jdopsl', - 'oauth_version' => '1.0' + 'oauth_timestamp' => '1191242090', + 'oauth_nonce' => 'hsu94j3884jdopsl', + 'oauth_version' => '1.0', ]; $signature = new Signature\Plaintext('1234567890'); $this->assertEquals('1234567890&', $signature->sign($params)); @@ -23,13 +25,13 @@ public function testSignatureWithoutAccessSecretIsOnlyConsumerSecretString() public function testSignatureWithAccessSecretIsConsumerAndAccessSecretStringsConcatWithAmp() { - $params = [ - 'oauth_version' => '1.0', - 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', + $params = [ + 'oauth_version' => '1.0', + 'oauth_consumer_key' => 'dpf43f3p2l4k3l03', 'oauth_signature_method' => 'PLAINTEXT', - 'oauth_timestamp' => '1191242090', - 'oauth_nonce' => 'hsu94j3884jdopsl', - 'oauth_version' => '1.0' + 'oauth_timestamp' => '1191242090', + 'oauth_nonce' => 'hsu94j3884jdopsl', + 'oauth_version' => '1.0', ]; $signature = new Signature\Plaintext('1234567890', '0987654321'); $this->assertEquals('1234567890&0987654321', $signature->sign($params)); diff --git a/test/Signature/RSATest.php b/test/Signature/RSATest.php index d4d20c8..c6682cc 100644 --- a/test/Signature/RSATest.php +++ b/test/Signature/RSATest.php @@ -1,5 +1,7 @@ assertInstanceOf('Laminas\\Http\\Response', $token->getResponse()); + $token = new AccessToken($response); + $this->assertInstanceOf(HTTPResponse::class, $token->getResponse()); } public function testConstructorParsesRequestTokenFromResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -30,8 +32,8 @@ public function testConstructorParsesRequestTokenFromResponseBody() public function testConstructorParsesRequestTokenSecretFromResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -41,8 +43,8 @@ public function testConstructorParsesRequestTokenSecretFromResponseBody() public function testPropertyAccessWorks() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri&foo=bar'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri&foo=bar'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -52,7 +54,7 @@ public function testPropertyAccessWorks() public function testTokenCastsToEncodedResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; $token = new AccessToken(); $token->setToken('jZaee4GF52O3lUb9'); $token->setTokenSecret('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'); @@ -61,7 +63,7 @@ public function testTokenCastsToEncodedResponseBody() public function testToStringReturnsEncodedResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; $token = new AccessToken(); $token->setToken('jZaee4GF52O3lUb9'); $token->setTokenSecret('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'); @@ -70,8 +72,8 @@ public function testToStringReturnsEncodedResponseBody() public function testIsValidDetectsBadResponse() { - $body = 'oauthtoken=jZaee4GF52O3lUb9&oauthtokensecret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $body = 'oauthtoken=jZaee4GF52O3lUb9&oauthtokensecret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -81,8 +83,8 @@ public function testIsValidDetectsBadResponse() public function testIsValidDetectsGoodResponse() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); diff --git a/test/Token/AuthorizedRequestTest.php b/test/Token/AuthorizedRequestTest.php index d14a4a6..d8baed5 100644 --- a/test/Token/AuthorizedRequestTest.php +++ b/test/Token/AuthorizedRequestTest.php @@ -1,5 +1,7 @@ 'bar']; + $data = ['foo' => 'bar']; $token = new AuthorizedRequestToken($data); $this->assertEquals($data, $token->getData()); } public function testConstructorParsesAccessTokenFromInputData() { - $data = [ - 'oauth_token' => 'jZaee4GF52O3lUb9' + $data = [ + 'oauth_token' => 'jZaee4GF52O3lUb9', ]; $token = new AuthorizedRequestToken($data); $this->assertEquals('jZaee4GF52O3lUb9', $token->getToken()); @@ -25,8 +27,8 @@ public function testConstructorParsesAccessTokenFromInputData() public function testPropertyAccessWorks() { - $data = [ - 'oauth_token' => 'jZaee4GF52O3lUb9' + $data = [ + 'oauth_token' => 'jZaee4GF52O3lUb9', ]; $token = new AuthorizedRequestToken($data); $this->assertEquals('jZaee4GF52O3lUb9', $token->oauth_token); @@ -35,7 +37,7 @@ public function testPropertyAccessWorks() public function testTokenCastsToEncodedQueryString() { $queryString = 'oauth_token=jZaee4GF52O3lUb9&foo%20=bar~'; - $token = new AuthorizedRequestToken(); + $token = new AuthorizedRequestToken(); $token->setToken('jZaee4GF52O3lUb9'); $token->setParam('foo ', 'bar~'); $this->assertEquals($queryString, (string) $token); @@ -44,15 +46,15 @@ public function testTokenCastsToEncodedQueryString() public function testToStringReturnsEncodedQueryString() { $queryString = 'oauth_token=jZaee4GF52O3lUb9'; - $token = new AuthorizedRequestToken(); + $token = new AuthorizedRequestToken(); $token->setToken('jZaee4GF52O3lUb9'); $this->assertEquals($queryString, $token->toString()); } public function testIsValidDetectsBadResponse() { - $data = [ - 'missing_oauth_token' => 'jZaee4GF52O3lUb9' + $data = [ + 'missing_oauth_token' => 'jZaee4GF52O3lUb9', ]; $token = new AuthorizedRequestToken($data); $this->assertFalse($token->isValid()); @@ -60,9 +62,9 @@ public function testIsValidDetectsBadResponse() public function testIsValidDetectsGoodResponse() { - $data = [ + $data = [ 'oauth_token' => 'jZaee4GF52O3lUb9', - 'foo' => 'bar' + 'foo' => 'bar', ]; $token = new AuthorizedRequestToken($data); $this->assertTrue($token->isValid()); diff --git a/test/Token/RequestTest.php b/test/Token/RequestTest.php index b08c876..8051a6e 100644 --- a/test/Token/RequestTest.php +++ b/test/Token/RequestTest.php @@ -1,5 +1,7 @@ assertInstanceOf(HTTPResponse::class, $token->getResponse()); } public function testConstructorParsesRequestTokenFromResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -30,7 +32,7 @@ public function testConstructorParsesRequestTokenSecretFromResponseBody() { $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -40,8 +42,8 @@ public function testConstructorParsesRequestTokenSecretFromResponseBody() public function testPropertyAccessWorks() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri&foo=bar'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri&foo=bar'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); @@ -51,7 +53,7 @@ public function testPropertyAccessWorks() public function testTokenCastsToEncodedResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; $token = new RequestToken(); $token->setToken('jZaee4GF52O3lUb9'); $token->setTokenSecret('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'); @@ -60,7 +62,7 @@ public function testTokenCastsToEncodedResponseBody() public function testToStringReturnsEncodedResponseBody() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; $token = new RequestToken(); $token->setToken('jZaee4GF52O3lUb9'); $token->setTokenSecret('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'); @@ -69,16 +71,16 @@ public function testToStringReturnsEncodedResponseBody() public function testIsValidDetectsBadResponse() { - $body = 'oauthtoken=jZaee4GF52O3lUb9&oauthtokensecret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $body = 'oauthtoken=jZaee4GF52O3lUb9&oauthtokensecret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; $response = new HTTPResponse(200, [], $body); - $token = new RequestToken($response); + $token = new RequestToken($response); $this->assertFalse($token->isValid()); } public function testIsValidDetectsGoodResponse() { - $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; - $response = new HTTPResponse; + $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri'; + $response = new HTTPResponse(); $response->setContent($body) ->setStatusCode(200); From c95ea465fa94a031af79724a597988d38929c5cc Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 15:59:10 +0530 Subject: [PATCH 12/23] Fixed tests folder PHPCS issues Signed-off-by: manishranjan-adobe --- test/Http/AccessTokenTest.php | 3 +++ test/Http/RequestTokenTest.php | 5 +++++ test/Http/UserAuthorizationTest.php | 1 + test/Http/UtilityTest.php | 3 +-- test/TestAsset/AccessToken48231.php | 4 ++++ test/TestAsset/Config90244.php | 12 ++++++------ test/TestAsset/Consumer32874.php | 10 +++++----- test/TestAsset/Consumer32874b.php | 11 +++++++---- test/TestAsset/Consumer34879.php | 6 +++--- test/TestAsset/Consumer39745.php | 10 +++++----- test/TestAsset/Consumer48231.php | 2 +- test/TestAsset/HTTPClient32874.php | 3 +++ test/TestAsset/HTTPUtility32874.php | 13 +++++++++++-- test/TestAsset/HTTPUtility39745.php | 13 +++++++++++-- test/TestAsset/HTTPUtility90244.php | 13 +++++++++++-- test/TestAsset/RequestToken39745.php | 2 +- test/TestAsset/RequestToken48231.php | 4 ++++ test/TestAsset/Token34879.php | 2 +- 18 files changed, 83 insertions(+), 34 deletions(-) diff --git a/test/Http/AccessTokenTest.php b/test/Http/AccessTokenTest.php index 076e46c..9746f4a 100644 --- a/test/Http/AccessTokenTest.php +++ b/test/Http/AccessTokenTest.php @@ -13,7 +13,10 @@ class AccessTokenTest extends TestCase { + /** @var Consumer39745 */ protected $stubConsumer; + + /** @var HTTPUtility39745 */ protected $stubHttpUtility; public function setup(): void diff --git a/test/Http/RequestTokenTest.php b/test/Http/RequestTokenTest.php index 1895e70..1b7d3ea 100644 --- a/test/Http/RequestTokenTest.php +++ b/test/Http/RequestTokenTest.php @@ -14,8 +14,13 @@ class RequestTokenTest extends TestCase { + /** @var Consumer32874 */ protected $stubConsumer; + + /** @var Consumer32874b */ protected $stubConsumer2; + + /** @var HTTPUtility32874 */ protected $stubHttpUtility; public function setup(): void diff --git a/test/Http/UserAuthorizationTest.php b/test/Http/UserAuthorizationTest.php index 1563cbc..d218c12 100644 --- a/test/Http/UserAuthorizationTest.php +++ b/test/Http/UserAuthorizationTest.php @@ -10,6 +10,7 @@ class UserAuthorizationTest extends TestCase { + /** @var Consumer34879 */ protected $stubConsumer; public function setup(): void diff --git a/test/Http/UtilityTest.php b/test/Http/UtilityTest.php index fce30bb..e1bf264 100644 --- a/test/Http/UtilityTest.php +++ b/test/Http/UtilityTest.php @@ -11,8 +11,7 @@ class UtilityTest extends TestCase { - // see: http://wiki.oauth.net/TestCases (Parameter Encoding Tests) - + /** see: http://wiki.oauth.net/TestCases (Parameter Encoding Tests) */ public function testUrlEncodeCorrectlyEncodesAlnum() { $string = 'abcABC123'; diff --git a/test/TestAsset/AccessToken48231.php b/test/TestAsset/AccessToken48231.php index 0b6d63e..ef3c10f 100644 --- a/test/TestAsset/AccessToken48231.php +++ b/test/TestAsset/AccessToken48231.php @@ -13,6 +13,10 @@ public function __construct() { } + /** + * @param array|null $params + * @return Access + */ public function execute(?array $params = null) { return new Access(); diff --git a/test/TestAsset/Config90244.php b/test/TestAsset/Config90244.php index 5bcdd3c..21cc403 100644 --- a/test/TestAsset/Config90244.php +++ b/test/TestAsset/Config90244.php @@ -9,34 +9,34 @@ class Config90244 extends StandardConfig { - public function getConsumerKey() + public function getConsumerKey(): string { return '1234567890'; } - public function getSignatureMethod() + public function getSignatureMethod(): string { return 'HMAC-SHA1'; } - public function getVersion() + public function getVersion(): string { return '1.0'; } - public function getRequestTokenUrl() + public function getRequestTokenUrl(): string { return 'http://www.example.com/request'; } - public function getToken() + public function getToken(): Access { $token = new Access(); $token->setToken('abcde'); return $token; } - public function getRequestMethod() + public function getRequestMethod(): string { return 'POST'; } diff --git a/test/TestAsset/Consumer32874.php b/test/TestAsset/Consumer32874.php index d09e7cc..1db35e0 100644 --- a/test/TestAsset/Consumer32874.php +++ b/test/TestAsset/Consumer32874.php @@ -8,27 +8,27 @@ class Consumer32874 extends Consumer { - public function getConsumerKey() + public function getConsumerKey(): string { return '1234567890'; } - public function getSignatureMethod() + public function getSignatureMethod(): string { return 'HMAC-SHA1'; } - public function getVersion() + public function getVersion(): string { return '1.0'; } - public function getRequestTokenUrl() + public function getRequestTokenUrl(): string { return 'http://www.example.com/request'; } - public function getCallbackUrl() + public function getCallbackUrl(): string { return 'http://www.example.com/local'; } diff --git a/test/TestAsset/Consumer32874b.php b/test/TestAsset/Consumer32874b.php index c30a48e..2e718f8 100644 --- a/test/TestAsset/Consumer32874b.php +++ b/test/TestAsset/Consumer32874b.php @@ -8,26 +8,29 @@ class Consumer32874b extends Consumer { - public function getConsumerKey() + public function getConsumerKey(): string { return '1234567890'; } - public function getSignatureMethod() + public function getSignatureMethod(): string { return 'HMAC-SHA1'; } - public function getVersion() + public function getVersion(): string { return '1.0'; } - public function getRequestTokenUrl() + public function getRequestTokenUrl(): string { return 'http://www.example.com/request'; } + /** + * @return null + */ public function getCallbackUrl() { return null; diff --git a/test/TestAsset/Consumer34879.php b/test/TestAsset/Consumer34879.php index 6d0798d..974fa4f 100644 --- a/test/TestAsset/Consumer34879.php +++ b/test/TestAsset/Consumer34879.php @@ -8,17 +8,17 @@ class Consumer34879 extends Consumer { - public function getUserAuthorizationUrl() + public function getUserAuthorizationUrl(): string { return 'http://www.example.com/authorize'; } - public function getCallbackUrl() + public function getCallbackUrl(): string { return 'http://www.example.com/local'; } - public function getLastRequestToken() + public function getLastRequestToken(): Token34879 { return new Token34879(); } diff --git a/test/TestAsset/Consumer39745.php b/test/TestAsset/Consumer39745.php index 24fa514..a0c4aaa 100644 --- a/test/TestAsset/Consumer39745.php +++ b/test/TestAsset/Consumer39745.php @@ -8,27 +8,27 @@ class Consumer39745 extends Consumer { - public function getConsumerKey() + public function getConsumerKey(): string { return '1234567890'; } - public function getSignatureMethod() + public function getSignatureMethod(): string { return 'HMAC-SHA1'; } - public function getVersion() + public function getVersion(): string { return '1.0'; } - public function getAccessTokenUrl() + public function getAccessTokenUrl(): string { return 'http://www.example.com/access'; } - public function getLastRequestToken() + public function getLastRequestToken(): RequestToken39745 { return new RequestToken39745(); } diff --git a/test/TestAsset/Consumer48231.php b/test/TestAsset/Consumer48231.php index 63ee520..84d2b35 100644 --- a/test/TestAsset/Consumer48231.php +++ b/test/TestAsset/Consumer48231.php @@ -17,7 +17,7 @@ public function __construct(array $options = []) parent::__construct($options); } - public function getCallbackUrl() + public function getCallbackUrl(): string { return 'http://www.example.com/local'; } diff --git a/test/TestAsset/HTTPClient32874.php b/test/TestAsset/HTTPClient32874.php index 0f21b81..0b5114f 100644 --- a/test/TestAsset/HTTPClient32874.php +++ b/test/TestAsset/HTTPClient32874.php @@ -8,6 +8,9 @@ class HTTPClient32874 extends Client { + /** + * @return mixed|string + */ public function getRawData() { return $this->getRequest()->getContent(); diff --git a/test/TestAsset/HTTPUtility32874.php b/test/TestAsset/HTTPUtility32874.php index efe2298..ed09b71 100644 --- a/test/TestAsset/HTTPUtility32874.php +++ b/test/TestAsset/HTTPUtility32874.php @@ -14,16 +14,25 @@ public function __construct() { } - public function generateNonce() + public function generateNonce(): string { return md5('1234567890'); } - public function generateTimestamp() + public function generateTimestamp(): string { return '12345678901'; } + /** + * @param array $params + * @param string $signatureMethod + * @param string $consumerSecret + * @param string $accessTokenSecret + * @param string $method + * @param string $url + * @return string + */ public function sign( array $params, $signatureMethod, diff --git a/test/TestAsset/HTTPUtility39745.php b/test/TestAsset/HTTPUtility39745.php index b06ee6c..6d34fa7 100644 --- a/test/TestAsset/HTTPUtility39745.php +++ b/test/TestAsset/HTTPUtility39745.php @@ -14,16 +14,25 @@ public function __construct() { } - public function generateNonce() + public function generateNonce(): string { return md5('1234567890'); } - public function generateTimestamp() + public function generateTimestamp(): string { return '12345678901'; } + /** + * @param array $params + * @param string $signatureMethod + * @param string $consumerSecret + * @param string $accessTokenSecret + * @param string $method + * @param string $url + * @return string + */ public function sign( array $params, $signatureMethod, diff --git a/test/TestAsset/HTTPUtility90244.php b/test/TestAsset/HTTPUtility90244.php index 8365d16..7a1b9f0 100644 --- a/test/TestAsset/HTTPUtility90244.php +++ b/test/TestAsset/HTTPUtility90244.php @@ -14,16 +14,25 @@ public function __construct() { } - public function generateNonce() + public function generateNonce(): string { return md5('1234567890'); } - public function generateTimestamp() + public function generateTimestamp(): string { return '12345678901'; } + /** + * @param array $params + * @param string $signatureMethod + * @param string $consumerSecret + * @param string $accessTokenSecret + * @param string $method + * @param string $url + * @return string + */ public function sign( array $params, $signatureMethod, diff --git a/test/TestAsset/RequestToken39745.php b/test/TestAsset/RequestToken39745.php index 449be90..0609a2b 100644 --- a/test/TestAsset/RequestToken39745.php +++ b/test/TestAsset/RequestToken39745.php @@ -8,7 +8,7 @@ class RequestToken39745 extends Request { - public function getToken() + public function getToken(): string { return '0987654321'; } diff --git a/test/TestAsset/RequestToken48231.php b/test/TestAsset/RequestToken48231.php index f8b2a7f..155bd1c 100644 --- a/test/TestAsset/RequestToken48231.php +++ b/test/TestAsset/RequestToken48231.php @@ -13,6 +13,10 @@ public function __construct() { } + /** + * @param array|null $params + * @return Request + */ public function execute(?array $params = null) { return new Request(); diff --git a/test/TestAsset/Token34879.php b/test/TestAsset/Token34879.php index 915bce3..5ad368a 100644 --- a/test/TestAsset/Token34879.php +++ b/test/TestAsset/Token34879.php @@ -6,7 +6,7 @@ class Token34879 { - public function getToken() + public function getToken(): string { return '1234567890'; } From 19426e1ec100b8c9f6fb329afa98d13f9b6f594a Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 16:43:14 +0530 Subject: [PATCH 13/23] Fixed BC issues fix Signed-off-by: manishranjan-adobe --- phpcs.xml | 20 --------- phpunit.xml | 25 ----------- src/Client.php | 13 +++--- src/Config/ConfigInterface.php | 52 +++++++++++++++++----- src/Config/StandardConfig.php | 2 - src/Consumer.php | 2 - src/Exception/BadMethodCallException.php | 2 - src/Exception/ExceptionInterface.php | 2 - src/Exception/InvalidArgumentException.php | 2 - src/Exception/RuntimeException.php | 2 - src/Http.php | 2 - src/Http/AccessToken.php | 2 - src/Http/RequestToken.php | 2 - src/Http/UserAuthorization.php | 2 - src/Http/Utility.php | 2 - src/OAuth.php | 2 - src/Signature/AbstractSignature.php | 2 - src/Signature/Hmac.php | 2 - src/Signature/Plaintext.php | 2 - src/Signature/Rsa.php | 2 - src/Signature/SignatureInterface.php | 2 - src/Token/AbstractToken.php | 9 ++-- src/Token/Access.php | 2 - src/Token/AuthorizedRequest.php | 2 - src/Token/Request.php | 2 - src/Token/TokenInterface.php | 2 - test/Config/StandardConfigurationTest.php | 3 -- test/ConsumerTest.php | 2 - test/Http/AccessTokenTest.php | 2 - test/Http/RequestTokenTest.php | 2 - test/Http/UserAuthorizationTest.php | 2 - test/Http/UtilityTest.php | 2 - test/OAuthTest.php | 2 - test/Signature/AbstractTest.php | 2 - test/Signature/HMACTest.php | 2 - test/Signature/PlaintextTest.php | 2 - test/Signature/RSATest.php | 2 - test/TestAsset/AccessToken48231.php | 2 - test/TestAsset/Config90244.php | 2 - test/TestAsset/Consumer32874.php | 2 - test/TestAsset/Consumer32874b.php | 2 - test/TestAsset/Consumer34879.php | 2 - test/TestAsset/Consumer39745.php | 2 - test/TestAsset/Consumer48231.php | 2 - test/TestAsset/HTTPClient19485876.php | 2 - test/TestAsset/HTTPClient32874.php | 2 - test/TestAsset/HTTPClient39745.php | 2 - test/TestAsset/HTTPUtility32874.php | 2 - test/TestAsset/HTTPUtility39745.php | 2 - test/TestAsset/HTTPUtility90244.php | 2 - test/TestAsset/RequestToken39745.php | 2 - test/TestAsset/RequestToken48231.php | 2 - test/TestAsset/Token34879.php | 2 - test/Token/AccessTest.php | 2 - test/Token/AuthorizedRequestTest.php | 2 - test/Token/RequestTest.php | 2 - 56 files changed, 51 insertions(+), 171 deletions(-) delete mode 100644 phpcs.xml delete mode 100644 phpunit.xml diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index cd255f3..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,20 +0,0 @@ -ο»Ώ - - - - - - - - - - - - - src - test - - - - diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index d278018..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - ./src - - - - - ./test - - - - - - - - - - - - - - - diff --git a/src/Client.php b/src/Client.php index 0af8c5d..6e91ca1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1,7 +1,5 @@ setRequestMethod(HttpRequest::METHOD_GET); - } elseif ($method === HttpRequest::METHOD_POST) { + } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_POST)) { $this->setRequestMethod(HttpRequest::METHOD_POST); - } elseif ($method === HttpRequest::METHOD_PUT) { + } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_PUT)) { $this->setRequestMethod(HttpRequest::METHOD_PUT); - } elseif ($method === HttpRequest::METHOD_DELETE) { + } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_DELETE)) { $this->setRequestMethod(HttpRequest::METHOD_DELETE); - } elseif ($method === HttpRequest::METHOD_HEAD) { + } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_HEAD)) { $this->setRequestMethod(HttpRequest::METHOD_HEAD); } return parent::setMethod($method); diff --git a/src/Config/ConfigInterface.php b/src/Config/ConfigInterface.php index 5ed7434..ed0f9f3 100644 --- a/src/Config/ConfigInterface.php +++ b/src/Config/ConfigInterface.php @@ -1,7 +1,5 @@ getParam($key); } @@ -248,7 +249,7 @@ protected function parseParameters(HTTPResponse $response) * * @return array */ - public function __sleep(): array + public function __sleep() { return ['_params']; } diff --git a/src/Token/Access.php b/src/Token/Access.php index abfd0e4..36ba0d2 100644 --- a/src/Token/Access.php +++ b/src/Token/Access.php @@ -1,7 +1,5 @@ Date: Tue, 22 Oct 2024 16:45:40 +0530 Subject: [PATCH 14/23] PHPCS configuration changes Signed-off-by: manishranjan-adobe --- phpcs.xml.dist | 20 ++++++++++++++++++-- phpunit.xml.dist | 23 +++++++++++++++-------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 1a80a86..ea5802d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,8 +1,24 @@ - - + + + + + + + + + + src test + + + + + src/ + test/ + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index dd69f42..988ca6b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,25 @@ - - + + ./src - - + ./test + + + + + + + + + + + + From c8fe9cf35943cca4627e1942c92e5da71336de9f Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 16:53:34 +0530 Subject: [PATCH 15/23] PHPCS issues fix Signed-off-by: manishranjan-adobe --- test/Config/StandardConfigurationTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Config/StandardConfigurationTest.php b/test/Config/StandardConfigurationTest.php index bcb5f8b..05ce403 100644 --- a/test/Config/StandardConfigurationTest.php +++ b/test/Config/StandardConfigurationTest.php @@ -1,4 +1,5 @@ Date: Tue, 22 Oct 2024 17:00:02 +0530 Subject: [PATCH 16/23] removed 8.2 platform dependency Signed-off-by: manishranjan-adobe --- .laminas-ci.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.laminas-ci.json b/.laminas-ci.json index 24c03b5..cc08634 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -5,7 +5,6 @@ {"name": "PHPUnit on PHP 7.1 with locked dependencies"} ], "ignore_php_platform_requirements": { - "8.2": true, "8.4": true } } From c6e446da73850dec350fd3d4e7ebe6e417e5e0f3 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 18:31:18 +0530 Subject: [PATCH 17/23] Fix phpunit config and improve code optimization Signed-off-by: manishranjan-adobe --- phpunit.xml.dist | 22 +++++++--------------- src/Client.php | 28 +++++++++++++++++----------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 988ca6b..c519bfd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,25 +1,17 @@ - - + + ./src - + ./test - - - - - - - - - - - - diff --git a/src/Client.php b/src/Client.php index 6e91ca1..596724c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,7 +12,7 @@ use function array_merge; use function call_user_func_array; use function method_exists; -use function strtolower; +use function strtoupper; class Client extends HttpClient { @@ -147,16 +147,22 @@ public function setRawDataStream($data, $enctype = null) */ public function setMethod($method = HttpRequest::METHOD_GET) { - if (strtolower($method) === strtolower(HttpRequest::METHOD_GET)) { - $this->setRequestMethod(HttpRequest::METHOD_GET); - } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_POST)) { - $this->setRequestMethod(HttpRequest::METHOD_POST); - } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_PUT)) { - $this->setRequestMethod(HttpRequest::METHOD_PUT); - } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_DELETE)) { - $this->setRequestMethod(HttpRequest::METHOD_DELETE); - } elseif (strtolower($method) === strtolower(HttpRequest::METHOD_HEAD)) { - $this->setRequestMethod(HttpRequest::METHOD_HEAD); + switch (strtoupper($method)) { + case HttpRequest::METHOD_GET: + $this->setRequestMethod(HttpRequest::METHOD_GET); + break; + case HttpRequest::METHOD_POST: + $this->setRequestMethod(HttpRequest::METHOD_POST); + break; + case HttpRequest::METHOD_PUT: + $this->setRequestMethod(HttpRequest::METHOD_PUT); + break; + case HttpRequest::METHOD_DELETE: + $this->setRequestMethod(HttpRequest::METHOD_DELETE); + break; + case HttpRequest::METHOD_HEAD: + $this->setRequestMethod(HttpRequest::METHOD_HEAD); + break; } return parent::setMethod($method); } From f45e41c7b9c0370fc11f10ef1236b28f01f4b24a Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 21:04:27 +0530 Subject: [PATCH 18/23] PR suggested changes Signed-off-by: manishranjan-adobe --- src/Client.php | 5 ++--- src/Signature/AbstractSignature.php | 4 ++-- test/TestAsset/HTTPUtility32874.php | 1 - test/TestAsset/HTTPUtility39745.php | 1 - test/TestAsset/HTTPUtility90244.php | 1 - test/TestAsset/RequestToken48231.php | 1 - 6 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Client.php b/src/Client.php index 596724c..18780bc 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,7 +12,6 @@ use function array_merge; use function call_user_func_array; use function method_exists; -use function strtoupper; class Client extends HttpClient { @@ -147,7 +146,7 @@ public function setRawDataStream($data, $enctype = null) */ public function setMethod($method = HttpRequest::METHOD_GET) { - switch (strtoupper($method)) { + switch ($method) { case HttpRequest::METHOD_GET: $this->setRequestMethod(HttpRequest::METHOD_GET); break; @@ -207,7 +206,7 @@ public function prepareOAuth() $requestHeaders->addHeaders(['Authorization' => $oauthHeaderValue]); break; case OAuth::REQUEST_SCHEME_POSTBODY: - if ($this->getRequestMethod() === HttpRequest::METHOD_GET) { + if ($this->getMethod() === HttpRequest::METHOD_GET) { throw new Exception\RuntimeException( 'The client is configured to' . ' pass OAuth parameters through a POST body but request method' diff --git a/src/Signature/AbstractSignature.php b/src/Signature/AbstractSignature.php index dc8fd2c..afdfddd 100644 --- a/src/Signature/AbstractSignature.php +++ b/src/Signature/AbstractSignature.php @@ -74,9 +74,9 @@ public function normaliseBaseSignatureUrl($url) { $uri = Uri\UriFactory::factory($url); $uri->normalize(); - if ($uri->getScheme() === 'http' && $uri->getPort() === '80') { + if ($uri->getScheme() === 'http' && (string) $uri->getPort() === '80') { $uri->setPort(''); - } elseif ($uri->getScheme() === 'https' && $uri->getPort() === '443') { + } elseif ($uri->getScheme() === 'https' && (string) $uri->getPort() === '443') { $uri->setPort(''); } elseif (! in_array($uri->getScheme(), ['http', 'https'])) { throw new Exception\InvalidArgumentException('Invalid URL provided; must be an HTTP or HTTPS scheme'); diff --git a/test/TestAsset/HTTPUtility32874.php b/test/TestAsset/HTTPUtility32874.php index c6c1155..842f2a9 100644 --- a/test/TestAsset/HTTPUtility32874.php +++ b/test/TestAsset/HTTPUtility32874.php @@ -23,7 +23,6 @@ public function generateTimestamp(): string } /** - * @param array $params * @param string $signatureMethod * @param string $consumerSecret * @param string $accessTokenSecret diff --git a/test/TestAsset/HTTPUtility39745.php b/test/TestAsset/HTTPUtility39745.php index 879c101..c47a4d9 100644 --- a/test/TestAsset/HTTPUtility39745.php +++ b/test/TestAsset/HTTPUtility39745.php @@ -23,7 +23,6 @@ public function generateTimestamp(): string } /** - * @param array $params * @param string $signatureMethod * @param string $consumerSecret * @param string $accessTokenSecret diff --git a/test/TestAsset/HTTPUtility90244.php b/test/TestAsset/HTTPUtility90244.php index 4adaa26..0dc3ee9 100644 --- a/test/TestAsset/HTTPUtility90244.php +++ b/test/TestAsset/HTTPUtility90244.php @@ -23,7 +23,6 @@ public function generateTimestamp(): string } /** - * @param array $params * @param string $signatureMethod * @param string $consumerSecret * @param string $accessTokenSecret diff --git a/test/TestAsset/RequestToken48231.php b/test/TestAsset/RequestToken48231.php index 3efc9f9..4c4b1a7 100644 --- a/test/TestAsset/RequestToken48231.php +++ b/test/TestAsset/RequestToken48231.php @@ -12,7 +12,6 @@ public function __construct() } /** - * @param array|null $params * @return Request */ public function execute(?array $params = null) From 547288210ed489a1355a41ace1f73f7174a6ab44 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 21:16:06 +0530 Subject: [PATCH 19/23] Reverted original code with additional check Signed-off-by: manishranjan-adobe --- src/Client.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Client.php b/src/Client.php index 18780bc..c415eb1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -146,22 +146,17 @@ public function setRawDataStream($data, $enctype = null) */ public function setMethod($method = HttpRequest::METHOD_GET) { - switch ($method) { - case HttpRequest::METHOD_GET: - $this->setRequestMethod(HttpRequest::METHOD_GET); - break; - case HttpRequest::METHOD_POST: - $this->setRequestMethod(HttpRequest::METHOD_POST); - break; - case HttpRequest::METHOD_PUT: - $this->setRequestMethod(HttpRequest::METHOD_PUT); - break; - case HttpRequest::METHOD_DELETE: - $this->setRequestMethod(HttpRequest::METHOD_DELETE); - break; - case HttpRequest::METHOD_HEAD: - $this->setRequestMethod(HttpRequest::METHOD_HEAD); - break; + $method = strtoupper($method); + if ($method === HttpRequest::METHOD_GET) { + $this->setRequestMethod(HttpRequest::METHOD_GET); + } elseif ($method === HttpRequest::METHOD_POST) { + $this->setRequestMethod(HttpRequest::METHOD_POST); + } elseif ($method === HttpRequest::METHOD_PUT) { + $this->setRequestMethod(HttpRequest::METHOD_PUT); + } elseif ($method === HttpRequest::METHOD_DELETE) { + $this->setRequestMethod(HttpRequest::METHOD_DELETE); + } elseif ($method === HttpRequest::METHOD_HEAD) { + $this->setRequestMethod(HttpRequest::METHOD_HEAD); } return parent::setMethod($method); } From 2aa1da4099fdc4642cf4e6e7b826189a639de63f Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 21:20:06 +0530 Subject: [PATCH 20/23] PHPCS Fix Signed-off-by: manishranjan-adobe --- src/Client.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client.php b/src/Client.php index c415eb1..8bc7792 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,6 +12,7 @@ use function array_merge; use function call_user_func_array; use function method_exists; +use function strtoupper; class Client extends HttpClient { From 8c0ff7f5fbdb4be6e8bf6c95646f1dec6c39c497 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Tue, 22 Oct 2024 21:21:11 +0530 Subject: [PATCH 21/23] Reveresed original code Signed-off-by: manishranjan-adobe --- src/Client.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Client.php b/src/Client.php index 8bc7792..aa70f8d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,7 +12,6 @@ use function array_merge; use function call_user_func_array; use function method_exists; -use function strtoupper; class Client extends HttpClient { @@ -147,7 +146,6 @@ public function setRawDataStream($data, $enctype = null) */ public function setMethod($method = HttpRequest::METHOD_GET) { - $method = strtoupper($method); if ($method === HttpRequest::METHOD_GET) { $this->setRequestMethod(HttpRequest::METHOD_GET); } elseif ($method === HttpRequest::METHOD_POST) { From 24fab998b5d669df1518a2313905c98ff280941d Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Wed, 23 Oct 2024 16:09:42 +0530 Subject: [PATCH 22/23] PR suggested changes Signed-off-by: manishranjan-adobe --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index aa70f8d..d8cd230 100644 --- a/src/Client.php +++ b/src/Client.php @@ -200,7 +200,7 @@ public function prepareOAuth() $requestHeaders->addHeaders(['Authorization' => $oauthHeaderValue]); break; case OAuth::REQUEST_SCHEME_POSTBODY: - if ($this->getMethod() === HttpRequest::METHOD_GET) { + if ($this->oauthConfig->getRequestMethod() === HttpRequest::METHOD_GET) { throw new Exception\RuntimeException( 'The client is configured to' . ' pass OAuth parameters through a POST body but request method' From 79e7aeeb0a018a081e344930424774d82309f730 Mon Sep 17 00:00:00 2001 From: manishranjan-adobe Date: Wed, 23 Oct 2024 18:20:24 +0530 Subject: [PATCH 23/23] Modified type casting to ensure consistency across lib Signed-off-by: manishranjan-adobe --- src/Signature/AbstractSignature.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Signature/AbstractSignature.php b/src/Signature/AbstractSignature.php index afdfddd..a6df57c 100644 --- a/src/Signature/AbstractSignature.php +++ b/src/Signature/AbstractSignature.php @@ -74,9 +74,9 @@ public function normaliseBaseSignatureUrl($url) { $uri = Uri\UriFactory::factory($url); $uri->normalize(); - if ($uri->getScheme() === 'http' && (string) $uri->getPort() === '80') { + if ($uri->getScheme() === 'http' && (int) $uri->getPort() === 80) { $uri->setPort(''); - } elseif ($uri->getScheme() === 'https' && (string) $uri->getPort() === '443') { + } elseif ($uri->getScheme() === 'https' && (int) $uri->getPort() === 443) { $uri->setPort(''); } elseif (! in_array($uri->getScheme(), ['http', 'https'])) { throw new Exception\InvalidArgumentException('Invalid URL provided; must be an HTTP or HTTPS scheme');