fix deprecated warnings

This commit is contained in:
Waterticket 2023-01-16 09:29:34 +00:00
parent b8351bf3c8
commit f58e865f4d
4 changed files with 52 additions and 52 deletions

View file

@ -50,13 +50,13 @@ class DBQueryParser extends BaseParser
// Load attributes that only apply to subqueries in the <conditions> block. // Load attributes that only apply to subqueries in the <conditions> block.
$query->operation = $attribs['operation'] ?? null; $query->operation = $attribs['operation'] ?? null;
$query->column = preg_replace('/[^a-z0-9_\.]/i', '', $attribs['column'] ?? null) ?: null; $query->column = preg_replace('/[^a-z0-9_\.]/i', '', $attribs['column'] ?? '') ?: null;
$query->pipe = strtoupper($attribs['pipe'] ?? null) ?: 'AND'; $query->pipe = strtoupper($attribs['pipe'] ?? '') ?: 'AND';
// Load tables. // Load tables.
foreach ($xml->tables ? $xml->tables->children() : [] as $tag) foreach ($xml->tables ? $xml->tables->children() : [] as $tag)
{ {
if (trim($tag['query']) === 'true') if (trim($tag['query'] ?: '') === 'true')
{ {
$table = self::_parseQuery($tag); $table = self::_parseQuery($tag);
$query->tables[$table->alias] = $table; $query->tables[$table->alias] = $table;
@ -65,11 +65,11 @@ class DBQueryParser extends BaseParser
{ {
$table = new DBQuery\Table; $table = new DBQuery\Table;
$table->name = trim($tag['name']); $table->name = trim($tag['name']);
$table->alias = trim($tag['alias']) ?: null; $table->alias = trim($tag['alias'] ?: '') ?: null;
$table->ifvar = trim($tag['if']) ?: null; $table->ifvar = trim($tag['if'] ?: '') ?: null;
} }
$table_type = trim($tag['type']); $table_type = trim($tag['type'] ?: '');
if (stripos($table_type, 'join') !== false) if (stripos($table_type, 'join') !== false)
{ {
$table->join_type = strtoupper($table_type); $table->join_type = strtoupper($table_type);
@ -84,7 +84,7 @@ class DBQueryParser extends BaseParser
// Load index hints. // Load index hints.
foreach ($xml->index_hint ?: [] as $index_hint_group) foreach ($xml->index_hint ?: [] as $index_hint_group)
{ {
$index_hint_target_db = strtolower(trim($index_hint_group['for'])); $index_hint_target_db = strtolower(trim($index_hint_group['for'] ?: ''));
if ($index_hint_target_db !== '' && $index_hint_target_db !== 'all') if ($index_hint_target_db !== '' && $index_hint_target_db !== 'all')
{ {
$index_hint_target_db = explode(',', $index_hint_target_db); $index_hint_target_db = explode(',', $index_hint_target_db);
@ -99,17 +99,17 @@ class DBQueryParser extends BaseParser
{ {
$index_hint = new DBQuery\IndexHint; $index_hint = new DBQuery\IndexHint;
$index_hint->target_db = $index_hint_target_db; $index_hint->target_db = $index_hint_target_db;
$index_hint->hint_type = strtoupper(trim($tag['type'])) ?: 'USE'; $index_hint->hint_type = strtoupper(trim($tag['type'] ?: '')) ?: 'USE';
$index_hint->index_name = trim($tag['name']) ?: ''; $index_hint->index_name = trim($tag['name'] ?: '') ?: '';
$index_hint->table_name = trim($tag['table']) ?: ''; $index_hint->table_name = trim($tag['table'] ?: '') ?: '';
$index_hint->ifvar = trim($tag['if']) ?: null; $index_hint->ifvar = trim($tag['if'] ?: '') ?: null;
if (isset($tag['var']) && trim($tag['var'])) if (isset($tag['var']) && trim($tag['var'] ?: ''))
{ {
$index_hint->var = trim($tag['var']); $index_hint->var = trim($tag['var'] ?: '');
} }
if (isset($tag['default']) && trim($tag['default'])) if (isset($tag['default']) && trim($tag['default'] ?: ''))
{ {
$index_hint->index_name = trim($tag['default']); $index_hint->index_name = trim($tag['default'] ?: '');
} }
if ($index_hint->index_name || $index_hint->var) if ($index_hint->index_name || $index_hint->var)
{ {
@ -123,15 +123,15 @@ class DBQueryParser extends BaseParser
{ {
if ($tag->getName() === 'query') if ($tag->getName() === 'query')
{ {
$subquery = self::_parseQuery($tag, trim($tag['id'])); $subquery = self::_parseQuery($tag, trim($tag['id'] ?: ''));
$query->columns[] = $subquery; $query->columns[] = $subquery;
} }
elseif ($query->type === 'SELECT') elseif ($query->type === 'SELECT')
{ {
$column = new DBQuery\ColumnRead; $column = new DBQuery\ColumnRead;
$column->name = trim($tag['name']); $column->name = trim($tag['name']);
$column->alias = trim($tag['alias']) ?: null; $column->alias = trim($tag['alias'] ?: '') ?: null;
$column->ifvar = trim($tag['if']) ?: null; $column->ifvar = trim($tag['if'] ?: '') ?: null;
if ($column->name === '*' || preg_match('/\.\*$/', $column->name)) if ($column->name === '*' || preg_match('/\.\*$/', $column->name))
{ {
$column->is_wildcard = true; $column->is_wildcard = true;
@ -169,13 +169,13 @@ class DBQueryParser extends BaseParser
if ($xml->groups) if ($xml->groups)
{ {
$query->groupby = new DBQuery\GroupBy; $query->groupby = new DBQuery\GroupBy;
$query->groupby->ifvar = trim($xml->groups['if']) ?: null; $query->groupby->ifvar = trim($xml->groups['if'] ?: '') ?: null;
foreach ($xml->groups->children() as $tag) foreach ($xml->groups->children() as $tag)
{ {
$name = $tag->getName(); $name = $tag->getName();
if ($name === 'group') if ($name === 'group')
{ {
$query->groupby->columns[] = trim($tag['column']); $query->groupby->columns[] = trim($tag['column'] ?: '');
} }
elseif ($name === 'having') elseif ($name === 'having')
{ {
@ -203,8 +203,8 @@ class DBQueryParser extends BaseParser
if ($tag = $xml->navigation->{$key}) if ($tag = $xml->navigation->{$key})
{ {
$query->navigation->{$key} = new DBQuery\VariableBase; $query->navigation->{$key} = new DBQuery\VariableBase;
$query->navigation->{$key}->var = trim($tag['var']) ?: null; $query->navigation->{$key}->var = trim($tag['var'] ?: '') ?: null;
$query->navigation->{$key}->default = trim($tag['default']) ?: null; $query->navigation->{$key}->default = trim($tag['default'] ?: '') ?: null;
} }
} }
} }
@ -220,7 +220,7 @@ class DBQueryParser extends BaseParser
} }
// Check the SELECT DISTINCT flag. // Check the SELECT DISTINCT flag.
if ($xml->columns && $select_distinct = trim($xml->columns['distinct'])) if ($xml->columns && $select_distinct = trim($xml->columns['distinct'] ?: ''))
{ {
if ($select_distinct === 'distinct' || toBool($select_distinct)) if ($select_distinct === 'distinct' || toBool($select_distinct))
{ {
@ -273,7 +273,7 @@ class DBQueryParser extends BaseParser
$cond->filter = $attribs['filter'] ?? null; $cond->filter = $attribs['filter'] ?? null;
$cond->minlength = intval($attribs['minlength'] ?? 0, 10); $cond->minlength = intval($attribs['minlength'] ?? 0, 10);
$cond->maxlength = intval($attribs['maxlength'] ?? 0, 10); $cond->maxlength = intval($attribs['maxlength'] ?? 0, 10);
$cond->pipe = strtoupper($attribs['pipe'] ?? null) ?: 'AND'; $cond->pipe = strtoupper($attribs['pipe'] ?? '') ?: 'AND';
$result[] = $cond; $result[] = $cond;
} }
elseif ($name === 'group') elseif ($name === 'group')

View file

@ -58,7 +58,7 @@ class ModuleActionParser extends BaseParser
{ {
$grant_info = new \stdClass; $grant_info = new \stdClass;
$grant_info->title = self::_getChildrenByLang($grant, 'title', $lang); $grant_info->title = self::_getChildrenByLang($grant, 'title', $lang);
$grant_info->default = trim($grant['default']); $grant_info->default = trim($grant['default'] ?: '');
$grant_name = trim($grant['name']); $grant_name = trim($grant['name']);
$info->grant->{$grant_name} = $grant_info; $info->grant->{$grant_name} = $grant_info;
} }
@ -70,8 +70,8 @@ class ModuleActionParser extends BaseParser
$menu_info->title = self::_getChildrenByLang($menu, 'title', $lang); $menu_info->title = self::_getChildrenByLang($menu, 'title', $lang);
$menu_info->index = null; $menu_info->index = null;
$menu_info->acts = array(); $menu_info->acts = array();
$menu_info->type = trim($menu['type']); $menu_info->type = trim($menu['type'] ?: '');
$menu_name = trim($menu['name']); $menu_name = trim($menu['name'] ?: '');
$info->menu->{$menu_name} = $menu_info; $info->menu->{$menu_name} = $menu_info;
} }
@ -87,12 +87,12 @@ class ModuleActionParser extends BaseParser
if ($permission) if ($permission)
{ {
$permission_info->target = $permission; $permission_info->target = $permission;
$permission_info->check_var = trim($action['check_var']) ?: trim($action['check-var']); $permission_info->check_var = trim($action['check_var'] ?: '') ?: trim($action['check-var'] ?: '');
$permission_info->check_type = trim($action['check_type']) ?: trim($action['check-type']); $permission_info->check_type = trim($action['check_type'] ?: '') ?: trim($action['check-type'] ?: '');
} }
// Parse the list of allowed HTTP methods. // Parse the list of allowed HTTP methods.
$method_attr = trim($action['method']); $method_attr = trim($action['method'] ?: '');
if ($method_attr) if ($method_attr)
{ {
$methods = explode('|', strtoupper($method_attr)); $methods = explode('|', strtoupper($method_attr));
@ -111,14 +111,14 @@ class ModuleActionParser extends BaseParser
} }
// Parse routes. // Parse routes.
$global_route = (trim($action['global_route']) ?: trim($action['global-route'])) === 'true' ? 'true' : 'false'; $global_route = (trim($action['global_route'] ?: '') ?: trim($action['global-route'] ?: '')) === 'true' ? 'true' : 'false';
$route_attr = trim($action['route']); $route_attr = trim($action['route'] ?: '');
$route_tags = $action->route ?: []; $route_tags = $action->route ?: [];
$route_arg = []; $route_arg = [];
if ($route_attr || count($route_tags)) if ($route_attr || count($route_tags))
{ {
$routes = $route_attr ? array_map(function($route) { $routes = $route_attr ? array_map(function($route) {
return ['route' => trim($route), 'priority' => 0]; return ['route' => trim($route ?: ''), 'priority' => 0];
}, explode_with_escape('|', $route_attr)) : array(); }, explode_with_escape('|', $route_attr)) : array();
foreach ($route_tags as $route_tag) foreach ($route_tags as $route_tag)
{ {
@ -142,7 +142,7 @@ class ModuleActionParser extends BaseParser
} }
elseif ($action_class) elseif ($action_class)
{ {
$standalone = trim($action['standalone']); $standalone = trim($action['standalone'] ?: '');
if (!$standalone || !in_array($standalone, ['true', 'false', 'auto'])) if (!$standalone || !in_array($standalone, ['true', 'false', 'auto']))
{ {
$standalone = 'auto'; $standalone = 'auto';
@ -150,7 +150,7 @@ class ModuleActionParser extends BaseParser
} }
else else
{ {
$standalone = trim($action['standalone']); $standalone = trim($action['standalone'] ?: '');
if (!$standalone || !in_array($standalone, ['true', 'false', 'auto'])) if (!$standalone || !in_array($standalone, ['true', 'false', 'auto']))
{ {
$standalone = 'true'; $standalone = 'true';
@ -178,19 +178,19 @@ class ModuleActionParser extends BaseParser
$action_info = new \stdClass; $action_info = new \stdClass;
$action_info->type = $action_type; $action_info->type = $action_type;
$action_info->class_name = preg_replace('/\\\\+/', '\\\\', $action_class); $action_info->class_name = preg_replace('/\\\\+/', '\\\\', $action_class);
$action_info->grant = trim($action['grant']) ?: 'guest'; $action_info->grant = trim($action['grant'] ?: '') ?: 'guest';
$action_info->permission = $permission_info; $action_info->permission = $permission_info;
$action_info->ruleset = trim($action['ruleset']); $action_info->ruleset = trim($action['ruleset'] ?: '');
$action_info->method = implode('|', $methods); $action_info->method = implode('|', $methods);
$action_info->route = $route_arg; $action_info->route = $route_arg;
$action_info->standalone = $standalone; $action_info->standalone = $standalone;
$action_info->check_csrf = (trim($action['check_csrf']) ?: trim($action['check-csrf'])) === 'false' ? 'false' : 'true'; $action_info->check_csrf = (trim($action['check_csrf'] ?: '') ?: trim($action['check-csrf'] ?: '')) === 'false' ? 'false' : 'true';
$action_info->meta_noindex = (trim($action['meta_noindex']) ?: trim($action['meta-noindex'])) === 'true' ? 'true' : 'false'; $action_info->meta_noindex = (trim($action['meta_noindex'] ?: '') ?: trim($action['meta-noindex'] ?: '')) === 'true' ? 'true' : 'false';
$action_info->global_route = $global_route; $action_info->global_route = $global_route;
$info->action->{$action_name} = $action_info; $info->action->{$action_name} = $action_info;
// Set the menu name and index settings. // Set the menu name and index settings.
$menu_name = trim($action['menu_name']); $menu_name = trim($action['menu_name'] ?: '');
if ($menu_name && isset($info->menu->{$menu_name})) if ($menu_name && isset($info->menu->{$menu_name}))
{ {
$info->menu->{$menu_name}->acts[] = $action_name; $info->menu->{$menu_name}->acts[] = $action_name;
@ -217,7 +217,7 @@ class ModuleActionParser extends BaseParser
} }
// Set error handler settings. // Set error handler settings.
$error_handlers = explode(',', trim($action['error_handlers']) ?: trim($action['error-handlers'])); $error_handlers = explode(',', trim($action['error_handlers'] ?: '') ?: trim($action['error-handlers'] ?: ''));
foreach ($error_handlers as $error_handler) foreach ($error_handlers as $error_handler)
{ {
if (intval($error_handler) > 200) if (intval($error_handler) > 200)
@ -233,9 +233,9 @@ class ModuleActionParser extends BaseParser
$action_name = trim($permission['action']); $action_name = trim($permission['action']);
if (isset($info->action->{$action_name})) if (isset($info->action->{$action_name}))
{ {
$info->action->{$action_name}->permission->target = trim($permission['target']); $info->action->{$action_name}->permission->target = trim($permission['target'] ?: '');
$info->action->{$action_name}->permission->check_var = trim($permission['check_var']) ?: trim($permission['check-var']); $info->action->{$action_name}->permission->check_var = trim($permission['check_var'] ?: '') ?: trim($permission['check-var'] ?: '');
$info->action->{$action_name}->permission->check_type = trim($permission['check_type']) ?: trim($permission['check-type']); $info->action->{$action_name}->permission->check_type = trim($permission['check_type'] ?: '') ?: trim($permission['check-type'] ?: '');
} }
} }

View file

@ -41,15 +41,15 @@ class ModuleInfoParser extends BaseParser
$info->category = trim($xml->category) ?: 'service'; $info->category = trim($xml->category) ?: 'service';
$info->date = ($xml->date === 'RX_CORE') ? '' : date('Ymd', strtotime($xml->date . 'T12:00:00Z')); $info->date = ($xml->date === 'RX_CORE') ? '' : date('Ymd', strtotime($xml->date . 'T12:00:00Z'));
$info->license = trim($xml->license); $info->license = trim($xml->license);
$info->license_link = trim($xml->license['link']); $info->license_link = trim($xml->license['link'] ?: '');
$info->author = array(); $info->author = array();
foreach ($xml->author as $author) foreach ($xml->author as $author)
{ {
$author_info = new \stdClass; $author_info = new \stdClass;
$author_info->name = self::_getChildrenByLang($author, 'name', $lang); $author_info->name = self::_getChildrenByLang($author, 'name', $lang);
$author_info->email_address = trim($author['email_address']); $author_info->email_address = trim($author['email_address'] ?: '');
$author_info->homepage = trim($author['link']); $author_info->homepage = trim($author['link'] ?: '');
$info->author[] = $author_info; $info->author[] = $author_info;
} }
} }
@ -59,12 +59,12 @@ class ModuleInfoParser extends BaseParser
{ {
$info->title = self::_getChildrenByLang($xml, 'title', $lang); $info->title = self::_getChildrenByLang($xml, 'title', $lang);
$info->description = self::_getChildrenByLang($xml->author, 'description', $lang); $info->description = self::_getChildrenByLang($xml->author, 'description', $lang);
$info->version = trim($xml['version']); $info->version = trim($xml['version'] ?: '');
$info->homepage = trim($xml->homepage); $info->homepage = trim($xml->homepage);
$info->category = trim($xml['category']) ?: 'service'; $info->category = trim($xml['category'] ?: '') ?: 'service';
$info->date = date('Ymd', strtotime($xml->author['date'] . 'T12:00:00Z')); $info->date = date('Ymd', strtotime($xml->author['date'] . 'T12:00:00Z'));
$info->license = trim($xml->license); $info->license = trim($xml->license);
$info->license_link = trim($xml->license['link']); $info->license_link = trim($xml->license['link'] ?: '');
$info->author = array(); $info->author = array();
foreach ($xml->author as $author) foreach ($xml->author as $author)
@ -72,7 +72,7 @@ class ModuleInfoParser extends BaseParser
$author_info = new \stdClass; $author_info = new \stdClass;
$author_info->name = self::_getChildrenByLang($author, 'name', $lang); $author_info->name = self::_getChildrenByLang($author, 'name', $lang);
$author_info->email_address = trim($author['email_address']); $author_info->email_address = trim($author['email_address']);
$author_info->homepage = trim($author['link']); $author_info->homepage = trim($author['link'] ?: '');
$info->author[] = $author_info; $info->author[] = $author_info;
} }
} }

View file

@ -257,7 +257,7 @@ function escape_dqstr($str)
*/ */
function explode_with_escape($delimiter, $str, $limit = 0, $escape_char = '\\') function explode_with_escape($delimiter, $str, $limit = 0, $escape_char = '\\')
{ {
if ($limit < 1) $limit = null; if ($limit < 1) $limit = 0;
$result = array(); $result = array();
$split = preg_split('/(?<!' . preg_quote($escape_char, '/') . ')' . preg_quote($delimiter, '/') . '/', $str, $limit); $split = preg_split('/(?<!' . preg_quote($escape_char, '/') . ')' . preg_quote($delimiter, '/') . '/', $str, $limit);
foreach ($split as $piece) foreach ($split as $piece)