Skip to content

Remove redundant code #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 26, 2023
Merged
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
31 changes: 8 additions & 23 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,6 @@ parameters:
count: 8
path: src/Components/OptionsArray.php

-
message: "#^Right side of && is always true\\.$#"
count: 1
path: src/Components/OptionsArray.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\OrderKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
count: 2
Expand Down Expand Up @@ -535,11 +530,6 @@ parameters:
count: 1
path: src/Statement.php

-
message: "#^Strict comparison using \\=\\=\\= between class\\-string\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Component and null will always evaluate to false\\.$#"
count: 1
path: src/Statement.php

-
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\>\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
Expand Down Expand Up @@ -825,6 +815,11 @@ parameters:
count: 1
path: src/Utils/Formatter.php

-
message: "#^Binary operation \"&\" between int and int\\|string results in an error\\.$#"
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\\.$#"
count: 1
Expand All @@ -851,12 +846,12 @@ parameters:
path: src/Utils/Formatter.php

-
message: "#^Access to an undefined property object\\:\\:\\$alias\\.$#"
message: "#^Trying to invoke int\\<min, \\-1\\>\\|int\\<1, max\\>\\|non\\-falsy\\-string but it might not be a callable\\.$#"
count: 1
path: src/Utils/Query.php
path: src/Utils/Formatter.php

-
message: "#^Access to an undefined property object\\:\\:\\$expr\\.$#"
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|string\\|null\\>\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/Utils/Query.php

Expand All @@ -865,11 +860,6 @@ parameters:
count: 1
path: src/Utils/Query.php

-
message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/Utils/Query.php

-
message: "#^Cannot access property \\$dest on PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\|null\\.$#"
count: 1
Expand All @@ -890,11 +880,6 @@ parameters:
count: 1
path: src/Utils/Query.php

-
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, object given\\.$#"
count: 1
path: src/Utils/Query.php

-
message: "#^Cannot access offset 'value' on mixed\\.$#"
count: 3
Expand Down
17 changes: 1 addition & 16 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@
<code><![CDATA[$ret->expr]]></code>
</PossiblyNullOperand>
<RedundantConditionGivenDocblockType>
<code>! $isExpr</code>
<code>$isExpr</code>
<code>$prev[1] !== null</code>
<code><![CDATA[empty($ret->function) && ($prev[1] !== null)]]></code>
</RedundantConditionGivenDocblockType>
Expand Down Expand Up @@ -470,10 +468,6 @@
<PossiblyNullPropertyFetch>
<code><![CDATA[$ret->options[$lastOptionId]['expr']->expr]]></code>
</PossiblyNullPropertyFetch>
<RedundantCondition>
<code><![CDATA[! empty($option['equals']) && $option['equals']]]></code>
<code><![CDATA[$option['equals']]]></code>
</RedundantCondition>
</file>
<file src="src/Components/OrderKeyword.php">
<MoreSpecificImplementedParamType>
Expand Down Expand Up @@ -904,9 +898,6 @@
</UnsupportedPropertyReferenceUsage>
</file>
<file src="src/Statement.php">
<DocblockTypeContradiction>
<code>$class === null</code>
</DocblockTypeContradiction>
<InvalidArgument>
<code>$built[$field]</code>
<code><![CDATA[$parsedClauses[$token->value]]]></code>
Expand Down Expand Up @@ -940,9 +931,6 @@
<PossiblyUnusedReturnValue>
<code>bool</code>
</PossiblyUnusedReturnValue>
<RedundantConditionGivenDocblockType>
<code>$class !== null</code>
</RedundantConditionGivenDocblockType>
<UnusedForeachValue>
<code>$index</code>
</UnusedForeachValue>
Expand Down Expand Up @@ -1379,9 +1367,6 @@
<PossiblyInvalidIterator>
<code><![CDATA[$this->options['formats']]]></code>
</PossiblyInvalidIterator>
<RedundantConditionGivenDocblockType>
<code><![CDATA[$curr->type === Token::TYPE_KEYWORD]]></code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Utils/Query.php">
<InvalidNullableReturnType>
Expand Down Expand Up @@ -1436,7 +1421,7 @@
<code>has</code>
</PossiblyNullReference>
<RedundantCondition>
<code><![CDATA[empty($ret['select_tables'])]]></code>
<code><![CDATA[$ret['select_tables'] === []]]></code>
</RedundantCondition>
</file>
<file src="src/Utils/Routine.php">
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =

$ret->expr .= $token->token;
}
} elseif (! $isExpr) {
} else {
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '.')) {
// Found a `.` which means we expect a column name and
// the column name we parsed is actually the table name
Expand Down
2 changes: 1 addition & 1 deletion src/Components/OptionsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public static function build($component): string
$options[] = $option;
} else {
$options[] = $option['name']
. (! empty($option['equals']) && $option['equals'] ? '=' : ' ')
. (! empty($option['equals']) ? '=' : ' ')
. (! empty($option['expr']) ? $option['expr'] : $option['value']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function parse(Parser $parser, TokensList $list): void
/**
* The name of the class that is used for parsing.
*
* @var Component
* @var Component|null
*/
$class = null;

Expand Down
5 changes: 1 addition & 4 deletions src/Utils/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,7 @@ public function formatList($list)
&& empty(self::$inlineClauses[$lastClause])
&& (
$curr->type !== Token::TYPE_KEYWORD
|| (
$curr->type === Token::TYPE_KEYWORD
&& $curr->flags & Token::FLAG_KEYWORD_FUNCTION
)
|| ($curr->flags & Token::FLAG_KEYWORD_FUNCTION)
)
) {
$formattedOptions = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public static function getAll($query)
// If no tables names were found in the SELECT clause or if there
// are expressions like * or COUNT(*), etc. tables names should be
// extracted from the FROM clause.
if (empty($ret['select_tables'])) {
if ($ret['select_tables'] === []) {
foreach ($statement->from as $expr) {
if (! isset($expr->table) || ($expr->table === '')) {
continue;
Expand Down