summaryrefslogtreecommitdiffstats
path: root/src/Utils/Error.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils/Error.php')
-rw-r--r--src/Utils/Error.php28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Utils/Error.php b/src/Utils/Error.php
index 20310a1..484da5c 100644
--- a/src/Utils/Error.php
+++ b/src/Utils/Error.php
@@ -1,20 +1,18 @@
<?php
-
/**
* Error related utilities.
*/
+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;
/**
* Error related utilities.
- *
- * @category Exceptions
- *
- * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
*/
class Error
{
@@ -32,26 +30,28 @@ class Error
*/
public static function get($objs)
{
- $ret = array();
+ $ret = [];
foreach ($objs as $obj) {
if ($obj instanceof Lexer) {
+ /** @var LexerException $err */
foreach ($obj->errors as $err) {
- $ret[] = array(
+ $ret[] = [
$err->getMessage(),
$err->getCode(),
$err->ch,
- $err->pos
- );
+ $err->pos,
+ ];
}
} elseif ($obj instanceof Parser) {
+ /** @var ParserException $err */
foreach ($obj->errors as $err) {
- $ret[] = array(
+ $ret[] = [
$err->getMessage(),
$err->getCode(),
$err->token->token,
- $err->token->position
- );
+ $err->token->position,
+ ];
}
}
}
@@ -77,7 +77,7 @@ class Error
$errors,
$format = '#%1$d: %2$s (near "%4$s" at position %5$d)'
) {
- $ret = array();
+ $ret = [];
$i = 0;
foreach ($errors as $key => $err) {
@@ -86,7 +86,7 @@ class Error
++$i,
$err[0],
$err[1],
- htmlspecialchars($err[2]),
+ htmlspecialchars((string) $err[2]),
$err[3]
);
}