diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 825d3e39..80ff745a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -370,11 +370,6 @@ parameters: count: 1 path: src/Context.php - - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Exceptions\\\\ParserException\\:\\:\\$token \\(PhpMyAdmin\\\\SqlParser\\\\Token\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#" - count: 1 - path: src/Exceptions/ParserException.php - - message: "#^Cannot access property \\$type on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#" count: 2 @@ -710,6 +705,16 @@ parameters: count: 2 path: src/Utils/CLI.php + - + message: "#^Cannot access property \\$position on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#" + count: 1 + path: src/Utils/Error.php + + - + message: "#^Cannot access property \\$token on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#" + count: 1 + path: src/Utils/Error.php + - message: "#^Argument of an invalid type array\\\\>\\|bool\\|string supplied for foreach, only iterables are supported\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d769180a..ce8a116d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -561,11 +561,6 @@ ContextMySql80100 - - - $token - - last]]> @@ -1038,6 +1033,10 @@ $err[1] $err[3] + + token->position]]> + token->token]]> + $obj instanceof Parser diff --git a/src/Exceptions/LexerException.php b/src/Exceptions/LexerException.php index abb87aa1..3ad0328e 100644 --- a/src/Exceptions/LexerException.php +++ b/src/Exceptions/LexerException.php @@ -13,17 +13,13 @@ class LexerException extends Exception { /** * The character that produced this error. - * - * @var string */ - public $ch; + public string $ch; /** * The index of the character that produced this error. - * - * @var int */ - public $pos; + public int $pos; /** * @param string $msg the message of this exception diff --git a/src/Exceptions/ParserException.php b/src/Exceptions/ParserException.php index 0341f8f8..bad07139 100644 --- a/src/Exceptions/ParserException.php +++ b/src/Exceptions/ParserException.php @@ -14,17 +14,15 @@ class ParserException extends Exception { /** * The token that produced this error. - * - * @var Token */ - public $token; + public Token|null $token; /** - * @param string $msg the message of this exception - * @param Token $token the token that produced this exception - * @param int $code the code of this error + * @param string $msg the message of this exception + * @param Token|null $token the token that produced this exception + * @param int $code the code of this error */ - public function __construct(string $msg = '', Token|null $token = null, int $code = 0) + public function __construct(string $msg, Token|null $token, int $code = 0) { parent::__construct($msg, $code); diff --git a/src/Tools/TestGenerator.php b/src/Tools/TestGenerator.php index b6dc65c4..0734698e 100644 --- a/src/Tools/TestGenerator.php +++ b/src/Tools/TestGenerator.php @@ -46,7 +46,7 @@ class TestGenerator * @param string $query the query to be analyzed * @param string $type test's type (may be `lexer` or `parser`) * - * @return array>>|null> + * @return array>>|null> */ public static function generate(string $query, string $type = 'parser'): array { diff --git a/tests/TestCase.php b/tests/TestCase.php index 45f14c31..abbd322e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -56,7 +56,7 @@ public function getTokensList(string $query): TokensList * @psalm-return ( * $obj is Lexer * ? list - * : list + * : list * ) */ public function getErrorsAsArray($obj): array