mirror of
https://github.com/friendica/friendica
synced 2025-04-28 03:50:17 +00:00
Use short form array syntax everywhere
- Add short form array syntax to po2php.php generation
This commit is contained in:
parent
77dfbaa0bf
commit
e36f2bb1fb
212 changed files with 5160 additions and 5160 deletions
|
@ -96,7 +96,7 @@ class Crypto
|
|||
$modulus->SetIntBuffer($Modulus);
|
||||
$publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
|
||||
$publicExponent->SetIntBuffer($PublicExponent);
|
||||
$keySequenceItems = array($modulus, $publicExponent);
|
||||
$keySequenceItems = [$modulus, $publicExponent];
|
||||
$keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
|
||||
$keySequence->SetSequence($keySequenceItems);
|
||||
//Encode bit string
|
||||
|
@ -125,7 +125,7 @@ class Crypto
|
|||
$modulus->SetIntBuffer($Modulus);
|
||||
$publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
|
||||
$publicExponent->SetIntBuffer($PublicExponent);
|
||||
$keySequenceItems = array($modulus, $publicExponent);
|
||||
$keySequenceItems = [$modulus, $publicExponent];
|
||||
$keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
|
||||
$keySequence->SetSequence($keySequenceItems);
|
||||
//Encode bit string
|
||||
|
@ -221,11 +221,11 @@ class Crypto
|
|||
*/
|
||||
public static function newKeypair($bits)
|
||||
{
|
||||
$openssl_options = array(
|
||||
$openssl_options = [
|
||||
'digest_alg' => 'sha1',
|
||||
'private_key_bits' => $bits,
|
||||
'encrypt_key' => false
|
||||
);
|
||||
];
|
||||
|
||||
$conf = Config::get('system', 'openssl_conf_file');
|
||||
if ($conf) {
|
||||
|
@ -239,7 +239,7 @@ class Crypto
|
|||
}
|
||||
|
||||
// Get private key
|
||||
$response = array('prvkey' => '', 'pubkey' => '');
|
||||
$response = ['prvkey' => '', 'pubkey' => ''];
|
||||
|
||||
openssl_pkey_export($result, $response['prvkey']);
|
||||
|
||||
|
|
|
@ -72,12 +72,12 @@ class Emailer
|
|||
"--" . $mimeBoundary . "--\n"; // message ending
|
||||
|
||||
// send the message
|
||||
$hookdata = array(
|
||||
$hookdata = [
|
||||
'to' => $params['toEmail'],
|
||||
'subject' => $messageSubject,
|
||||
'body' => $multipartMessageBody,
|
||||
'headers' => $messageHeader
|
||||
);
|
||||
];
|
||||
//echo "<pre>"; var_dump($hookdata); killme();
|
||||
call_hooks("emailer_send", $hookdata);
|
||||
$res = mail(
|
||||
|
|
|
@ -140,7 +140,7 @@ class ExAuth
|
|||
$this->setHost($aCommand[2]);
|
||||
|
||||
// Now we check if the given user is valid
|
||||
$sUser = str_replace(array('%20', '(a)'), array(' ', '@'), $aCommand[1]);
|
||||
$sUser = str_replace(['%20', '(a)'], [' ', '@'], $aCommand[1]);
|
||||
|
||||
// Does the hostname match? So we try directly
|
||||
if ($a->get_hostname() == $aCommand[2]) {
|
||||
|
@ -220,7 +220,7 @@ class ExAuth
|
|||
$this->setHost($aCommand[2]);
|
||||
|
||||
// We now check if the password match
|
||||
$sUser = str_replace(array('%20', '(a)'), array(' ', '@'), $aCommand[1]);
|
||||
$sUser = str_replace(['%20', '(a)'], [' ', '@'], $aCommand[1]);
|
||||
|
||||
// Does the hostname match? So we try directly
|
||||
if ($a->get_hostname() == $aCommand[2]) {
|
||||
|
|
|
@ -21,7 +21,7 @@ require_once 'include/dba.php';
|
|||
*/
|
||||
class Lock
|
||||
{
|
||||
private static $semaphore = array();
|
||||
private static $semaphore = [];
|
||||
|
||||
/**
|
||||
* @brief Check for memcache and open a connection if configured
|
||||
|
@ -140,11 +140,11 @@ class Lock
|
|||
}
|
||||
}
|
||||
if (!$lock['locked']) {
|
||||
dba::update('locks', array('locked' => true, 'pid' => getmypid()), array('name' => $fn_name));
|
||||
dba::update('locks', ['locked' => true, 'pid' => getmypid()], ['name' => $fn_name]);
|
||||
$got_lock = true;
|
||||
}
|
||||
} elseif (!DBM::is_result($lock)) {
|
||||
dba::insert('locks', array('name' => $fn_name, 'locked' => true, 'pid' => getmypid()));
|
||||
dba::insert('locks', ['name' => $fn_name, 'locked' => true, 'pid' => getmypid()]);
|
||||
$got_lock = true;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ class Lock
|
|||
return;
|
||||
}
|
||||
|
||||
dba::update('locks', array('locked' => false, 'pid' => 0), array('name' => $fn_name, 'pid' => getmypid()));
|
||||
dba::update('locks', ['locked' => false, 'pid' => 0], ['name' => $fn_name, 'pid' => getmypid()]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ class Lock
|
|||
return;
|
||||
}
|
||||
|
||||
dba::update('locks', array('locked' => false, 'pid' => 0), array('pid' => getmypid()));
|
||||
dba::update('locks', ['locked' => false, 'pid' => 0], ['pid' => getmypid()]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ namespace Friendica\Util;
|
|||
class Map {
|
||||
public static function byCoordinates($coord) {
|
||||
$coord = trim($coord);
|
||||
$coord = str_replace(array(',','/',' '),array(' ',' ',' '),$coord);
|
||||
$arr = array('lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'html' => '');
|
||||
$coord = str_replace([',','/',' '],[' ',' ',' '],$coord);
|
||||
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'html' => ''];
|
||||
call_hooks('generate_map',$arr);
|
||||
return ($arr['html']) ? $arr['html'] : $coord;
|
||||
}
|
||||
|
||||
public static function byLocation($location) {
|
||||
$arr = array('location' => $location, 'html' => '');
|
||||
$arr = ['location' => $location, 'html' => ''];
|
||||
call_hooks('generate_named_map',$arr);
|
||||
return ($arr['html']) ? $arr['html'] : $location;
|
||||
}
|
||||
|
|
|
@ -69,10 +69,10 @@ class ParseUrl
|
|||
|
||||
dba::insert(
|
||||
'parsed_url',
|
||||
array(
|
||||
[
|
||||
'url' => normalise_link($url), 'guessing' => !$no_guessing,
|
||||
'oembed' => $do_oembed, 'content' => serialize($data),
|
||||
'created' => datetime_convert()),
|
||||
'created' => datetime_convert()],
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -122,7 +122,7 @@ class ParseUrl
|
|||
{
|
||||
$a = get_app();
|
||||
|
||||
$siteinfo = array();
|
||||
$siteinfo = [];
|
||||
|
||||
// Check if the URL does contain a scheme
|
||||
$scheme = parse_url($url, PHP_URL_SCHEME);
|
||||
|
@ -165,7 +165,7 @@ class ParseUrl
|
|||
if ($do_oembed) {
|
||||
$oembed_data = OEmbed::fetchURL($url);
|
||||
|
||||
if (!in_array($oembed_data->type, array("error", "rich", ""))) {
|
||||
if (!in_array($oembed_data->type, ["error", "rich", ""])) {
|
||||
$siteinfo["type"] = $oembed_data->type;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ class ParseUrl
|
|||
|
||||
$list = $xpath->query("//meta[@content]");
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
@ -250,7 +250,7 @@ class ParseUrl
|
|||
//$list = $xpath->query("head/meta[@name]");
|
||||
$list = $xpath->query("//meta[@name]");
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
@ -307,7 +307,7 @@ class ParseUrl
|
|||
}
|
||||
|
||||
if (isset($keywords)) {
|
||||
$siteinfo["keywords"] = array();
|
||||
$siteinfo["keywords"] = [];
|
||||
foreach ($keywords as $keyword) {
|
||||
if (!in_array(trim($keyword), $siteinfo["keywords"])) {
|
||||
$siteinfo["keywords"][] = trim($keyword);
|
||||
|
@ -318,7 +318,7 @@ class ParseUrl
|
|||
//$list = $xpath->query("head/meta[@property]");
|
||||
$list = $xpath->query("//meta[@property]");
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
@ -345,7 +345,7 @@ class ParseUrl
|
|||
if ((@$siteinfo["image"] == "") && !$no_guessing) {
|
||||
$list = $xpath->query("//img[@src]");
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
@ -364,9 +364,9 @@ class ParseUrl
|
|||
$photodata[0] = round($photodata[0] * (300 / $photodata[1]));
|
||||
$photodata[1] = 300;
|
||||
}
|
||||
$siteinfo["images"][] = array("src" => $src,
|
||||
$siteinfo["images"][] = ["src" => $src,
|
||||
"width" => $photodata[0],
|
||||
"height" => $photodata[1]);
|
||||
"height" => $photodata[1]];
|
||||
}
|
||||
}
|
||||
} elseif ($siteinfo["image"] != "") {
|
||||
|
@ -377,9 +377,9 @@ class ParseUrl
|
|||
$photodata = Image::getInfoFromURL($src);
|
||||
|
||||
if (($photodata) && ($photodata[0] > 10) && ($photodata[1] > 10)) {
|
||||
$siteinfo["images"][] = array("src" => $src,
|
||||
$siteinfo["images"][] = ["src" => $src,
|
||||
"width" => $photodata[0],
|
||||
"height" => $photodata[1]);
|
||||
"height" => $photodata[1]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ class ParseUrl
|
|||
}
|
||||
|
||||
if ($text != "") {
|
||||
$text = trim(str_replace(array("\n", "\r"), array(" ", " "), $text));
|
||||
$text = trim(str_replace(["\n", "\r"], [" ", " "], $text));
|
||||
|
||||
while (strpos($text, " ")) {
|
||||
$text = trim(str_replace(" ", " ", $text));
|
||||
|
@ -441,7 +441,7 @@ class ParseUrl
|
|||
$arr_tags = str_getcsv($string);
|
||||
if (count($arr_tags)) {
|
||||
// add the # sign to every tag
|
||||
array_walk($arr_tags, array("self", "arrAddHashes"));
|
||||
array_walk($arr_tags, ["self", "arrAddHashes"]);
|
||||
|
||||
return $arr_tags;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class XML
|
|||
*
|
||||
* @return string The created XML
|
||||
*/
|
||||
public static function fromArray($array, &$xml, $remove_header = false, $namespaces = array(), $root = true)
|
||||
public static function fromArray($array, &$xml, $remove_header = false, $namespaces = [], $root = true)
|
||||
{
|
||||
if ($root) {
|
||||
foreach ($array as $key => $value) {
|
||||
|
@ -140,7 +140,7 @@ class XML
|
|||
*
|
||||
* @return object XML element object
|
||||
*/
|
||||
public static function createElement($doc, $element, $value = "", $attributes = array())
|
||||
public static function createElement($doc, $element, $value = "", $attributes = [])
|
||||
{
|
||||
$element = $doc->createElement($element, xmlify($value));
|
||||
|
||||
|
@ -162,7 +162,7 @@ class XML
|
|||
* @param array $attributes array containing the attributes
|
||||
* @return void
|
||||
*/
|
||||
public static function addElement($doc, $parent, $element, $value = "", $attributes = array())
|
||||
public static function addElement($doc, $parent, $element, $value = "", $attributes = [])
|
||||
{
|
||||
$element = self::createElement($doc, $element, $value, $attributes);
|
||||
$parent->appendChild($element);
|
||||
|
@ -194,7 +194,7 @@ class XML
|
|||
}
|
||||
|
||||
if (is_array($xml_element)) {
|
||||
$result_array = array();
|
||||
$result_array = [];
|
||||
if (count($xml_element) <= 0) {
|
||||
return (trim(strval($xml_element_copy)));
|
||||
}
|
||||
|
@ -207,9 +207,9 @@ class XML
|
|||
|
||||
if ($recursion_depth == 0) {
|
||||
$temp_array = $result_array;
|
||||
$result_array = array(
|
||||
$result_array = [
|
||||
strtolower($xml_element_copy->getName()) => $temp_array,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return ($result_array);
|
||||
|
@ -242,12 +242,12 @@ class XML
|
|||
public static function toArray($contents, $namespaces = true, $get_attributes = 1, $priority = 'attribute')
|
||||
{
|
||||
if (!$contents) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!function_exists('xml_parser_create')) {
|
||||
logger('Xml::toArray: parser function missing');
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
@ -262,7 +262,7 @@ class XML
|
|||
|
||||
if (! $parser) {
|
||||
logger('Xml::toArray: xml_parser_create: no resource');
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
|
||||
|
@ -282,15 +282,15 @@ class XML
|
|||
}
|
||||
|
||||
//Initializations
|
||||
$xml_array = array();
|
||||
$parents = array();
|
||||
$opened_tags = array();
|
||||
$arr = array();
|
||||
$xml_array = [];
|
||||
$parents = [];
|
||||
$opened_tags = [];
|
||||
$arr = [];
|
||||
|
||||
$current = &$xml_array; // Reference
|
||||
|
||||
// Go through the tags.
|
||||
$repeated_tag_index = array(); // Multiple tags with same name will be turned into an array
|
||||
$repeated_tag_index = []; // Multiple tags with same name will be turned into an array
|
||||
foreach ($xml_values as $data) {
|
||||
$tag = $data['tag'];
|
||||
$type = $data['type'];
|
||||
|
@ -298,8 +298,8 @@ class XML
|
|||
$attributes = isset($data['attributes']) ? $data['attributes'] : null;
|
||||
$value = isset($data['value']) ? $data['value'] : null;
|
||||
|
||||
$result = array();
|
||||
$attributes_data = array();
|
||||
$result = [];
|
||||
$attributes_data = [];
|
||||
|
||||
if (isset($value)) {
|
||||
if ($priority == 'tag') {
|
||||
|
@ -344,7 +344,7 @@ class XML
|
|||
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
|
||||
$repeated_tag_index[$tag.'_'.$level]++;
|
||||
} else { // This section will make the value an array if multiple tags with the same name appear together
|
||||
$current[$tag] = array($current[$tag], $result); // This will combine the existing item and the new item together to make an array
|
||||
$current[$tag] = [$current[$tag], $result]; // This will combine the existing item and the new item together to make an array
|
||||
$repeated_tag_index[$tag.'_'.$level] = 2;
|
||||
|
||||
if (isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
|
@ -374,7 +374,7 @@ class XML
|
|||
}
|
||||
$repeated_tag_index[$tag.'_'.$level]++;
|
||||
} else { // If it is not an array...
|
||||
$current[$tag] = array($current[$tag], $result); //...Make it an array using using the existing value and the new value
|
||||
$current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value
|
||||
$repeated_tag_index[$tag.'_'.$level] = 1;
|
||||
if ($priority == 'tag' and $get_attributes) {
|
||||
if (isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue