Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 8a68f6d

Browse files
authored
More cleanup (#139)
* Convert to short array syntax * Fix type hints * Fix indentation
1 parent 768fce1 commit 8a68f6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3086
-2414
lines changed

Auth/OpenID.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static function isFailure($thing)
148148
*/
149149
static function getQuery($query_str=null)
150150
{
151-
$data = array();
151+
$data = [];
152152

153153
if ($query_str !== null) {
154154
$data = Auth_OpenID::params_from_string($query_str);
@@ -170,7 +170,7 @@ static function getQuery($query_str=null)
170170
$str = file_get_contents('php://input');
171171

172172
if ($str === false) {
173-
$post = array();
173+
$post = [];
174174
} else {
175175
$post = Auth_OpenID::params_from_string($str);
176176
}
@@ -186,7 +186,7 @@ static function params_from_string($str)
186186
{
187187
$chunks = explode("&", $str);
188188

189-
$data = array();
189+
$data = [];
190190
foreach ($chunks as $chunk) {
191191
$parts = explode("=", $chunk, 2);
192192

@@ -237,7 +237,7 @@ static function ensureDir($dir_name)
237237
*/
238238
static function addPrefix($values, $prefix)
239239
{
240-
$new_values = array();
240+
$new_values = [];
241241
foreach ($values as $s) {
242242
$new_values[] = $prefix . $s;
243243
}
@@ -286,7 +286,7 @@ static function parse_str($query)
286286

287287
$parts = explode('&', $query);
288288

289-
$new_parts = array();
289+
$new_parts = [];
290290
for ($i = 0; $i < count($parts); $i++) {
291291
$pair = explode('=', $parts[$i]);
292292

@@ -314,7 +314,7 @@ static function parse_str($query)
314314
*/
315315
static function httpBuildQuery($data)
316316
{
317-
$pairs = array();
317+
$pairs = [];
318318
foreach ($data as $key => $value) {
319319
if (is_array($value)) {
320320
$pairs[] = urlencode($value[0])."=".urlencode($value[1]);
@@ -354,9 +354,9 @@ static function appendArgs($url, $args)
354354
} else {
355355
$keys = array_keys($args);
356356
sort($keys);
357-
$new_args = array();
357+
$new_args = [];
358358
foreach ($keys as $key) {
359-
$new_args[] = array($key, $args[$key]);
359+
$new_args[] = [$key, $args[$key]];
360360
}
361361
$args = $new_args;
362362
}
@@ -440,7 +440,7 @@ static function normalizeUrl($url)
440440
if (isset($parsed['scheme']) &&
441441
isset($parsed['host'])) {
442442
$scheme = strtolower($parsed['scheme']);
443-
if (!in_array($scheme, array('http', 'https'))) {
443+
if (!in_array($scheme, ['http', 'https'])) {
444444
return null;
445445
}
446446
} else {
@@ -497,10 +497,10 @@ static function toBytes($str)
497497
$hex = bin2hex($str);
498498

499499
if (!$hex) {
500-
return array();
500+
return [];
501501
}
502502

503-
$b = array();
503+
$b = [];
504504
for ($i = 0; $i < strlen($hex); $i += 2) {
505505
$b[] = chr(base_convert(substr($hex, $i, 2), 16, 10));
506506
}
@@ -513,18 +513,18 @@ static function urldefrag($url)
513513
$parts = explode("#", $url, 2);
514514

515515
if (count($parts) == 1) {
516-
return array($parts[0], "");
516+
return [$parts[0], ""];
517517
} else {
518518
return $parts;
519519
}
520520
}
521521

522522
static function filter($callback, &$sequence)
523523
{
524-
$result = array();
524+
$result = [];
525525

526526
foreach ($sequence as $item) {
527-
if (call_user_func_array($callback, array($item))) {
527+
if (call_user_func_array($callback, [$item])) {
528528
$result[] = $item;
529529
}
530530
}

Auth/OpenID/AX.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function _checkMode($ax_args)
130130
*/
131131
function _newArgs()
132132
{
133-
return array('mode' => $this->mode);
133+
return ['mode' => $this->mode];
134134
}
135135
}
136136

@@ -248,7 +248,7 @@ function wantsUnlimitedValues()
248248
*/
249249
function Auth_OpenID_AX_toTypeURIs($namespace_map, $alias_list_s)
250250
{
251-
$uris = array();
251+
$uris = [];
252252

253253
if ($alias_list_s) {
254254
foreach (explode(',', $alias_list_s) as $alias) {
@@ -295,7 +295,7 @@ class Auth_OpenID_AX_FetchRequest extends Auth_OpenID_AX_Message {
295295
*
296296
* @var array
297297
*/
298-
private $requested_attributes = array();
298+
private $requested_attributes = [];
299299

300300
function __construct($update_url=null)
301301
{
@@ -331,8 +331,8 @@ function getExtensionArgs($request = null)
331331
{
332332
$aliases = new Auth_OpenID_NamespaceMap();
333333

334-
$required = array();
335-
$if_available = array();
334+
$required = [];
335+
$if_available = [];
336336

337337
$ax_args = $this->_newArgs();
338338

@@ -383,7 +383,7 @@ function getExtensionArgs($request = null)
383383
*/
384384
function getRequiredAttrs()
385385
{
386-
$required = array();
386+
$required = [];
387387
foreach ($this->requested_attributes as $type_uri => $attribute) {
388388
if ($attribute->required) {
389389
$required[] = $type_uri;
@@ -559,7 +559,7 @@ function contains($type_uri)
559559
class Auth_OpenID_AX_KeyValueMessage extends Auth_OpenID_AX_Message {
560560

561561
/** @var array */
562-
protected $data = array();
562+
protected $data = [];
563563

564564
/**
565565
* Add a single value for the given attribute type to the
@@ -574,7 +574,7 @@ class Auth_OpenID_AX_KeyValueMessage extends Auth_OpenID_AX_Message {
574574
function addValue($type_uri, $value)
575575
{
576576
if (!array_key_exists($type_uri, $this->data)) {
577-
$this->data[$type_uri] = array();
577+
$this->data[$type_uri] = [];
578578
}
579579

580580
$values =& $this->data[$type_uri];
@@ -609,7 +609,7 @@ function _getExtensionKpublicgs($aliases)
609609
$aliases = new Auth_OpenID_NamespaceMap();
610610
}
611611

612-
$ax_args = array();
612+
$ax_args = [];
613613

614614
foreach ($this->data as $type_uri => $values) {
615615
$alias = $aliases->add($type_uri);
@@ -683,7 +683,7 @@ function parseExtensionArgs($ax_args)
683683
);
684684
}
685685

686-
$values = array();
686+
$values = [];
687687
for ($i = 1; $i < $count + 1; $i++) {
688688
$value_key = sprintf('value.%s.%d', $alias, $i);
689689

@@ -710,9 +710,9 @@ function parseExtensionArgs($ax_args)
710710
$value = $ax_args['value.' . $alias];
711711

712712
if ($value == '') {
713-
$values = array();
713+
$values = [];
714714
} else {
715-
$values = array($value);
715+
$values = [$value];
716716
}
717717
}
718718

@@ -828,7 +828,7 @@ function getExtensionArgs($request=null)
828828
{
829829
$aliases = new Auth_OpenID_NamespaceMap();
830830

831-
$zero_value_types = array();
831+
$zero_value_types = [];
832832

833833
if ($request !== null) {
834834
// Validate the data in the context of the request (the
@@ -865,7 +865,7 @@ function getExtensionArgs($request=null)
865865
if (array_key_exists($attr_info->type_uri, $this->data)) {
866866
$values = $this->data[$attr_info->type_uri];
867867
} else {
868-
$values = array();
868+
$values = [];
869869
$zero_value_types[] = $attr_info;
870870
}
871871

0 commit comments

Comments
 (0)