summaryrefslogtreecommitdiff
path: root/hauth
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-03-27 09:53:21 +0000
committerlsces <lester@lsces.co.uk>2026-03-27 09:53:21 +0000
commit58a06634259893011a912c380ab78cf3c1bdc10e (patch)
tree16c8032533e71d0b8b32df33a9e2f75f783b8411 /hauth
parent12c7af8b9349a3ecf93d96d22c986519d41b9482 (diff)
downloadusers-58a06634259893011a912c380ab78cf3c1bdc10e.tar.gz
users-58a06634259893011a912c380ab78cf3c1bdc10e.tar.bz2
users-58a06634259893011a912c380ab78cf3c1bdc10e.zip
PHP8.4 style tweaks
Diffstat (limited to 'hauth')
-rw-r--r--hauth/Hybrid/thirdparty/OAuth/OAuth.php47
1 files changed, 24 insertions, 23 deletions
diff --git a/hauth/Hybrid/thirdparty/OAuth/OAuth.php b/hauth/Hybrid/thirdparty/OAuth/OAuth.php
index a8d8934..5e50fe1 100644
--- a/hauth/Hybrid/thirdparty/OAuth/OAuth.php
+++ b/hauth/Hybrid/thirdparty/OAuth/OAuth.php
@@ -126,10 +126,10 @@ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
- $key_parts = array(
- $consumer->secret,
- ($token) ? $token->secret : ""
- );
+ $key_parts = [
+ $consumer->secret,
+ ( $token ) ? $token->secret : ""
+ ];
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
@@ -158,10 +158,10 @@ class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
* OAuthRequest handles this!
*/
public function build_signature($request, $consumer, $token) {
- $key_parts = array(
- $consumer->secret,
- ($token) ? $token->secret : ""
- );
+ $key_parts = [
+ $consumer->secret,
+ ( $token ) ? $token->secret : ""
+ ];
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
@@ -242,8 +242,8 @@ class OAuthRequest {
public static $POST_INPUT = 'php://input';
function __construct($http_method, $http_url, $parameters=null) {
- $parameters = ($parameters) ? $parameters : array();
- $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
+ $parameters = $parameters ? $parameters : [];
+ $parameters = [ ...OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), ...$parameters];
$this->parameters = $parameters;
$this->http_method = $http_method;
$this->http_url = $http_url;
@@ -310,10 +310,12 @@ class OAuthRequest {
*/
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null) {
$parameters = ($parameters) ? $parameters : array();
- $defaults = array("oauth_version" => OAuthRequest::$version,
- "oauth_nonce" => OAuthRequest::generate_nonce(),
- "oauth_timestamp" => OAuthRequest::generate_timestamp(),
- "oauth_consumer_key" => $consumer->key);
+ $defaults = [
+ "oauth_version" => OAuthRequest::$version,
+ "oauth_nonce" => OAuthRequest::generate_nonce(),
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
+ "oauth_consumer_key" => $consumer->key,
+ ];
if ($token)
$defaults['oauth_token'] = $token->key;
@@ -498,7 +500,7 @@ class OAuthRequest {
class OAuthServer {
protected $timestamp_threshold = 300; // in seconds, five minutes
protected $version = '1.0'; // hi blaine
- protected $signature_methods = array();
+ protected $signature_methods = [];
protected $data_store;
@@ -563,7 +565,7 @@ class OAuthServer {
$consumer = $this->get_consumer($request);
$token = $this->get_token($request, $consumer, "access");
$this->check_signature($request, $consumer, $token);
- return array($consumer, $token);
+ return [ $consumer, $token ];
}
// Internals from here
@@ -600,8 +602,7 @@ class OAuthServer {
if (!in_array($signature_method,
array_keys($this->signature_methods))) {
throw new OAuthException(
- "Signature method '$signature_method' not supported " .
- "try one of the following: " .
+ "Signature method '$signature_method' not supported try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
@@ -772,7 +773,7 @@ class OAuthUtil {
// May 28th, 2010 - method updated to tjerk.meesters for a speed improvement.
// see http://code.google.com/p/oauth/issues/detail?id=163
public static function split_header($header, $only_allow_oauth_parameters = true) {
- $params = array();
+ $params = [];
if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
foreach ($matches[1] as $i => $h) {
$params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
@@ -807,7 +808,7 @@ class OAuthUtil {
} else {
// otherwise we don't have apache and are just going to have to hope
// that $_SERVER actually contains what we need
- $out = array();
+ $out = [];
if( isset($_SERVER['CONTENT_TYPE']) )
$out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
if( isset($_ENV['CONTENT_TYPE']) )
@@ -838,7 +839,7 @@ class OAuthUtil {
$pairs = explode('&', $input);
- $parsed_parameters = array();
+ $parsed_parameters = [];
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
@@ -851,7 +852,7 @@ class OAuthUtil {
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
- $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
+ $parsed_parameters[$parameter] = [ $parsed_parameters[$parameter] ];
}
$parsed_parameters[$parameter][] = $value;
@@ -874,7 +875,7 @@ class OAuthUtil {
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
- $pairs = array();
+ $pairs = [];
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value