Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 6 additions & 84 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1753,15 +1753,15 @@ parameters:
path: src/Utils/CLI.php

-
message: '#^Parameter \#1 \$query of static method PhpMyAdmin\\SqlParser\\Utils\\Formatter\:\:format\(\) expects string, string\|false given\.$#'
message: '#^Parameter \#1 \$str of class PhpMyAdmin\\SqlParser\\Lexer constructor expects PhpMyAdmin\\SqlParser\\UtfString\|string, string\|false given\.$#'
identifier: argument.type
count: 1
count: 2
path: src/Utils/CLI.php

-
message: '#^Parameter \#1 \$str of class PhpMyAdmin\\SqlParser\\Lexer constructor expects PhpMyAdmin\\SqlParser\\UtfString\|string, string\|false given\.$#'
message: '#^Parameter \$type of class PhpMyAdmin\\SqlParser\\Utils\\FormattingOptions constructor expects ''cli''\|''html''\|''text'', string\|false given\.$#'
identifier: argument.type
count: 2
count: 1
path: src/Utils/CLI.php

-
Expand All @@ -1770,52 +1770,10 @@ parameters:
count: 1
path: src/Utils/Error.php

-
message: '#^Argument of an invalid type array\<int, array\<string, int\|string\>\>\|bool\|string supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
count: 1
path: src/Utils/Formatter.php

-
message: '#^Binary operation "&" between int and int\|string results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/Utils/Formatter.php

-
message: '#^Binary operation "&\=" between array\<int, array\<string, int\|string\>\>\|bool\|string\|null and array\<int, array\<string, int\|string\>\>\|bool\|string\|null results in an error\.$#'
identifier: assignOp.invalid
count: 1
path: src/Utils/Formatter.php

-
message: '#^Binary operation "\." between array\<int, array\<string, int\|string\>\>\|bool\|string and string results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/Utils/Formatter.php

-
message: '#^Binary operation "\.\=" between string and mixed results in an error\.$#'
identifier: assignOp.invalid
count: 1
path: src/Utils/Formatter.php

-
message: '#^Call to function in_array\(\) requires parameter \#3 to be set\.$#'
identifier: function.strict
count: 1
path: src/Utils/Formatter.php

-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 4
path: src/Utils/Formatter.php

-
message: '#^Method PhpMyAdmin\\SqlParser\\Utils\\Formatter\:\:getMergedOptions\(\) should return array\<string, array\<int, array\<string, int\|string\>\>\|bool\|string\> but returns array\<string, mixed\>\.$#'
identifier: return.type
count: 1
count: 3
path: src/Utils/Formatter.php

-
Expand All @@ -1824,30 +1782,12 @@ parameters:
count: 1
path: src/Utils/Formatter.php

-
message: '#^Only booleans are allowed in &&, array\<int, array\<string, int\|string\>\>\|bool\|string given on the left side\.$#'
identifier: booleanAnd.leftNotBoolean
count: 2
path: src/Utils/Formatter.php

-
message: '#^Only booleans are allowed in &&, array\<int, array\<string, int\|string\>\>\|bool\|string given on the right side\.$#'
identifier: booleanAnd.rightNotBoolean
count: 2
path: src/Utils/Formatter.php

-
message: '#^Only booleans are allowed in an if condition, bool\|int given\.$#'
identifier: if.condNotBoolean
count: 1
path: src/Utils/Formatter.php

-
message: '#^Only booleans are allowed in \|\|, array\<int, array\<string, int\|string\>\>\|bool\|string given on the right side\.$#'
identifier: booleanOr.rightNotBoolean
count: 1
path: src/Utils/Formatter.php

-
message: '#^Only booleans are allowed in \|\|, int\<0, 32\> given on the right side\.$#'
identifier: booleanOr.rightNotBoolean
Expand All @@ -1866,36 +1806,18 @@ parameters:
count: 2
path: src/Utils/Formatter.php

-
message: '#^Parameter \#1 \$string of function str_repeat expects string, array\<int, array\<string, int\|string\>\>\|bool\|string given\.$#'
identifier: argument.type
count: 1
path: src/Utils/Formatter.php

-
message: '#^Parameter \#1 \$string of method PhpMyAdmin\\SqlParser\\Utils\\Formatter\:\:escapeConsole\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 4
path: src/Utils/Formatter.php

