fix: noverify --fix

This commit is contained in:
origami11@yandex.ru 2024-06-14 14:12:02 +03:00
parent 5aff28d2b8
commit 117640a755
44 changed files with 174 additions and 174 deletions

View file

@ -5,6 +5,6 @@ namespace ctiso;
class Arr {
static function get($data, $key, $default = null) {
return isset($data[$key]) ? $data[$key] : $default;
return $data[$key] ?? $default;
}
}

View file

@ -76,7 +76,7 @@ class Collection implements \ArrayAccess
public function clear()
{
$this->data = array();
$this->data = [];
}
public function offsetSet($key, $value): void
@ -96,6 +96,6 @@ class Collection implements \ArrayAccess
public function offsetGet($key): mixed
{
return isset($this->data[$key]) ? $this->data[$key] : null;
return $this->data[$key] ?? null;
}
}

View file

@ -39,7 +39,7 @@ class HttpResponse
if (isset($this->param['Transfer-Encoding']) && $this->param['Transfer-Encoding'] == 'chunked') {
//$this->data = substr($this->response, $this->offset);
$index = hexdec($this->getLine());
$chunk = array();
$chunk = [];
while ($index > 0) {
$chunk [] = substr($this->response, $this->offset, $index);
$this->offset += $index;

View file

@ -82,7 +82,7 @@ class Action
}
public function addSuggest(View $view, $name) {
$suggest = array();
$suggest = [];
$file = Path::join($this->modulePath, 'help', $name . '.suggest');
if (file_exists($file)) {
$view->suggestions = include($file);
@ -107,10 +107,10 @@ class Action
$basePath = $this->config->get('system', 'path');
$webPath = $this->config->get('system', 'web');
$list = array(
$list = [
Path::join($this->modulePath, 'templates', $this->viewPathPrefix) => Path::join($webPath, "modules", $this->name, 'templates', $this->viewPathPrefix),
Path::join($basePath, "templates") => Path::join($webPath, "templates")
);
];
// Поиск файла для шаблона
foreach($list as $ospath => $path) {
@ -130,14 +130,14 @@ class Action
$tpl->set('script', $scriptPath); // Путь к файлам скриптов
$tpl->set('template', $path); // Путь к файлам текущего шаблона
$tpl->setAlias(array(
$tpl->setAlias([
'assets' => $stylePath,
'icons' => $iconsPath,
'script' => $scriptPath,
// Для media и template поиск происходит как для файлов шаблонов
'media' => $list,
'template' => $list
));
]);
$tpl->loadImports(Path::skipExtension($template) . ".import");
@ -185,7 +185,7 @@ class Action
}
public function forward($action, HttpRequest $args) {
$value = call_user_func(array($this, $action), $args);
$value = call_user_func([$this, $action], $args);
return $value;
}
@ -207,7 +207,7 @@ class Action
* 'mode' означает что элемент до отправки обрабатывается javascript
* @return Url|null
*/
public function nUrl($name, array $param = array())
public function nUrl($name, array $param = [])
{
$access/*: ActionAccess*/ = $this->access;
$url = new Url();
@ -220,7 +220,7 @@ class Action
array_shift($moduleName);
}
}
$param = array_merge(array('module' => implode("\\", $moduleName), "action" => $name), $param);
$param = array_merge(['module' => implode("\\", $moduleName), "action" => $name], $param);
$url->setParent($this->part);
$url->setQuery($param);
@ -239,9 +239,9 @@ class Action
* @example ?action=$name&mode=ajax
* {$param[i].key = $param[i].value}
*/
public function aUrl($name, array $param = array())
public function aUrl($name, array $param = [])
{
return $this->nUrl($name, array_merge(array('mode' => 'ajax'), $param));
return $this->nUrl($name, array_merge(['mode' => 'ajax'], $param));
}
/**
@ -260,7 +260,7 @@ class Action
$action = self::ACTION_PREFIX . $request->getAction();
foreach ($this->helpers as $helper) {
if (method_exists($helper, $action)) {
return call_user_func(array($helper, $action), $request, $this);
return call_user_func([$helper, $action], $request, $this);
} else {
return $helper->actionIndex($request, $this); // Вместо return response ???
}

View file

@ -82,7 +82,7 @@ class Component
$this->before();
if (method_exists($this, $action)) {
return call_user_func(array($this, $action), $crequest);
return call_user_func([$this, $action], $crequest);
} else {
return $this->actionIndex($crequest);
}
@ -180,17 +180,17 @@ class Component
}
public function options($key, $val, $res/*: PDOStatement*/) {
$result = array();
$result = [];
while($res->next()) {
$result[] = array('value' => $res->getString($key), 'name' => $res->getString($val));
$result[] = ['value' => $res->getString($key), 'name' => $res->getString($val)];
}
return $result;
}
public function optionsPair($list, $selected = false) {
$result = array();
$result = [];
foreach ($list as $key => $value) {
$result [] = array('value' => $key, 'name' => $value, 'selected' => $key == $selected);
$result [] = ['value' => $key, 'name' => $value, 'selected' => $key == $selected];
}
return $result;
}
@ -213,7 +213,7 @@ class Component
return $settings;
}
}
return array('parameter' => []);
return ['parameter' => []];
}
/**
@ -238,7 +238,7 @@ class Component
$offset = strpos($expression, '?');
$url = parse_url($expression);
$arguments = array();
$arguments = [];
if ($offset === false) {
$path = $expression;
} else if (is_int($offset)) {
@ -259,34 +259,34 @@ class Component
// require_once ($path);
$component = new $className();
$component->viewPath = array($config->get('site', 'components') . '/' . $name . '/');
$component->webPath = array($config->get('site', 'components.web') . '/' . $name);
$component->viewPath = [$config->get('site', 'components') . '/' . $name . '/'];
$component->webPath = [$config->get('site', 'components.web') . '/' . $name];
$component->COMPONENTS_WEB = $config->get('site', 'web') . '/components/';
} else {
$component = new $className();
$template = $component->getTemplateName($site->config);
$component->viewPath = array(
$component->viewPath = [
// Сначало ищем локально
$config->get('site', 'templates') . '/'. $template . '/_components/' . $name . '/',
$config->get('site', 'components') . '/' . $name . '/',
// Потом в общем хранилище
$config->get('system', 'templates'). '/' . $template . '/_components/' . $name . '/',
$config->get('system', 'components') . '/' . $name . '/',
);
];
if (defined('COMPONENTS_WEB')) {
$component->webPath = array(
$component->webPath = [
// Сначало локально
$config->get('site', 'templates.web') . '/' . $template . '/_components/' . $name,
$config->get('site', 'components.web') . '/' . $name,
// Потом в общем хранилище
$config->get('system', 'templates.web') . '/' . $template . '/_components/' . $name,
$config->get('system', 'components.web') . '/' . $name,
);
];
$component->COMPONENTS_WEB = $config->get('system', 'components.web');
} else {
$component->webPath = array('', $config->get('site', 'components.web') . '/' . $name, '', '');
$component->webPath = ['', $config->get('site', 'components.web') . '/' . $name, '', ''];
}
}
@ -343,13 +343,13 @@ class Component
{
$arr = $request->r->export('get');
$param = array();
$param = [];
$parameter/*: Collection*/ = $this->parameter;
foreach($parameter->export() as $key => $value) {
$param[$key] = $value;
}
$data = array();
$data = [];
foreach($arr as $key => $value) {
if (is_array($value)) {
$data[$key] = Arr::get($value, $this->component_id);

View file

@ -73,7 +73,7 @@ class Installer
// Устанавливает обновления если есть
function doUpdates($name, $force = false) // Установка модуля
{
$result = array();
$result = [];
$setup = $this->getSetupFile($name);
if (file_exists($setup) && ($this->isChanged($name) || $force)) {
@ -89,7 +89,7 @@ class Installer
$version_old = $item['version'];
} else {
$version_old = "0.0";
$registry->writeKey(array($name), array());
$registry->writeKey([$name], []);
}
if (version_compare($version_old, $settings->get('version'), "!=")) {
$sql = $settings->get('sql');

View file

@ -16,7 +16,7 @@ class Request {
$v = $this->r->get($name);
$id = $this->id;
if ($id && is_array($v)) {
return isset($v[$id]) ? $v[$id] : $def;
return $v[$id] ?? $def;
}
return $v;
}

View file

@ -54,17 +54,17 @@ class Service
}
public function options($key, $val, $res/*: PDOStatement*/) {
$result = array();
$result = [];
while($res->next()) {
$result[] = array('value' => $res->getInt($key), 'name' => $res->getString($val));
$result[] = ['value' => $res->getInt($key), 'name' => $res->getString($val)];
}
return $result;
}
public function optionsPair($list, $selected = false) {
$result = array();
$result = [];
foreach ($list as $key => $value) {
$result [] = array('value' => $key, 'name' => $value, 'selected' => $key == $selected);
$result [] = ['value' => $key, 'name' => $value, 'selected' => $key == $selected];
}
return $result;
}
@ -75,7 +75,7 @@ class Service
$settings = json_decode(File::getContents($filename), true);
return $settings;
}
return array();
return [];
}
}

