Skip to content

Commit 577b1cc

Browse files
Merge pull request #477 from kamil-tekiela/Redundant-code
Remove redundant code
2 parents d6e0d4c + ecc447c commit 577b1cc

File tree

7 files changed

+14
-47
lines changed

7 files changed

+14
-47
lines changed

phpstan-baseline.neon

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,6 @@ parameters:
320320
count: 8
321321
path: src/Components/OptionsArray.php
322322

323-
-
324-
message: "#^Right side of && is always true\\.$#"
325-
count: 1
326-
path: src/Components/OptionsArray.php
327-
328323
-
329324
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\OrderKeyword\\:\\:\\$expr \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
330325
count: 2
@@ -535,11 +530,6 @@ parameters:
535530
count: 1
536531
path: src/Statement.php
537532

538-
-
539-
message: "#^Strict comparison using \\=\\=\\= between class\\-string\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Component and null will always evaluate to false\\.$#"
540-
count: 1
541-
path: src/Statement.php
542-
543533
-
544534
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\>\\|null supplied for foreach, only iterables are supported\\.$#"
545535
count: 1
@@ -825,6 +815,11 @@ parameters:
825815
count: 1
826816
path: src/Utils/Formatter.php
827817

818+
-
819+
message: "#^Binary operation \"&\" between int and int\\|string results in an error\\.$#"
820+
count: 1
821+
path: src/Utils/Formatter.php
822+
828823
-
829824
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\\.$#"
830825
count: 1
@@ -851,12 +846,12 @@ parameters:
851846
path: src/Utils/Formatter.php
852847

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

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

@@ -865,11 +860,6 @@ parameters:
865860
count: 1
866861
path: src/Utils/Query.php
867862

868-
-
869-
message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#"
870-
count: 1
871-
path: src/Utils/Query.php
872-
873863
-
874864
message: "#^Cannot access property \\$dest on PhpMyAdmin\\\\SqlParser\\\\Components\\\\IntoKeyword\\|null\\.$#"
875865
count: 1
@@ -890,11 +880,6 @@ parameters:
890880
count: 1
891881
path: src/Utils/Query.php
892882

893-
-
894-
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:build\\(\\) expects array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression, object given\\.$#"
895-
count: 1
896-
path: src/Utils/Query.php
897-
898883
-
899884
message: "#^Cannot access offset 'value' on mixed\\.$#"
900885
count: 3

psalm-baseline.xml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@
213213
<code><![CDATA[$ret->expr]]></code>
214214
</PossiblyNullOperand>
215215
<RedundantConditionGivenDocblockType>
216-
<code>! $isExpr</code>
217-
<code>$isExpr</code>
218216
<code>$prev[1] !== null</code>
219217
<code><![CDATA[empty($ret->function) && ($prev[1] !== null)]]></code>
220218
</RedundantConditionGivenDocblockType>
@@ -470,10 +468,6 @@
470468
<PossiblyNullPropertyFetch>
471469
<code><![CDATA[$ret->options[$lastOptionId]['expr']->expr]]></code>
472470
</PossiblyNullPropertyFetch>
473-
<RedundantCondition>
474-
<code><![CDATA[! empty($option['equals']) && $option['equals']]]></code>
475-
<code><![CDATA[$option['equals']]]></code>
476-
</RedundantCondition>
477471
</file>
478472
<file src="src/Components/OrderKeyword.php">
479473
<MoreSpecificImplementedParamType>
@@ -904,9 +898,6 @@
904898
</UnsupportedPropertyReferenceUsage>
905899
</file>
906900
<file src="src/Statement.php">
907-
<DocblockTypeContradiction>
908-
<code>$class === null</code>
909-
</DocblockTypeContradiction>
910901
<InvalidArgument>
911902
<code>$built[$field]</code>
912903
<code><![CDATA[$parsedClauses[$token->value]]]></code>
@@ -940,9 +931,6 @@
940931
<PossiblyUnusedReturnValue>
941932
<code>bool</code>
942933
</PossiblyUnusedReturnValue>
943-
<RedundantConditionGivenDocblockType>
944-
<code>$class !== null</code>
945-
</RedundantConditionGivenDocblockType>
946934
<UnusedForeachValue>
947935
<code>$index</code>
948936
</UnusedForeachValue>
@@ -1379,9 +1367,6 @@
13791367
<PossiblyInvalidIterator>
13801368
<code><![CDATA[$this->options['formats']]]></code>
13811369
</PossiblyInvalidIterator>
1382-
<RedundantConditionGivenDocblockType>
1383-
<code><![CDATA[$curr->type === Token::TYPE_KEYWORD]]></code>
1384-
</RedundantConditionGivenDocblockType>
13851370
</file>
13861371
<file src="src/Utils/Query.php">
13871372
<InvalidNullableReturnType>
@@ -1436,7 +1421,7 @@
14361421
<code>has</code>
14371422
</PossiblyNullReference>
14381423
<RedundantCondition>
1439-
<code><![CDATA[empty($ret['select_tables'])]]></code>
1424+
<code><![CDATA[$ret['select_tables'] === []]]></code>
14401425
</RedundantCondition>
14411426
</file>
14421427
<file src="src/Utils/Routine.php">

src/Components/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
392392

393393
$ret->expr .= $token->token;
394394
}
395-
} elseif (! $isExpr) {
395+
} else {
396396
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '.')) {
397397
// Found a `.` which means we expect a column name and
398398
// the column name we parsed is actually the table name

src/Components/OptionsArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public static function build($component): string
281281
$options[] = $option;
282282
} else {
283283
$options[] = $option['name']
284-
. (! empty($option['equals']) && $option['equals'] ? '=' : ' ')
284+
. (! empty($option['equals']) ? '=' : ' ')
285285
. (! empty($option['expr']) ? $option['expr'] : $option['value']);
286286
}
287287
}

src/Statement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public function parse(Parser $parser, TokensList $list): void
298298
/**
299299
* The name of the class that is used for parsing.
300300
*
301-
* @var Component
301+
* @var Component|null
302302
*/
303303
$class = null;
304304

src/Utils/Formatter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,7 @@ public function formatList($list)
440440
&& empty(self::$inlineClauses[$lastClause])
441441
&& (
442442
$curr->type !== Token::TYPE_KEYWORD
443-
|| (
444-
$curr->type === Token::TYPE_KEYWORD
445-
&& $curr->flags & Token::FLAG_KEYWORD_FUNCTION
446-
)
443+
|| ($curr->flags & Token::FLAG_KEYWORD_FUNCTION)
447444
)
448445
) {
449446
$formattedOptions = true;

src/Utils/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public static function getAll($query)
528528
// If no tables names were found in the SELECT clause or if there
529529
// are expressions like * or COUNT(*), etc. tables names should be
530530
// extracted from the FROM clause.
531-
if (empty($ret['select_tables'])) {
531+
if ($ret['select_tables'] === []) {
532532
foreach ($statement->from as $expr) {
533533
if (! isset($expr->table) || ($expr->table === '')) {
534534
continue;

0 commit comments

Comments
 (0)