-
message: '#^Parameter \#2 \$newFormats of static method PhpMyAdmin\\SqlParser\\Utils\\Formatter\:\:mergeFormats\(\) expects array\<int, array\<string, int\|string\>\>, array\<int, array\<string, int\|string\>\>\|bool\|string given\.$#'
identifier: argument.type
count: 1
path: src/Utils/Formatter.php

-
message: '#^Possibly invalid array key type bool\|float\|int\|string\.$#'
identifier: offsetAccess.invalidOffset
count: 7
path: src/Utils/Formatter.php

-
message: '#^Trying to invoke int\<min, \-1\>\|int\<1, max\>\|non\-falsy\-string but it might not be a callable\.$#'
identifier: callable.nonCallable
count: 1
path: src/Utils/Formatter.php

-
message: '''
#^Access to deprecated property \$isDelete of class PhpMyAdmin\\SqlParser\\Utils\\StatementFlags\:
Expand Down Expand Up @@ -2736,7 +2658,7 @@ parameters:
-
message: '#^Dynamic call to static method PHPUnit\\Framework\\Assert\:\:assertEquals\(\)\.$#'
identifier: staticMethod.dynamicCall
count: 4
count: 3
path: tests/Utils/FormatterTest.php

-
Expand Down
38 changes: 5 additions & 33 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac">
<files psalm-version="6.15.1@28dc127af1b5aecd52314f6f645bafc10d0e11f9">
<file src="src/Components/AlterOperation.php">
<PossiblyNullReference>
<code><![CDATA[has]]></code>
Expand Down Expand Up @@ -951,6 +951,9 @@
</PossiblyNullOperand>
</file>
<file src="src/Utils/CLI.php">
<ArgumentTypeCoercion>
<code><![CDATA[$params['f']]]></code>
</ArgumentTypeCoercion>
<InvalidReturnStatement>
<code><![CDATA[getopt($opt, $long)]]></code>
</InvalidReturnStatement>
Expand All @@ -962,7 +965,7 @@
</MixedArgumentTypeCoercion>
<PossiblyFalseArgument>
<code><![CDATA[$params['c']]]></code>
<code><![CDATA[$params['q']]]></code>
<code><![CDATA[$params['f']]]></code>
<code><![CDATA[$params['q']]]></code>
<code><![CDATA[$params['q']]]></code>
</PossiblyFalseArgument>
Expand Down Expand Up @@ -1008,16 +1011,6 @@
<code><![CDATA[$text]]></code>
<code><![CDATA[$text]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$format['cli']]]></code>
<code><![CDATA[$format['cli']]]></code>
<code><![CDATA[$format['cli']]]></code>
<code><![CDATA[$format['flags']]]></code>
<code><![CDATA[$format['flags']]]></code>
<code><![CDATA[$format['function']]]></code>
<code><![CDATA[$format['html']]]></code>
<code><![CDATA[$format['type']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[self::$inlineClauses[$lastClause]]]></code>
<code><![CDATA[self::$inlineClauses[$lastClause]]]></code>
Expand All @@ -1030,32 +1023,16 @@
</MixedArrayTypeCoercion>
<MixedAssignment>
<code><![CDATA[$blocksLineEndings[]]]></code>
<code><![CDATA[$format]]></code>
<code><![CDATA[$func]]></code>
<code><![CDATA[$lineEnded]]></code>
<code><![CDATA[$prev]]></code>
<code><![CDATA[$text]]></code>
</MixedAssignment>
<MixedFunctionCall>
<code><![CDATA[$func($text)]]></code>
</MixedFunctionCall>
<MixedOperand>
<code><![CDATA[$format['cli']]]></code>
<code><![CDATA[$format['flags']]]></code>
<code><![CDATA[$format['html']]]></code>
<code><![CDATA[$lineEnded]]></code>
</MixedOperand>
<MixedReturnStatement>
<code><![CDATA[$text]]></code>
<code><![CDATA[$text]]></code>
</MixedReturnStatement>
<PossiblyInvalidArgument>
<code><![CDATA[$options['formats']]]></code>
<code><![CDATA[$this->options['indentation']]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidIterator>
<code><![CDATA[$this->options['formats']]]></code>
</PossiblyInvalidIterator>
<PossiblyNullArrayOffset>
<code><![CDATA[Parser::KEYWORD_PARSERS]]></code>
<code><![CDATA[Parser::STATEMENT_PARSERS]]></code>
Expand All @@ -1068,11 +1045,6 @@
</PossiblyNullOperand>
<RiskyTruthyFalsyComparison>
<code><![CDATA[$lineEnded]]></code>
<code><![CDATA[$this->options['clause_newline']]]></code>
<code><![CDATA[$this->options['parts_newline']]]></code>
<code><![CDATA[$this->options['parts_newline']]]></code>
<code><![CDATA[$this->options['parts_newline']]]></code>
<code><![CDATA[$this->options['remove_comments']]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Utils/Query.php">
Expand Down
6 changes: 4 additions & 2 deletions src/Utils/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{
public function __construct()
{
Context::load();

Check warning on line 28 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ { public function __construct() { - Context::load(); + } public function run(): int
}

public function run(): int
Expand Down Expand Up @@ -56,7 +56,7 @@
* @param string[]|false[] $params
* @param string[] $longopts
*/
public function mergeLongOpts(array &$params, array &$longopts): void

Check warning on line 59 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": @@ @@ * @param string[]|false[] $params * @param string[] $longopts */ - public function mergeLongOpts(array &$params, array &$longopts): void + protected function mergeLongOpts(array &$params, array &$longopts): void { foreach ($longopts as $value) { $value = rtrim($value, ':');
{
foreach ($longopts as $value) {
$value = rtrim($value, ':');
Expand All @@ -68,7 +68,7 @@
}
}

public function usageHighlight(): void

Check warning on line 71 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": @@ @@ } } - public function usageHighlight(): void + protected function usageHighlight(): void { $command = 'sql-parser --highlight';
{
$command = 'sql-parser --highlight';

Expand All @@ -87,9 +87,9 @@
}

/** @return string[]|false[]|false */
public function parseHighlight(): array|false

Check warning on line 90 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": @@ @@ } /** @return string[]|false[]|false */ - public function parseHighlight(): array|false + protected function parseHighlight(): array|false { $longopts = [ 'help',
{
$longopts = [

Check warning on line 92 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ public function parseHighlight(): array|false { $longopts = [ - 'help', 'query:', 'format:', 'ansi',
'help',
'query:',
'format:',
Expand Down Expand Up @@ -139,11 +139,13 @@
Context::setMode(Context::SQL_MODE_ANSI_QUOTES);
}

if (isset($params['q'])) {
if (isset($params['q']) && $params['q'] !== false) {
// $params['f'] is guaranteed to be set and valid at this point. @see parseHighlight()
echo Formatter::format(
$params['q'],
['type' => $params['f']],
new FormattingOptions(type: $params['f']),
);

echo "\n";

return 0;
Expand All @@ -155,7 +157,7 @@
return 1;
}

public function usageLint(): void

Check warning on line 160 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": @@ @@ return 1; } - public function usageLint(): void + protected function usageLint(): void { $command = 'sql-parser --lint';
{
$command = 'sql-parser --lint';

Expand All @@ -164,9 +166,9 @@
}

/** @return string[]|false[]|false */
public function parseLint(): array|false

Check warning on line 169 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": @@ @@ } /** @return string[]|false[]|false */ - public function parseLint(): array|false + protected function parseLint(): array|false { $longopts = [ 'help',
{
$longopts = [

Check warning on line 171 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ public function parseLint(): array|false { $longopts = [ - 'help', 'query:', 'context:', 'ansi',
'help',
'query:',
'context:',
Expand Down Expand Up @@ -196,7 +198,7 @@
}

if (isset($params['c'])) {
Context::load($params['c']);

Check warning on line 201 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ } if (isset($params['c'])) { - Context::load($params['c']); + } if (! isset($params['q'])) {
}

if (! isset($params['q'])) {
Expand All @@ -212,7 +214,7 @@
}

if (isset($params['q'])) {
$lexer = new Lexer($params['q'], false);

Check warning on line 217 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "FalseValue": @@ @@ } if (isset($params['q'])) { - $lexer = new Lexer($params['q'], false); + $lexer = new Lexer($params['q'], true); $parser = new Parser($lexer->list); $errors = Error::get([$lexer, $parser]); if ($errors === []) {
$parser = new Parser($lexer->list);
$errors = Error::get([$lexer, $parser]);
if ($errors === []) {
Expand Down
Loading
Loading