View file

@ -25,7 +25,7 @@ class Database extends PDO
parent::__construct($dsn, $username, $password);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array(PDOStatement::class, array()));
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, array()]);
}
function prepare(string $sql, array $options = []): PDOStatement|false {
@ -112,7 +112,7 @@ class Database extends PDO
return null;
}
$pg = $this->isPostgres();
$prep = array();
$prep = [];
foreach ($values as $key => $value) {
$result = null;
if(is_bool($value)) {
@ -139,7 +139,7 @@ class Database extends PDO
. ") VALUES (" . implode(",", array_keys($prep)). ")";
if ($return_id) {
if ($this->isPostgres()){
$sql = $sql." RETURNING $index";
$sql .= " RETURNING $index";
}
}
$stmt = $this->prepare($sql);

View file

@ -23,7 +23,7 @@ class Manager
$this->DropTableQuery($action["table_name"], true);
break;
case "createTable":
$constraints = isset($action["constraints"]) ? $action["constraints"] : null;
$constraints = $action["constraints"] ?? null;
$this->CreateTableQuery($action["table_name"], $action["fields"], $constraints);
break;
case "addColumn":
@ -70,7 +70,7 @@ class Manager
{
$statement = "DROP TABLE IF EXISTS ".$table;
if ($this->db->isPostgres()&&$cascade) {
$statement = $statement." CASCADE";
$statement .= " CASCADE";
}
$this->db->query($statement);
}
@ -201,7 +201,7 @@ class Manager
{
$pg = $this->db->isPostgres();
$result/*: array*/ = array();
$result/*: array*/ = [];
$data/*: array*/ = $this->db->fetchAllArray("SELECT * FROM ".$table_name.";");
if (!$pg) {
@ -219,11 +219,11 @@ class Manager
}
}
foreach ($data as $r) {
$result[] = array(
$result[] = [
"type" => "insert",
"table_name" => $table_name,
"values" => $r
);
];
}
return $result;
}
@ -246,7 +246,7 @@ class Manager
public function DumpInserts()
{
$table_names = $this->GetAllTableNames();
$result = array();
$result = [];
foreach ($table_names as $table_name) {
$result = array_merge($result, $this->DumpTable($table_name));
}

View file

@ -84,7 +84,7 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate
}
function getString($name) {
return isset($this->fields[$name]) ? $this->fields[$name]: null;
return $this->fields[$name] ?? null;
}
function getBoolean($name) {

View file

@ -22,15 +22,15 @@ class Statement
}
function setInt($n, $value) {
$this->binds [] = array($n, $value, PDO::PARAM_INT);
$this->binds [] = [$n, $value, PDO::PARAM_INT];
}
function setString($n, $value) {
$this->binds [] = array($n, $value, PDO::PARAM_STR);
$this->binds [] = [$n, $value, PDO::PARAM_STR];
}
function setBlob($n, $value) {
$this->binds [] = array($n, $value, PDO::PARAM_LOB);
$this->binds [] = [$n, $value, PDO::PARAM_LOB];
}
function setLimit($limit) {

View file

@ -25,7 +25,7 @@ class Document {
function setStyle ($name, array $values, $type = 'Interior')
{
if(!isset($this->styles[$name])) {
$this->styles[$name] = array();
$this->styles[$name] = [];
}
$this->styles[$name][$type] = $values;
}
@ -70,7 +70,7 @@ class Document {
function clean ($s) {
assert(is_string($s));
return strtr($s, array ("\n" => "
"));
return strtr($s, ["\n" => "
"]);
}
/**

View file

@ -142,7 +142,7 @@ class Table
/**
* Добавляет строку к таблице
*/
function addRow($index = 1, array $data = array(""))
function addRow($index = 1, array $data = [""])
{
assert(is_numeric($index) && $index > 0);
$offset = $this->getRows() + 1;
@ -196,7 +196,7 @@ class Table
* @return int
*/
function getColumns() {
return max(array_map(array($this, 'getRowCells'), $this->rows));
return max(array_map([$this, 'getRowCells'], $this->rows));
}
function encode($s)

View file

@ -46,7 +46,7 @@ class Authorization {
$signParts = ['HTTP_USER_AGENT'];
foreach ($signParts as $signPart) {
$rawSign .= '::' . (isset($_SERVER[$signPart]) ? $_SERVER[$signPart] : 'none');
$rawSign .= '::' . ($_SERVER[$signPart] ?? 'none');
}
return $rawSign;

View file

@ -56,7 +56,7 @@ class Login extends Filter
if ($this->role->access == 'site_root' && defined('PARENT_PATH')) {
$s = new Settings(PARENT_PATH . '/settings.json');
$s->read();
$dsn = $s->readKey(array('system', 'dsn'));
$dsn = $s->readKey(['system', 'dsn']);
$db = Database::getConnection($dsn);
$user = $db->fetchOneArray("SELECT * FROM users WHERE login = :login", ['login' => $login]);
@ -143,7 +143,7 @@ class Login extends Filter
$logged = $this->isLoggin($request);
if ($request->get('action') == 'user_access') {
if ($logged) {
$result = array();
$result = [];
$result['fullname'] = $this->user->getString('patronymic') . " " . $this->user->getString('firstname');
$result['email'] = $this->user->getString('email');
$result['hash'] = sha1(self::SESSION_BROWSER_SIGN_SECRET . $this->user->getString('email'));
@ -155,9 +155,9 @@ class Login extends Filter
if ($request->get('action') == 'relogin') {
if ($logged) {
return json_encode(array('result' => 'ok', 'message' => "Авторизация успешна"));
return json_encode(['result' => 'ok', 'message' => "Авторизация успешна"]);
} else {
return json_encode(array('result' => 'fail', 'message' => "Неправильное имя пользователя или пароль"));
return json_encode(['result' => 'fail', 'message' => "Неправильное имя пользователя или пароль"]);
}
}
@ -166,14 +166,14 @@ class Login extends Filter
// Действия по умолчанию !! Возможно переход на форму регистрации
if ($request->get('mode') == 'ajax') {
if (!$this->requestIsWhite($request)) {
return json_encode(array('result' => 'fail', 'message' =>"NOT_AUTHORIZED"));
return json_encode(['result' => 'fail', 'message' =>"NOT_AUTHORIZED"]);
}
} else {
$request->set('module', 'login');
$request->set('mode', $this->mode);
}
} else if (isset($_SERVER['HTTP_REFERER'])) {
$arr = array();
$arr = [];
parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY) ?? '', $arr);
if (isset($arr['back_page']) && $request->get('mode') != 'ajax') {
$request->redirect($arr['back_page']);

View file

@ -23,7 +23,7 @@ class Field
public $alias = array();
/** @phpstan-ignore-next-line */
public function __construct ($input = array(), $factory = null)
public function __construct ($input = [], $factory = null)
{
$this->default = null;
if (isset($input['validate'])) {
@ -33,7 +33,7 @@ class Field
$this->fieldset = $input['fieldset'];
}
// Инициализация свойст обьетка
foreach (array('label', 'name', 'type', 'description') as $name) {
foreach (['label', 'name', 'type', 'description'] as $name) {
if (isset($input[$name])) {
$this->$name = $input[$name];
}

View file

@ -35,7 +35,7 @@ class Form extends View {
*/
public function __construct()
{
$this->constructor = array(
$this->constructor = [
'input' => 'ctiso\\Form\\Input',
// input с проверкой на заполненность
'inputreq' => 'ctiso\\Form\\Input',
@ -64,7 +64,7 @@ class Form extends View {
'chooser' => 'ctiso\\Form\\Input',
'select_chooser' => 'ctiso\\Form\\SelectOne',
'html_text' => 'ctiso\\Form\\HtmlText'
);
];
}
@ -168,7 +168,7 @@ class Form extends View {
{
foreach ($schema as $key => $conv) {
list($value, $type) = $conv;
$this->field [$key]->setValue(call_user_func(array('ctiso\\Primitive', 'from_' . $type), $data->$value));
$this->field [$key]->setValue(call_user_func(['ctiso\\Primitive', 'from_' . $type], $data->$value));
}
}

View file

@ -25,9 +25,9 @@ class Select extends Field
}
public function optionsPair($list, $selected = false) {
$result = array();
$result = [];
foreach ($list as $key => $value) {
$result [] = array('value' => $key, 'name' => $value, 'selected' => $key == $selected);
$result [] = ['value' => $key, 'name' => $value, 'selected' => $key == $selected];
}
return $result;
}

View file

@ -8,7 +8,7 @@ class SelectMany extends Select
function setValue($value)
{
// Установить selected у options
if (!is_array($value)) { $value = array($value); }
if (!is_array($value)) { $value = [$value]; }
$this->value = $value;
foreach ($this->options as &$option) {
$option['selected'] = (in_array($option['value'], $value));

View file

@ -54,7 +54,7 @@ class partial {
function apply() {
$params = func_get_args();
$result = array();
$result = [];
$count = count($this->params);
for($i = 0, $j = 0; $i < $count; $i++) {
if ($this->params[$i] == __) {
@ -92,7 +92,7 @@ class Functions {
static function partial($_rest) {
$closure = new partial(func_get_args());
return array($closure, 'apply');
return [$closure, 'apply'];
}
@ -103,7 +103,7 @@ class Functions {
*/
static function compose($_rest) {
$closure = new compose(func_get_args());
return array($closure, 'apply');
return [$closure, 'apply'];
}
/**
@ -113,7 +113,7 @@ class Functions {
*/
static function rcurry($_rest) {
$closure = new right(func_get_args ());
return array($closure, 'apply');
return [$closure, 'apply'];
}
/**
@ -123,7 +123,7 @@ class Functions {
*/
static function lcurry($_rest) {
$closure = new left(func_get_args ());
return array($closure, 'apply');
return [$closure, 'apply'];
}
/**
@ -134,8 +134,8 @@ class Functions {
* @return mixed
*/
static function partition($pred, $lst) {
$left = array ();
$right = array ();
$left = [];
$right = [];
foreach ($lst as $n) {
if (call_user_func($pred, $n) !== false) {
$left [] = $n;
@ -143,7 +143,7 @@ class Functions {
$right [] = $n;
}
}
return array ($left, $right);
return [$left, $right];
}
/**
@ -191,7 +191,7 @@ class Functions {
}
static function __self($name, $o) {
return call_user_func(array($o, $name));
return call_user_func([$o, $name]);
}
static function concat(/* $args ...*/) {
@ -225,7 +225,7 @@ class Functions {
* @return mixed
*/
static function key_values($key, $array/*: array|ArrayIterator*/) {
$result = array();
$result = [];
foreach($array as $item) {
$result[] = $item[$key];
@ -234,7 +234,7 @@ class Functions {
}
static function key_values_object($key, $array/*: array|ArrayIterator*/) {
$result = array();
$result = [];
foreach($array as $item) {
$result[] = $item->{$key};
@ -243,7 +243,7 @@ class Functions {
}
static function assoc_key_values($key, $value, $array) {
$result = array();
$result = [];
foreach ($array as $item) {
$result[$item[$key]] = $item[$value];
}
@ -251,7 +251,7 @@ class Functions {
}
static function assoc_key($key, $array) {
$result = array();
$result = [];
foreach ($array as $item) {
$result[$item[$key]] = $item;
}
@ -307,7 +307,7 @@ class Functions {
static function span($length, array $array) {
assert(is_int($length));
$result = array();
$result = [];
$count = count($array);
for($i = 0; $i < $count; $i += $length) {
$result [] = array_slice($array, $i, $length);
@ -334,7 +334,7 @@ class Functions {
*/
static function array_usearch($cb, array $hs, $strict = false) {
foreach($hs as $key => $value) {
if (call_user_func_array($cb, array($value, $key, $strict))) return $key;
if (call_user_func_array($cb, [$value, $key, $strict])) return $key;
}
return null;
}
@ -350,7 +350,7 @@ class Functions {
*/
static function key_unique_values ($name, $table) {
// Ищем уникальные значения для заданного ключа
$keys = array ();
$keys = [];
foreach ($table as $row) {
if (!in_array ($row[$name], $keys))
$keys[] = $row[$name];
@ -375,7 +375,7 @@ class Functions {
* @return mixed
*/
static function hash_key ($key_name,$array/*: array */) {
$result = array();
$result = [];
foreach($array as $value) {
$result[$value[$key_name]] = $value;

View file

@ -24,7 +24,7 @@ class Manager extends Filter
*/
public function addConditionGet($get, Filter $layout)
{
$this->addCondition(Functions::rcurry(array($this, 'checkGet'), $get), $layout);
$this->addCondition(Functions::rcurry([$this, 'checkGet'], $get), $layout);
}
/**
@ -32,7 +32,7 @@ class Manager extends Filter
*/
public function addConditionXHR($get, Filter $layout)
{
$this->addCondition(Functions::rcurry(array($this, 'checkXHR'), $get), $layout);
$this->addCondition(Functions::rcurry([$this, 'checkXHR'], $get), $layout);
}
public function checkGet($request/*: HttpRequest*/, $get)
@ -59,7 +59,7 @@ class Manager extends Filter
*/
public function addCondition($get, Filter $layout)
{
$this->condition [] = array($get, $layout);
$this->condition [] = [$get, $layout];
}
/**

View file

@ -96,7 +96,7 @@ class Mail
$file = fopen($filename, "rb");
if (is_resource($file)) {
$data = fread($file, filesize($filename));
$this->attachment [] = ($name) ? array($data, $name) : array($data, basename($filename));
$this->attachment [] = ($name) ? [$data, $name] : [$data, basename($filename)];
}
}
}
@ -113,7 +113,7 @@ class Mail
{
assert(is_string($name));
$this->attachment [] = array($data, $name);
$this->attachment [] = [$data, $name];
}
function quote($var, $val)
@ -125,12 +125,12 @@ class Mail
* Общий формат тегов MIME
* @see http://tools.ietf.org/html/rfc2045
*/
function mimeTag($name, $value, array $args = array())
function mimeTag($name, $value, array $args = [])
{
assert (is_string($name));
assert (is_string($value));
return $name . ": " . $value . implode("", array_map(array($this, 'quote'), array_keys($args), array_values($args))) . PHP_EOL;
return $name . ": " . $value . implode("", array_map([$this, 'quote'], array_keys($args), array_values($args))) . PHP_EOL;
}
/**
@ -148,7 +148,7 @@ class Mail
function getMessage()
{
$message = "--".$this->uniqid . PHP_EOL;
$message .= $this->mimeTag("Content-Type", $this->type, array ('charset' => $this->encoding));
$message .= $this->mimeTag("Content-Type", $this->type, ['charset' => $this->encoding]);
$message .= $this->mimeTag("Content-Transfer-Encoding", "8bit");
$message .= PHP_EOL . $this->content . PHP_EOL . PHP_EOL;
@ -159,9 +159,9 @@ class Mail
foreach ($this->attachment as $value) {
list($data, $name) = $value;
$message .= "--" . $this->uniqid . PHP_EOL;
$message .= $this->mimeTag("Content-Type", "application/octet-stream", array ('name' => basename($name)));
$message .= $this->mimeTag("Content-Type", "application/octet-stream", ['name' => basename($name)]);
$message .= $this->mimeTag("Content-Transfer-Encoding", "base64");
$message .= $this->mimeTag("Content-Disposition", "attachment", array ('filename' => basename($name)));
$message .= $this->mimeTag("Content-Disposition", "attachment", ['filename' => basename($name)]);
$message .= PHP_EOL . chunk_split(base64_encode($data)) . PHP_EOL;
}
@ -180,7 +180,7 @@ class Mail
if (is_string($this->_notify)) {
$head .= $this->mimeTag("Disposition-Notification-To", "\"" . $this->_notify . "\" <" . $this->_from . ">");
}
$head .= $this->mimeTag("Content-Type", "multipart/mixed", array ("boundary" => $this->uniqid));
$head .= $this->mimeTag("Content-Type", "multipart/mixed", ["boundary" => $this->uniqid]);
if ($this->copy) {
$head .= $this->mimeTag("BCC", $this->copy);
}
@ -218,6 +218,6 @@ class Mail
foreach ($this->attachment as $key => &$value) {
unset($this->attachment[$key]);
}
$this->attachment = array();
$this->attachment = [];
}
}

View file

@ -16,7 +16,7 @@ class Numbers
static function prefix($prefix, array $array, $key = false)
{
$result = array();
$result = [];
$count = count($array);
for ($i = 0; $i < $count; $i++) {
$result [] = call_user_func($prefix, $i + 1) . '. ' . $array[$i];

View file

@ -138,7 +138,7 @@ class Path
*/
public static function optimize($path) //
{
$result = array();
$result = [];
foreach ($path as $n) {
switch ($n) {
// Может быть относительным или абсолютным путем
@ -254,7 +254,7 @@ class Path
$self_path = $self->getParts();
$list_path = $list->getParts();
$result = array();
$result = [];
$count = count($list_path);
for ($i = 0; $i < $count; $i++) {
if (($i >= count($self_path)) || $list_path[$i] != $self_path[$i]) {
@ -286,7 +286,7 @@ class Path
static function fromJoin($_rest) {
$args = func_get_args();
$result = array();
$result = [];
$parts0 = new Path(array_shift($args));
$result [] = $parts0->getParts();
foreach ($args as $file) {
@ -371,9 +371,9 @@ class Path
*
* @returnarray
*/
public function getContent($allow = null, $ignore = array())
public function getContent($allow = null, $ignore = [])
{
$ignore = array_merge(array(".", ".."), $ignore);
$ignore = array_merge([".", ".."], $ignore);
return self::fileList($this->__toString(), $allow, $ignore);
}
@ -385,10 +385,10 @@ class Path
*
* @return array
*/
function getContentRec($allow = null, $ignore = array())
function getContentRec($allow = null, $ignore = [])
{
$result = array ();
$ignore = array_merge(array (".", ".."), $ignore);
$result = [];
$ignore = array_merge([".", ".."], $ignore);
self::fileListAll($result, $this->__toString(), $allow, $ignore);
return $result;
}
@ -397,7 +397,7 @@ class Path
protected static function fileList($base, &$allow, &$ignore)
{
if ($base == '') $base = '.';
$result = array ();
$result = [];
$handle = opendir($base);
if (is_resource($handle)) {
while (true) {

View file

@ -71,7 +71,7 @@ class Primitive {
{
$result = 0;
$tmp = array();
$tmp = [];
if (preg_match('/(\d+)-(\d+)-(\d+)T(\d+):(\d+)Z/', $value, $tmp)) {
if (checkdate((int)$tmp[2], (int)$tmp[3], (int)$tmp[1])) {
$result = mktime((int)$tmp[4], (int)$tmp[5], 0, (int)$tmp[2], (int)$tmp[3], (int)$tmp[1]);
@ -112,7 +112,7 @@ class Primitive {
// array
public static function to_array($value)
{
return (is_array($value)) ? $value : array();
return (is_array($value)) ? $value : [];
}
public static function from_array($value)

View file

@ -43,10 +43,10 @@ class User implements UserInterface
$this->name = $result->getString('login');
$this->id = $result->getInt('id_user');
$this->password = $result->getString('password');
$this->fullname = implode(' ', array(
$this->fullname = implode(' ', [
$result->getString('surname'),
$result->getString('firstname'),
$result->getString('patronymic')));
$result->getString('patronymic')]);
return $result;
}
return null;

View file

@ -25,7 +25,7 @@ class Settings
$fileFormat = ['theme' => 'json'];
$extname = pathinfo($file, PATHINFO_EXTENSION);
$this->format = $format ? $format : Arr::get($fileFormat, $extname, $extname);
$this->format = $format ?: Arr::get($fileFormat, $extname, $extname);
$this->file = $file;
}
@ -40,7 +40,7 @@ class Settings
return false;
}
// Не include_once т.к читать настройки можно несколько раз
$settings = array();
$settings = [];
if ($this->format == 'json') {
$settings = json_decode(File::getContents($this->file), true);
} else {
@ -73,7 +73,7 @@ class Settings
$name = array_shift($key);
if (is_array($value)) {
if (!isset($data[$name])) {
$data[$name] = array();
$data[$name] = [];
}
$this->merge($data[$name], $value);
} else {
@ -88,7 +88,7 @@ class Settings
{
foreach ($value as $key => $subvalue) {
if (is_array($subvalue)) {
if (! isset($data[$key])) $data[$key] = array();
if (! isset($data[$key])) $data[$key] = [];
$this->merge($data[$key], $subvalue);
} else {
$data[$key] = $subvalue;
@ -132,7 +132,7 @@ class Settings
*/
public function readKeyList(...$key)
{
$result = array();
$result = [];
foreach ($this->data as $name => $value) {
$output = $this->readKeyData($key, $value);
if ($output) {

View file

@ -48,11 +48,11 @@ class Setup
array_push($this->stack, $this->node);
$this->registerAction('copy', array($this, 'copyFile'));
$this->registerAction('make-directory', array($this, 'makeDirectory'));
$this->registerAction('make-link', array($this, 'makeLink'));
$this->registerAction('include', array($this, 'includeFile'));
$this->registerAction('when', array($this, 'testWhen'));
$this->registerAction('copy', [$this, 'copyFile']);
$this->registerAction('make-directory', [$this, 'makeDirectory']);
$this->registerAction('make-link', [$this, 'makeLink']);
$this->registerAction('include', [$this, 'includeFile']);
$this->registerAction('when', [$this, 'testWhen']);
}
/**
@ -87,7 +87,7 @@ class Setup
public function fileContent($file, array $tpl)
{
$result = $this->zip->getFromName($file);
$result = preg_replace_callback('/\{\{\s*(\*?)(\w+)\s*\}\}/', array($this, 'replaceFn'), $result);
$result = preg_replace_callback('/\{\{\s*(\*?)(\w+)\s*\}\}/', [$this, 'replaceFn'], $result);
return $result;
}
@ -114,9 +114,9 @@ class Setup
*/
function resolve($attributes)
{
$result = array();
$result = [];
foreach ($attributes as $key => $value) {
$result [$key] = preg_replace_callback("/\\\${(\w+)}/", array($this, 'replaceVariable'), $value);
$result [$key] = preg_replace_callback("/\\\${(\w+)}/", [$this, 'replaceVariable'], $value);
}
return $result;
}
@ -139,7 +139,7 @@ class Setup
{
$attributes = $node->attributes();
array_push($this->stack, $node);
$this->callAction($node->getName(), array($this->resolve($attributes)));
$this->callAction($node->getName(), [$this->resolve($attributes)]);
array_pop($this->stack);
}
}

View file

@ -33,21 +33,21 @@ class SortRecord
function sort(&$list)
{
return usort($list, array($this, 'compare'));
return usort($list, [$this, 'compare']);
}
function sortKeys(&$list)
{
return usort($list, array($this, 'compareKeys'));
return usort($list, [$this, 'compareKeys']);
}
function group(&$list, $key, $types)
{
$groups = array();
$groups = [];
foreach ($types as $name) {
$groups[$name] = array();
$groups[$name] = [];
}
$groups['_any_'] = array();
$groups['_any_'] = [];
foreach ($list as $item) {
if (isset($groups[$item[$key]])) {
$groups[$item[$key]][] = $item;
@ -55,7 +55,7 @@ class SortRecord
$groups['_any_'][] = $item;
}
}
$result = array();
$result = [];
foreach ($groups as $value) {
$result = array_merge($result, $value);
}

View file

@ -25,7 +25,7 @@ class TableTree {
$name = array_shift ($level);
$keys = Functions::key_unique_values($name, $table);
$data = array ();
$data = [];
foreach ($keys as $index) {
list($rows, $table) = Functions::partition (Functions::lcurry(['\ctiso\Functions', '__index'], $index, $name), $table);
// $rows = array_filter ($table, lcurry('__index', intval($index), $name));

View file

@ -77,9 +77,9 @@ class Tales {
/* Регистрация нового префикса для подключения компонента */
$tales = PHPTAL_TalesRegistry::getInstance();
$tales->registerPrefix('component', array('ctiso\\Tales_Component', 'component'));
$tales->registerPrefix('date', array('ctiso\\Tales_DateTime', 'date'));
$tales->registerPrefix('time', array('ctiso\\Tales_DateTime', 'time'));
$tales->registerPrefix('assets', array('ctiso\\Tales_Assets', 'assets'));
$tales->registerPrefix('component', ['ctiso\\Tales_Component', 'component']);
$tales->registerPrefix('date', ['ctiso\\Tales_DateTime', 'date']);
$tales->registerPrefix('time', ['ctiso\\Tales_DateTime', 'time']);
$tales->registerPrefix('assets', ['ctiso\\Tales_Assets', 'assets']);
}
}

View file

@ -32,8 +32,8 @@ class Drawing
// self::drawrectnagle($image, $left, $top, $max_width, $max_height, array(0xFF,0,0));
$text_lines = explode("\n", $text); // Supports manual line breaks!
$lines = array();
$line_widths = array();
$lines = [];
$line_widths = [];
$largest_line_height = 0;
foreach ($text_lines as $block) {
@ -54,7 +54,7 @@ class Drawing
if ($line_width > $max_width && !$first_word) {
$lines[] = $current_line;
$line_widths[] = $last_width ? $last_width : $line_width;
$line_widths[] = $last_width ?: $line_width;
$current_line = $item;
} else {
$current_line .= ($first_word ? '' : ' ') . $item;

View file

@ -65,7 +65,7 @@ class SQLStatementExtractor {
*/
protected static function extractStatements($lines) {
$statements = array();
$statements = [];
$sql = "";
foreach($lines as $line) {

View file

@ -7,9 +7,9 @@ class StringUtil {
// from creole
static function strToArray($str) {
$str = substr($str, 1, -1); // remove { }
$res = array();
$res = [];
$subarr = array();
$subarr = [];
$in_subarr = 0;
$toks = explode(',', $str);
@ -24,7 +24,7 @@ class StringUtil {
if ('}' !== substr($tok, -1, 1)) {
$in_subarr++;
// if sub-array has more than one element
$subarr[$in_subarr] = array();
$subarr[$in_subarr] = [];
$subarr[$in_subarr][] = $tok;
} else {
$res[] = static::strToArray($tok);
@ -83,7 +83,7 @@ class StringUtil {
static function encodestring($st) {
$st = self::mb_strtr($st,"абвгдеёзийклмнопрстуфхъыэ !+()", "abvgdeeziyklmnoprstufh_ie_____");
$st = self::mb_strtr($st,"АБВГДЕЁЗИЙКЛМНОПРСТУФХЪЫЭ", "ABVGDEEZIYKLMNOPRSTUFH_IE");
$st = strtr($st, array(
$st = strtr($st, [
" " => '_',
"." => '_',
"," => '_',
@ -101,7 +101,7 @@ class StringUtil {
"Щ"=>"SHCH","Ь"=>"", "Ю"=>"YU", "Я"=>"YA",
"Й"=>"i", "й"=>"ie", "ё"=>"Ye",
""=>"N"
));
]);
return strtolower($st);
}

View file

@ -6,7 +6,7 @@ class UTF8 {
static function str_split($str, $split_length = 1) {
$split_length = (int) $split_length;
$matches = array();
$matches = [];
preg_match_all('/.{'.$split_length.'}|[^\x00]{1,'.$split_length.'}$/us', $str, $matches);
return $matches[0];

View file

@ -31,7 +31,7 @@ class Code extends AbstractRule
if (is_array($_POST[$name . '_code_genre'])) {
$count = count($_POST[$name . '_code_genre']);
for($n = 0; $n < $count; $n++) {
$code = array(
$code = [
$_POST[$name . '_code_genre'][$n],
$_POST[$name . '_code_f'][$n],
$_POST[$name . '_code_i'][$n],
@ -39,14 +39,14 @@ class Code extends AbstractRule
$_POST[$name . '_code_year'][$n],
$_POST[$name . '_code_month'][$n],
$_POST[$name . '_code_day'][$n]
);
];
if (!$this->checkCode($code)) {
return false;
}
}
return true;
} else {
$code = array(
$code = [
$_POST[$name . '_code_genre'],
$_POST[$name . '_code_f'],
$_POST[$name . '_code_i'],
@ -54,7 +54,7 @@ class Code extends AbstractRule
$_POST[$name . '_code_year'],
$_POST[$name . '_code_month'],
$_POST[$name . '_code_day']
);
];
return $this->checkCode($code);
}

View file

@ -28,7 +28,7 @@ class Count extends AbstractRule
$this->max = $this->size;
}
$count = count(array_filter(array_map('trim',
explode(";", $container->get($this->field))), array($this, 'not_empty')));
explode(";", $container->get($this->field))), [$this, 'not_empty']));
return $count >= $this->size && $count <= ((int)$this->max);
}

View file

@ -31,7 +31,7 @@ class Validator
'reg' => 'ctiso\\Validator\\Rule\\PregMatch',
);
function __construct($rules = array()) {
function __construct($rules = []) {
$this->addRuleList($rules);
}
@ -100,11 +100,11 @@ class Validator
public function validate(Collection $container, $rule = null, $status = null)
{
$fields = array();
$fields = [];
if ($rule) {
$this->chain = $rule;
}
$this->errorMsg = array();
$this->errorMsg = [];
foreach ($this->chain as $rule) {
//echo $key;
if (!in_array($rule->field, $fields) && !$this->skip($rule, $container) && !$rule->isValid($container, $status)) {

View file

@ -7,7 +7,7 @@ class ListView extends View
{
function execute()
{
$result = array();
$result = [];
foreach ($this->_section as $key => $value) {
$result [] = $value->execute();
}

View file

@ -14,17 +14,17 @@ class Pages
if ($page > $n) $page = $n;
if ($page < 1) $page = 1;
$url = 'page=';
$result = array();
$result = [];
for ($i = max($page - self::$range, 1); $i <= min($n, $page + self::$range); $i++) {
$result [] = array('page' => $i, 'href' => ($i != $page) ? self::href($prefix, $url . $i) : false);
$result [] = ['page' => $i, 'href' => ($i != $page) ? self::href($prefix, $url . $i) : false];
}
return array(
return [
'all' => ($n > 1),
'list' => $result,
'first' => self::href($prefix, $url . 1),
'last' => self::href($prefix, $url . $n),
'next' => ($page == $n)? false : self::href($prefix, $url . ($page + 1)) ,
'prev' => ($page == 1)? false : self::href($prefix, $url . ($page - 1)));
'prev' => ($page == 1)? false : self::href($prefix, $url . ($page - 1))];
}
/**
@ -45,10 +45,10 @@ class Pages
*/
static function _getLimit($page, $onpage) {
if ($page <= 0) { $page = 1; }
return array(
return [
'count' => $onpage,
'start' => ($page - 1) * $onpage,
);
];
}
static function href($prefix, $x) {

View file

@ -15,7 +15,7 @@ class Top extends Composite
public function getTitle()
{
return implode(" - ", array_filter($this->doTree('_title', false), array($this, 'isNotNull')));
return implode(" - ", array_filter($this->doTree('_title', false), [$this, 'isNotNull']));
}
function getId($pref)
@ -39,10 +39,10 @@ class Top extends Composite
$this->set('scripts', array_unique($this->getScripts()));
$this->set('stylesheet', array_unique($this->getStyleSheet()));
$this->require = array('admin' => 'ma');
$this->deps = array();
$this->require = ['admin' => 'ma'];
$this->deps = [];
$startup = array();
$startup = [];
foreach ($this->_section as $s) {
if (is_string($s)) {
continue;
@ -67,7 +67,7 @@ class Top extends Composite
$script .= $value . "." . $key . " = " . json_encode($v /*, JSON_PRETTY_PRINT*/) . ";\n";
}
$init = array();
$init = [];
foreach ($s->_section as $key => $item) {
$ss /*: View*/= $item;
if ($ss->codeGenerator !== null) {

View file

@ -101,7 +101,7 @@ class View extends \stdClass
*/
protected function doTree($list, $flatten = true)
{
$result = ($flatten == true) ? $this->$list : array($this->$list);
$result = ($flatten == true) ? $this->$list : [$this->$list];
foreach ($this->_section as $value) {
if (is_object($value)) {
if ($list == '_script' || $list == '_stylesheet') {
@ -182,10 +182,10 @@ class View extends \stdClass
function loadImports($importFile)
{
$types = array(
$types = [
'js' => array($this, 'addScript'),
'css' => array($this, 'addStyleSheet')
);
];
// Подключение стилей и скриптов
if (file_exists($importFile)) {
$files = file($importFile);
@ -201,7 +201,7 @@ class View extends \stdClass
}
public function resolveAllNames($alias, $list) {
$result = array();
$result = [];
foreach($list as $item) {
$result [] = $this->resolveName($alias, $item);
}

View file

@ -30,7 +30,7 @@ class ZipFile extends ZipArchive
if (in_array($file, $this->ignore)) continue;
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
$call = (is_dir($location . $file)) ? 'addDir' : 'addFile';
call_user_func(array($this, $call), $location . $file, $name . $file);
call_user_func([$this, $call], $location . $file, $name . $file);
}
}