Skip to content

Commit bdf7b67

Browse files
committed
Fix SA issues
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent a7eddce commit bdf7b67

5 files changed

Lines changed: 17 additions & 13 deletions

File tree

phpstan-baseline.neon

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,6 @@ parameters:
370370
count: 1
371371
path: src/Context.php
372372

373-
-
374-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Exceptions\\\\ParserException\\:\\:\\$token \\(PhpMyAdmin\\\\SqlParser\\\\Token\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
375-
count: 1
376-
path: src/Exceptions/ParserException.php
377-
378373
-
379374
message: "#^Cannot access property \\$type on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
380375
count: 2
@@ -710,6 +705,16 @@ parameters:
710705
count: 2
711706
path: src/Utils/CLI.php
712707

708+
-
709+
message: "#^Cannot access property \\$position on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
710+
count: 1
711+
path: src/Utils/Error.php
712+
713+
-
714+
message: "#^Cannot access property \\$token on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
715+
count: 1
716+
path: src/Utils/Error.php
717+
713718
-
714719
message: "#^Argument of an invalid type array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string supplied for foreach, only iterables are supported\\.$#"
715720
count: 1

psalm-baseline.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,6 @@
561561
<code>ContextMySql80100</code>
562562
</UnusedClass>
563563
</file>
564-
<file src="src/Exceptions/ParserException.php">
565-
<PossiblyNullPropertyAssignmentValue>
566-
<code>$token</code>
567-
</PossiblyNullPropertyAssignmentValue>
568-
</file>
569564
<file src="src/Lexer.php">
570565
<LoopInvalidation>
571566
<code><![CDATA[$this->last]]></code>
@@ -1038,6 +1033,10 @@
10381033
<code>$err[1]</code>
10391034
<code>$err[3]</code>
10401035
</PossiblyNullArgument>
1036+
<PossiblyNullPropertyFetch>
1037+
<code><![CDATA[$err->token->position]]></code>
1038+
<code><![CDATA[$err->token->token]]></code>
1039+
</PossiblyNullPropertyFetch>
10411040
<RedundantConditionGivenDocblockType>
10421041
<code>$obj instanceof Parser</code>
10431042
</RedundantConditionGivenDocblockType>

src/Exceptions/ParserException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ParserException extends Exception
2222
* @param Token|null $token the token that produced this exception
2323
* @param int $code the code of this error
2424
*/
25-
public function __construct(string $msg = '', Token|null $token = null, int $code = 0)
25+
public function __construct(string $msg, Token|null $token, int $code = 0)
2626
{
2727
parent::__construct($msg, $code);
2828

src/Tools/TestGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TestGenerator
4646
* @param string $query the query to be analyzed
4747
* @param string $type test's type (may be `lexer` or `parser`)
4848
*
49-
* @return array<string, string|Lexer|Parser|array<string, array<int, array<int, int|string|Token>>>|null>
49+
* @return array<string, string|Lexer|Parser|array<string, array<int, array<int, int|string|Token|null>>>|null>
5050
*/
5151
public static function generate(string $query, string $type = 'parser'): array
5252
{

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getTokensList(string $query): TokensList
5656
* @psalm-return (
5757
* $obj is Lexer
5858
* ? list<array{string, string, int, int}>
59-
* : list<array{string, Token, int}>
59+
* : list<array{string, Token|null, int}>
6060
* )
6161
*/
6262
public function getErrorsAsArray($obj): array

0 commit comments

Comments
 (0)