@@ -302,12 +302,17 @@ public function __construct(string $http_method, string $http_url, array $parame
302302 /**
303303 * attempt to build up a request from what was passed to the server
304304 */
305- public static function from_request (string $ http_method = null , string $ http_url = null , array $ parameters = null ): self
306- {
305+ public static function from_request (
306+ string $ http_method = null ,
307+ string $ http_url = null ,
308+ array $ parameters = null
309+ ): self {
307310 $ scheme = (!isset ($ _SERVER ['HTTPS ' ]) || $ _SERVER ['HTTPS ' ] != 'on ' )
308311 ? 'http '
309312 : 'https ' ;
310- $ http_url = ($ http_url ) ? $ http_url : $ scheme .
313+ $ http_url = ($ http_url )
314+ ? $ http_url
315+ : $ scheme .
311316 ':// ' . $ _SERVER ['HTTP_HOST ' ] .
312317 ': ' .
313318 $ _SERVER ['SERVER_PORT ' ] .
@@ -339,7 +344,10 @@ public static function from_request(string $http_method = null, string $http_url
339344
340345 // We have a Authorization-header with OAuth data. Parse the header
341346 // and add those overriding any duplicates from GET or POST
342- if (isset ($ request_headers ['Authorization ' ]) && substr ($ request_headers ['Authorization ' ], 0 , 6 ) == 'OAuth ' ) {
347+ if (
348+ isset ($ request_headers ['Authorization ' ])
349+ && substr ($ request_headers ['Authorization ' ], 0 , 6 ) == 'OAuth '
350+ ) {
343351 $ header_parameters = Util::split_header (
344352 $ request_headers ['Authorization ' ]
345353 );
@@ -354,8 +362,13 @@ public static function from_request(string $http_method = null, string $http_url
354362 /**
355363 * pretty much a helper function to set up the request
356364 */
357- public static function from_consumer_and_token (Consumer $ consumer , ?Token $ token , string $ http_method , string $ http_url , array $ parameters = null ): self
358- {
365+ public static function from_consumer_and_token (
366+ Consumer $ consumer ,
367+ ?Token $ token ,
368+ string $ http_method ,
369+ string $ http_url ,
370+ array $ parameters = null
371+ ): self {
359372 $ parameters = $ parameters ?: [];
360373 $ defaults = [
361374 'oauth_version ' => self ::$ version ,
@@ -392,7 +405,7 @@ public function set_parameter(string $name, $value, bool $allow_duplicates = tru
392405
393406 public function get_parameter (string $ name )
394407 {
395- return isset ( $ this ->parameters [$ name ]) ? $ this -> parameters [ $ name ] : null ;
408+ return $ this ->parameters [$ name ] ?? null ;
396409 }
397410
398411
@@ -465,7 +478,9 @@ public function get_normalized_http_url(): string
465478 $ parts = parse_url ($ this ->http_url );
466479
467480 $ scheme = (isset ($ parts ['scheme ' ])) ? $ parts ['scheme ' ] : 'http ' ;
468- $ port = (isset ($ parts ['port ' ])) ? $ parts ['port ' ] : (($ scheme == 'https ' ) ? '443 ' : '80 ' );
481+ $ port = (isset ($ parts ['port ' ]))
482+ ? $ parts ['port ' ]
483+ : (($ scheme == 'https ' ) ? '443 ' : '80 ' );
469484 $ host = (isset ($ parts ['host ' ])) ? $ parts ['host ' ] : '' ;
470485 $ path = (isset ($ parts ['path ' ])) ? $ parts ['path ' ] : '' ;
471486
@@ -581,7 +596,7 @@ class Util
581596 public static function urlencode_rfc3986 ($ input )
582597 {
583598 if (is_array ($ input )) {
584- return array_map ([__CLASS__ , 'urlencode_rfc3986 ' ], $ input );
599+ return array_map ([self ::class , 'urlencode_rfc3986 ' ], $ input );
585600 } elseif (is_scalar ($ input )) {
586601 return str_replace ('+ ' , ' ' , str_replace ('%7E ' , '~ ' , rawurlencode ((string ) $ input )));
587602 } else {
0 commit comments