Use short form array syntax everywhere

- Add short form array syntax to po2php.php generation
This commit is contained in:
Hypolite Petovan 2018-01-15 08:05:12 -05:00
parent 77dfbaa0bf
commit e36f2bb1fb
212 changed files with 5160 additions and 5160 deletions

View file

@ -41,13 +41,13 @@ class Image
if (class_exists('Imagick')) {
// Imagick::queryFormats won't help us a lot there...
// At least, not yet, other parts of friendica uses this array
$t = array(
$t = [
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif'
);
];
} else {
$t = array();
$t = [];
$t['image/jpeg'] ='jpg';
if (imagetypes() & IMG_PNG) {
$t['image/png'] = 'png';
@ -113,11 +113,11 @@ class Image
*/
public static function getFormatsMap()
{
$m = array(
$m = [
'image/jpeg' => 'JPG',
'image/png' => 'PNG',
'image/gif' => 'GIF'
);
];
return $m;
}
@ -726,7 +726,7 @@ class Image
$type = null;
if ($fromcurl) {
$a = get_app();
$headers=array();
$headers=[];
$h = explode("\n", $a->get_curl_headers());
foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
@ -767,7 +767,7 @@ class Image
*/
public static function getInfoFromURL($url)
{
$data = array();
$data = [];
$data = Cache::get($url);
@ -850,7 +850,7 @@ class Image
}
}
}
return array("width" => $dest_width, "height" => $dest_height);
return ["width" => $dest_width, "height" => $dest_height];
}
/**
@ -871,7 +871,7 @@ class Image
if (!DBM::is_result($r)) {
logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
return(array());
return([]);
}
$page_owner_nick = $r[0]['nickname'];
@ -882,7 +882,7 @@ class Image
if ((strlen($imagedata) == 0) && ($url == "")) {
logger("No image data and no url provided", LOGGER_DEBUG);
return(array());
return([]);
} elseif (strlen($imagedata) == 0) {
logger("Uploading picture from ".$url, LOGGER_DEBUG);
@ -895,7 +895,7 @@ class Image
if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
return(array());
return([]);
}
$tempfile = tempnam(get_temppath(), "cache");
@ -909,7 +909,7 @@ class Image
if (!isset($data["mime"])) {
unlink($tempfile);
logger("File is no picture", LOGGER_DEBUG);
return(array());
return([]);
}
$Image = new Image($imagedata, $data["mime"]);
@ -917,7 +917,7 @@ class Image
if (!$Image->isValid()) {
unlink($tempfile);
logger("Picture is no valid picture", LOGGER_DEBUG);
return(array());
return([]);
}
$Image->orient($tempfile);
@ -948,11 +948,11 @@ class Image
if (!$r) {
logger("Picture couldn't be stored", LOGGER_DEBUG);
return(array());
return([]);
}
$image = array("page" => System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash,
"full" => System::baseUrl()."/photo/{$hash}-0.".$Image->getExt());
$image = ["page" => System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash,
"full" => System::baseUrl()."/photo/{$hash}-0.".$Image->getExt()];
if ($width > 800 || $height > 800) {
$image["large"] = System::baseUrl()."/photo/{$hash}-0.".$Image->getExt();

View file

@ -23,16 +23,16 @@ require_once 'include/conversation.php';
*/
class Post extends BaseObject
{
private $data = array();
private $data = [];
private $template = null;
private $available_templates = array(
private $available_templates = [
'wall' => 'wall_thread.tpl',
'wall2wall' => 'wallwall_thread.tpl'
);
];
private $comment_box_template = 'comment_item.tpl';
private $toplevel = false;
private $writable = false;
private $children = array();
private $children = [];
private $parent = null;
private $thread = null;
private $redirect_url = null;
@ -107,7 +107,7 @@ class Post extends BaseObject
{
require_once "mod/proxy.php";
$result = array();
$result = [];
$a = self::getApp();
@ -119,11 +119,11 @@ class Post extends BaseObject
// between creation time and edit time of a second. Thats why we add the notice
// only if the difference is more than 1 second.
if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
$edited = array(
$edited = [
'label' => t('This entry was edited'),
'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
'relative' => relative_date($item['edited'])
);
];
}
$commentww = '';
$sparkle = '';
@ -147,9 +147,9 @@ class Post extends BaseObject
if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
if ($item["event-id"] != 0) {
$edpost = array("events/event/" . $item['event-id'], t("Edit"));
$edpost = ["events/event/" . $item['event-id'], t("Edit")];
} else {
$edpost = array("editpost/" . $item['id'], t("Edit"));
$edpost = ["editpost/" . $item['id'], t("Edit")];
}
$dropping = in_array($item['uid'], [0, local_user()]);
} else {
@ -167,12 +167,12 @@ class Post extends BaseObject
$dropping = true;
}
$drop = array(
$drop = [
'dropping' => $dropping,
'pagedrop' => ((Feature::isEnabled($conv->getProfileOwner(), 'multi_delete')) ? $item['pagedrop'] : ''),
'select' => t('Select'),
'delete' => t('Delete'),
);
];
$filer = (($conv->getProfileOwner() == local_user()) ? t("save to folder") : false);
@ -212,12 +212,12 @@ class Post extends BaseObject
}
}
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
$locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
call_hooks('render_location', $locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like', 'dislike');
$response_verbs = ['like', 'dislike'];
$isevent = false;
$attend = [];
@ -227,7 +227,7 @@ class Post extends BaseObject
$response_verbs[] = 'attendmaybe';
if ($conv->isWritable()) {
$isevent = true;
$attend = array(t('I will attend'), t('I will not attend'), t('I might attend'));
$attend = [t('I will attend'), t('I will not attend'), t('I might attend')];
}
}
@ -254,31 +254,31 @@ class Post extends BaseObject
if ($conv->getProfileOwner() == local_user()) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array(
$star = [
'do' => t("add star"),
'undo' => t("remove star"),
'toggle' => t("toggle star status"),
'classdo' => $item['starred'] ? "hidden" : "",
'classundo' => $item['starred'] ? "" : "hidden",
'starred' => t('starred'),
);
];
$thread = dba::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
if (DBM::is_result($thread)) {
$ignore = array(
$ignore = [
'do' => t("ignore thread"),
'undo' => t("unignore thread"),
'toggle' => t("toggle ignore status"),
'classdo' => $thread['ignored'] ? "hidden" : "",
'classundo' => $thread['ignored'] ? "" : "hidden",
'ignored' => t('ignored'),
);
];
}
if (Feature::isEnabled($conv->getProfileOwner(), 'commtag')) {
$tagger = array(
$tagger = [
'add' => t("add tag"),
'class' => "",
);
];
}
}
} else {
@ -286,12 +286,12 @@ class Post extends BaseObject
}
if ($conv->isWritable()) {
$buttons = array(
'like' => array(t("I like this \x28toggle\x29"), t("like")),
'dislike' => Feature::isEnabled($conv->getProfileOwner(), 'dislike') ? array(t("I don't like this \x28toggle\x29"), t("dislike")) : '',
);
$buttons = [
'like' => [t("I like this \x28toggle\x29"), t("like")],
'dislike' => Feature::isEnabled($conv->getProfileOwner(), 'dislike') ? [t("I don't like this \x28toggle\x29"), t("dislike")] : '',
];
if ($shareable) {
$buttons['share'] = array(t('Share this'), t('share'));
$buttons['share'] = [t('Share this'), t('share')];
}
// If a contact isn't writable, we cannot send a like or dislike to it
@ -322,7 +322,7 @@ class Post extends BaseObject
// Disable features that aren't available in several networks
/// @todo Add NETWORK_DIASPORA when it will pass this information
if (!in_array($item["item_network"], array(NETWORK_DFRN)) && isset($buttons["dislike"])) {
if (!in_array($item["item_network"], [NETWORK_DFRN]) && isset($buttons["dislike"])) {
unset($buttons["dislike"]);
$isevent = false;
$tagger = '';
@ -336,7 +336,7 @@ class Post extends BaseObject
unset($buttons["like"]);
}
$tmp_item = array(
$tmp_item = [
'template' => $this->getTemplate(),
'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
'tags' => $item['tags'],
@ -401,14 +401,14 @@ class Post extends BaseObject
'received' => $item['received'],
'commented' => $item['commented'],
'created_date' => $item['created'],
);
];
$arr = array('item' => $item, 'output' => $tmp_item);
$arr = ['item' => $item, 'output' => $tmp_item];
call_hooks('display_item', $arr);
$result = $arr['output'];
$result['children'] = array();
$result['children'] = [];
$children = $this->getChildren();
$nb_children = count($children);
if ($nb_children > 0) {
@ -774,7 +774,7 @@ class Post extends BaseObject
}
$template = get_markup_template($this->getCommentBoxTemplate());
$comment_box = replace_macros($template, array(
$comment_box = replace_macros($template, [
'$return_path' => $a->query_string,
'$threaded' => $this->isThreaded(),
'$jsreload' => '',
@ -801,7 +801,7 @@ class Post extends BaseObject
'$sourceapp' => t($a->sourcename),
'$ww' => $conv->getMode() === 'network' ? $ww : '',
'$rand_num' => random_digits(12)
));
]);
}
return $comment_box;

View file

@ -17,7 +17,7 @@ require_once 'include/text.php';
*/
class Thread extends BaseObject
{
private $parents = array();
private $parents = [];
private $mode = null;
private $writable = false;
private $profile_owner = 0;
@ -172,7 +172,7 @@ class Thread extends BaseObject
public function getTemplateData($conv_responses)
{
$a = self::getApp();
$result = array();
$result = [];
$i = 0;
foreach ($this->parents as $item) {