Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Add type casting to avoid deprecation issues
Browse files Browse the repository at this point in the history
Signed-off-by: Karyna Tsymbal <[email protected]>
  • Loading branch information
karyna-t committed Jul 22, 2022
1 parent f527f1d commit 3457c37
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/Http/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ public function toAuthorizationHeader(array $params, $realm = null, $excludeCust
*/
public function sign(
array $params,
string $signatureMethod,
$signatureMethod,
$consumerSecret,
$tokenSecret = null,
$method = null,
$url = null
) {
$className = '';
$hashAlgo = null;
$parts = explode('-', $signatureMethod);
$parts = explode('-', (string) $signatureMethod);
if (count($parts) > 1) {
$className = 'Laminas\OAuth\Signature\\' . ucfirst(strtolower($parts[0]));
$hashAlgo = $parts[1];
Expand Down Expand Up @@ -189,9 +189,9 @@ public function generateTimestamp()
* @param string $value
* @return string
*/
public static function urlEncode(string $value)
public static function urlEncode($value)
{
$encoded = rawurlencode($value);
$encoded = rawurlencode((string) $value);
$encoded = str_replace('%7E', '~', $encoded);
return $encoded;
}
Expand Down
16 changes: 4 additions & 12 deletions test/OAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public function testOauthClientUsingGetRequestParametersForSignature()
->setTokenSecret('456');

$client = new OAuthClient([
'token' => $token,
'consumerSecret' => '', // for PHP 8.1 compatibility
'consumerKey' => ''
'token' => $token
], 'http://www.example.com');
$client->getRequest()->getQuery()->set('foo', 'bar');
$client->prepareOAuth();
Expand Down Expand Up @@ -126,9 +124,7 @@ public function testOauthClientUsingPostRequestParametersForSignature()
->setTokenSecret('456');

$client = new OAuthClient([
'token' => $token,
'consumerSecret' => '', // for PHP 8.1 compatibility
'consumerKey' => ''
'token' => $token
], 'http://www.example.com');
$client->getRequest()->getPost()->set('foo', 'bar');
$client->prepareOAuth();
Expand Down Expand Up @@ -158,9 +154,7 @@ public function testOauthClientUsingPostAndGetRequestParametersForSignature()
->setTokenSecret('456');

$client = new OAuthClient([
'token' => $token,
'consumerSecret' => '', // for PHP 8.1 compatibility
'consumerKey' => ''
'token' => $token
], 'http://www.example.com');
$client->getRequest()->getPost()->set('foo', 'bar');
$client->getRequest()->getQuery()->set('baz', 'bat');
Expand Down Expand Up @@ -192,9 +186,7 @@ public function testOAuthClientDoesntOverrideExistingHeaders()
->setTokenSecret('456');

$client = new OAuthClient([
'token' => $token,
'consumerSecret' => '', // for PHP 8.1 compatibility
'consumerKey' => ''
'token' => $token
], 'http://www.example.com');

$dummyHeader = Header\ContentType::fromString('Content-Type: application/octet-stream');
Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/HTTPUtility32874.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function generateTimestamp()

public function sign(
array $params,
string $signatureMethod,
$signatureMethod,
$consumerSecret,
$accessTokenSecret = null,
$method = null,
Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/HTTPUtility39745.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function generateTimestamp()

public function sign(
array $params,
string $signatureMethod,
$signatureMethod,
$consumerSecret,
$accessTokenSecret = null,
$method = null,
Expand Down
2 changes: 1 addition & 1 deletion test/TestAsset/HTTPUtility90244.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function generateTimestamp()

public function sign(
array $params,
string $signatureMethod,
$signatureMethod,
$consumerSecret,
$accessTokenSecret = null,
$method = null,
Expand Down

0 comments on commit 3457c37

Please sign in to comment.