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

Commit

Permalink
More cleanup (#139)
Browse files Browse the repository at this point in the history
* Convert to short array syntax

* Fix type hints

* Fix indentation
  • Loading branch information
liayn authored Apr 7, 2020
1 parent 768fce1 commit 8a68f6d
Show file tree
Hide file tree
Showing 79 changed files with 3,086 additions and 2,414 deletions.
28 changes: 14 additions & 14 deletions Auth/OpenID.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static function isFailure($thing)
*/
static function getQuery($query_str=null)
{
$data = array();
$data = [];

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

if ($str === false) {
$post = array();
$post = [];
} else {
$post = Auth_OpenID::params_from_string($str);
}
Expand All @@ -186,7 +186,7 @@ static function params_from_string($str)
{
$chunks = explode("&", $str);

$data = array();
$data = [];
foreach ($chunks as $chunk) {
$parts = explode("=", $chunk, 2);

Expand Down Expand Up @@ -237,7 +237,7 @@ static function ensureDir($dir_name)
*/
static function addPrefix($values, $prefix)
{
$new_values = array();
$new_values = [];
foreach ($values as $s) {
$new_values[] = $prefix . $s;
}
Expand Down Expand Up @@ -286,7 +286,7 @@ static function parse_str($query)

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

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

Expand Down Expand Up @@ -314,7 +314,7 @@ static function parse_str($query)
*/
static function httpBuildQuery($data)
{
$pairs = array();
$pairs = [];
foreach ($data as $key => $value) {
if (is_array($value)) {
$pairs[] = urlencode($value[0])."=".urlencode($value[1]);
Expand Down Expand Up @@ -354,9 +354,9 @@ static function appendArgs($url, $args)
} else {
$keys = array_keys($args);
sort($keys);
$new_args = array();
$new_args = [];
foreach ($keys as $key) {
$new_args[] = array($key, $args[$key]);
$new_args[] = [$key, $args[$key]];
}
$args = $new_args;
}
Expand Down Expand Up @@ -440,7 +440,7 @@ static function normalizeUrl($url)
if (isset($parsed['scheme']) &&
isset($parsed['host'])) {
$scheme = strtolower($parsed['scheme']);
if (!in_array($scheme, array('http', 'https'))) {
if (!in_array($scheme, ['http', 'https'])) {
return null;
}
} else {
Expand Down Expand Up @@ -497,10 +497,10 @@ static function toBytes($str)
$hex = bin2hex($str);

if (!$hex) {
return array();
return [];
}

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

if (count($parts) == 1) {
return array($parts[0], "");
return [$parts[0], ""];
} else {
return $parts;
}
}

static function filter($callback, &$sequence)
{
$result = array();
$result = [];

foreach ($sequence as $item) {
if (call_user_func_array($callback, array($item))) {
if (call_user_func_array($callback, [$item])) {
$result[] = $item;
}
}
Expand Down
28 changes: 14 additions & 14 deletions Auth/OpenID/AX.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function _checkMode($ax_args)
*/
function _newArgs()
{
return array('mode' => $this->mode);
return ['mode' => $this->mode];
}
}

Expand Down Expand Up @@ -248,7 +248,7 @@ function wantsUnlimitedValues()
*/
function Auth_OpenID_AX_toTypeURIs($namespace_map, $alias_list_s)
{
$uris = array();
$uris = [];

if ($alias_list_s) {
foreach (explode(',', $alias_list_s) as $alias) {
Expand Down Expand Up @@ -295,7 +295,7 @@ class Auth_OpenID_AX_FetchRequest extends Auth_OpenID_AX_Message {
*
* @var array
*/
private $requested_attributes = array();
private $requested_attributes = [];

function __construct($update_url=null)
{
Expand Down Expand Up @@ -331,8 +331,8 @@ function getExtensionArgs($request = null)
{
$aliases = new Auth_OpenID_NamespaceMap();

$required = array();
$if_available = array();
$required = [];
$if_available = [];

$ax_args = $this->_newArgs();

Expand Down Expand Up @@ -383,7 +383,7 @@ function getExtensionArgs($request = null)
*/
function getRequiredAttrs()
{
$required = array();
$required = [];
foreach ($this->requested_attributes as $type_uri => $attribute) {
if ($attribute->required) {
$required[] = $type_uri;
Expand Down Expand Up @@ -559,7 +559,7 @@ function contains($type_uri)
class Auth_OpenID_AX_KeyValueMessage extends Auth_OpenID_AX_Message {

/** @var array */
protected $data = array();
protected $data = [];

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

$values =& $this->data[$type_uri];
Expand Down Expand Up @@ -609,7 +609,7 @@ function _getExtensionKpublicgs($aliases)
$aliases = new Auth_OpenID_NamespaceMap();
}

$ax_args = array();
$ax_args = [];

foreach ($this->data as $type_uri => $values) {
$alias = $aliases->add($type_uri);
Expand Down Expand Up @@ -683,7 +683,7 @@ function parseExtensionArgs($ax_args)
);
}

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

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

if ($value == '') {
$values = array();
$values = [];
} else {
$values = array($value);
$values = [$value];
}
}

Expand Down Expand Up @@ -828,7 +828,7 @@ function getExtensionArgs($request=null)
{
$aliases = new Auth_OpenID_NamespaceMap();

$zero_value_types = array();
$zero_value_types = [];

if ($request !== null) {
// Validate the data in the context of the request (the
Expand Down Expand Up @@ -865,7 +865,7 @@ function getExtensionArgs($request=null)
if (array_key_exists($attr_info->type_uri, $this->data)) {
$values = $this->data[$attr_info->type_uri];
} else {
$values = array();
$values = [];
$zero_value_types[] = $attr_info;
}

Expand Down
Loading

0 comments on commit 8a68f6d

Please sign in to comment.