From 117640a75566547b70820384d6f5d9f1c8929e47 Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Fri, 14 Jun 2024 14:12:02 +0300 Subject: [PATCH] fix: noverify --fix --- src/Arr.php | 2 +- src/Collection.php | 4 ++-- src/Connection/HttpResponse.php | 2 +- src/Controller/Action.php | 22 +++++++++---------- src/Controller/Component.php | 32 +++++++++++++-------------- src/Controller/Installer.php | 4 ++-- src/Controller/Request.php | 2 +- src/Controller/Service.php | 10 ++++----- src/Database.php | 6 ++--- src/Database/Manager.php | 12 +++++----- src/Database/PDOStatement.php | 2 +- src/Database/Statement.php | 6 ++--- src/Excel/Document.php | 4 ++-- src/Excel/Table.php | 4 ++-- src/Filter/Authorization.php | 2 +- src/Filter/Login.php | 12 +++++----- src/Form/Field.php | 4 ++-- src/Form/Form.php | 6 ++--- src/Form/Select.php | 4 ++-- src/Form/SelectMany.php | 2 +- src/Functions.php | 34 ++++++++++++++--------------- src/Layout/Manager.php | 6 ++--- src/Mail.php | 18 +++++++-------- src/Numbers.php | 2 +- src/Path.php | 18 +++++++-------- src/Primitive.php | 4 ++-- src/Role/User.php | 4 ++-- src/Settings.php | 10 ++++----- src/Setup.php | 18 +++++++-------- src/SortRecord.php | 12 +++++----- src/TableTree.php | 2 +- src/Tales.php | 8 +++---- src/Tools/Drawing.php | 6 ++--- src/Tools/SQLStatementExtractor.php | 2 +- src/Tools/StringUtil.php | 10 ++++----- src/UTF8.php | 2 +- src/Validator/Rule/Code.php | 8 +++---- src/Validator/Rule/Count.php | 2 +- src/Validator/Validator.php | 6 ++--- src/View/ListView.php | 2 +- src/View/Pages.php | 12 +++++----- src/View/Top.php | 10 ++++----- src/View/View.php | 8 +++---- src/ZipFile.php | 2 +- 44 files changed, 174 insertions(+), 174 deletions(-) diff --git a/src/Arr.php b/src/Arr.php index 5a421b3..38cbb35 100644 --- a/src/Arr.php +++ b/src/Arr.php @@ -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; } } diff --git a/src/Collection.php b/src/Collection.php index 7e3b808..2f7cea3 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -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; } } diff --git a/src/Connection/HttpResponse.php b/src/Connection/HttpResponse.php index 9d6f2b8..1da2036 100644 --- a/src/Connection/HttpResponse.php +++ b/src/Connection/HttpResponse.php @@ -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; diff --git a/src/Controller/Action.php b/src/Controller/Action.php index 49f345e..c9b29eb 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -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 ??? } diff --git a/src/Controller/Component.php b/src/Controller/Component.php index a86bd14..4d168c7 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -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); diff --git a/src/Controller/Installer.php b/src/Controller/Installer.php index 72be02b..e00b705 100644 --- a/src/Controller/Installer.php +++ b/src/Controller/Installer.php @@ -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'); diff --git a/src/Controller/Request.php b/src/Controller/Request.php index 81fbc46..fb2d950 100644 --- a/src/Controller/Request.php +++ b/src/Controller/Request.php @@ -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; } diff --git a/src/Controller/Service.php b/src/Controller/Service.php index 0d527ef..331475d 100644 --- a/src/Controller/Service.php +++ b/src/Controller/Service.php @@ -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 []; } } diff --git a/src/Database.php b/src/Database.php index b641ebf..1f39d3d 100644 --- a/src/Database.php +++ b/src/Database.php @@ -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); diff --git a/src/Database/Manager.php b/src/Database/Manager.php index 9e8c044..1fbc101 100644 --- a/src/Database/Manager.php +++ b/src/Database/Manager.php @@ -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)); } diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php index b4c351b..2a6a834 100644 --- a/src/Database/PDOStatement.php +++ b/src/Database/PDOStatement.php @@ -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) { diff --git a/src/Database/Statement.php b/src/Database/Statement.php index 38652e5..e4d5ff1 100644 --- a/src/Database/Statement.php +++ b/src/Database/Statement.php @@ -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) { diff --git a/src/Excel/Document.php b/src/Excel/Document.php index dff1c3b..e149da2 100644 --- a/src/Excel/Document.php +++ b/src/Excel/Document.php @@ -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" => " "]); } /** diff --git a/src/Excel/Table.php b/src/Excel/Table.php index 96eaedf..d5a539c 100644 --- a/src/Excel/Table.php +++ b/src/Excel/Table.php @@ -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) diff --git a/src/Filter/Authorization.php b/src/Filter/Authorization.php index 814418f..8510433 100644 --- a/src/Filter/Authorization.php +++ b/src/Filter/Authorization.php @@ -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; diff --git a/src/Filter/Login.php b/src/Filter/Login.php index a891d32..b190270 100644 --- a/src/Filter/Login.php +++ b/src/Filter/Login.php @@ -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']); diff --git a/src/Form/Field.php b/src/Form/Field.php index 1b2c0d2..d4e8a34 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -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]; } diff --git a/src/Form/Form.php b/src/Form/Form.php index 3bdd32e..5f8da65 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -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)); } } diff --git a/src/Form/Select.php b/src/Form/Select.php index 44d26f4..4b00b0a 100644 --- a/src/Form/Select.php +++ b/src/Form/Select.php @@ -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; } diff --git a/src/Form/SelectMany.php b/src/Form/SelectMany.php index e0edcb9..86f4295 100644 --- a/src/Form/SelectMany.php +++ b/src/Form/SelectMany.php @@ -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)); diff --git a/src/Functions.php b/src/Functions.php index bab33e8..b547974 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -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; diff --git a/src/Layout/Manager.php b/src/Layout/Manager.php index d687113..78a4686 100644 --- a/src/Layout/Manager.php +++ b/src/Layout/Manager.php @@ -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]; } /** diff --git a/src/Mail.php b/src/Mail.php index 20cdb7c..9daae2c 100644 --- a/src/Mail.php +++ b/src/Mail.php @@ -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 = []; } } diff --git a/src/Numbers.php b/src/Numbers.php index 5fc73e4..2494706 100644 --- a/src/Numbers.php +++ b/src/Numbers.php @@ -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]; diff --git a/src/Path.php b/src/Path.php index 4e35405..09d7e29 100644 --- a/src/Path.php +++ b/src/Path.php @@ -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) { diff --git a/src/Primitive.php b/src/Primitive.php index db3228e..283d7e1 100644 --- a/src/Primitive.php +++ b/src/Primitive.php @@ -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) diff --git a/src/Role/User.php b/src/Role/User.php index 818c318..291048c 100644 --- a/src/Role/User.php +++ b/src/Role/User.php @@ -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; diff --git a/src/Settings.php b/src/Settings.php index 6033c71..1f38299 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -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) { diff --git a/src/Setup.php b/src/Setup.php index 34da2ed..8574adc 100644 --- a/src/Setup.php +++ b/src/Setup.php @@ -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); } } diff --git a/src/SortRecord.php b/src/SortRecord.php index 030bb52..3c4fe48 100644 --- a/src/SortRecord.php +++ b/src/SortRecord.php @@ -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); } diff --git a/src/TableTree.php b/src/TableTree.php index 70b3cb6..ba0ec60 100644 --- a/src/TableTree.php +++ b/src/TableTree.php @@ -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)); diff --git a/src/Tales.php b/src/Tales.php index 7cbd91c..6538d86 100644 --- a/src/Tales.php +++ b/src/Tales.php @@ -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']); } } diff --git a/src/Tools/Drawing.php b/src/Tools/Drawing.php index ab4d43d..829e3c3 100644 --- a/src/Tools/Drawing.php +++ b/src/Tools/Drawing.php @@ -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; diff --git a/src/Tools/SQLStatementExtractor.php b/src/Tools/SQLStatementExtractor.php index 746423b..771b52b 100644 --- a/src/Tools/SQLStatementExtractor.php +++ b/src/Tools/SQLStatementExtractor.php @@ -65,7 +65,7 @@ class SQLStatementExtractor { */ protected static function extractStatements($lines) { - $statements = array(); + $statements = []; $sql = ""; foreach($lines as $line) { diff --git a/src/Tools/StringUtil.php b/src/Tools/StringUtil.php index 8fb208f..35baa93 100644 --- a/src/Tools/StringUtil.php +++ b/src/Tools/StringUtil.php @@ -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); } diff --git a/src/UTF8.php b/src/UTF8.php index fe97742..5eb93a0 100644 --- a/src/UTF8.php +++ b/src/UTF8.php @@ -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]; diff --git a/src/Validator/Rule/Code.php b/src/Validator/Rule/Code.php index 8e6e122..4ae1b48 100644 --- a/src/Validator/Rule/Code.php +++ b/src/Validator/Rule/Code.php @@ -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); } diff --git a/src/Validator/Rule/Count.php b/src/Validator/Rule/Count.php index ff030a4..c346892 100644 --- a/src/Validator/Rule/Count.php +++ b/src/Validator/Rule/Count.php @@ -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); } diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index 2e003d7..465c679 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -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)) { diff --git a/src/View/ListView.php b/src/View/ListView.php index 16945ff..3acd298 100644 --- a/src/View/ListView.php +++ b/src/View/ListView.php @@ -7,7 +7,7 @@ class ListView extends View { function execute() { - $result = array(); + $result = []; foreach ($this->_section as $key => $value) { $result [] = $value->execute(); } diff --git a/src/View/Pages.php b/src/View/Pages.php index f621cef..e5e93c7 100644 --- a/src/View/Pages.php +++ b/src/View/Pages.php @@ -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) { diff --git a/src/View/Top.php b/src/View/Top.php index 6cf27d7..37b3339 100644 --- a/src/View/Top.php +++ b/src/View/Top.php @@ -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) { diff --git a/src/View/View.php b/src/View/View.php index 0151523..c8abbf2 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -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); } diff --git a/src/ZipFile.php b/src/ZipFile.php index c788806..e858432 100644 --- a/src/ZipFile.php +++ b/src/ZipFile.php @@ -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); } }