Visitar URL original
Merge pull request #19224 from MauricioFauth/validator-validate-methods · phpmyadmin/phpmyadmin@eae32be · GitHub
Skip to content

Commit eae32be

Browse files
Merge pull request #19224 from MauricioFauth/validator-validate-methods
Explicity calls Validator::validate* methods
2 parents 1c7f1cf + 681b914 commit eae32be

3 files changed

Lines changed: 129 additions & 74 deletions

File tree

‎phpstan-baseline.neon‎

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -931,72 +931,92 @@ parameters:
931931
path: src/Config/Validator.php
932932

933933
-
934-
message: "#^Method PhpMyAdmin\\\\Config\\\\Validator\\:\\:testDBConnection\\(\\) return type has no value type specified in iterable type array\\.$#"
934+
message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#"
935935
count: 1
936936
path: src/Config/Validator.php
937937

938938
-
939-
message: "#^Method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validate\\(\\) return type has no value type specified in iterable type array\\.$#"
939+
message: "#^Only booleans are allowed in a negated boolean, mysqli\\|false given\\.$#"
940940
count: 1
941941
path: src/Config/Validator.php
942942

943943
-
944-
message: "#^Method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateByRegex\\(\\) return type has no value type specified in iterable type array\\.$#"
944+
message: "#^Only booleans are allowed in a ternary operator condition, int\\<0, max\\>\\|false given\\.$#"
945945
count: 1
946946
path: src/Config/Validator.php
947947

948948
-
949-
message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#"
949+
message: "#^Only booleans are allowed in a ternary operator condition, int\\|false given\\.$#"
950+
count: 2
951+
path: src/Config/Validator.php
952+
953+
-
954+
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
950955
count: 1
951956
path: src/Config/Validator.php
952957

953958
-
954-
message: "#^Only booleans are allowed in a negated boolean, mysqli\\|false given\\.$#"
959+
message: "#^Parameter \\#1 \\$haystack of function mb_strpos expects string, \\(int\\|string\\) given\\.$#"
955960
count: 1
956961
path: src/Config/Validator.php
957962

958963
-
959-
message: "#^Only booleans are allowed in a ternary operator condition, int\\<0, max\\>\\|false given\\.$#"
964+
message: "#^Parameter \\#1 \\$haystack of function str_starts_with expects string, mixed given\\.$#"
960965
count: 1
961966
path: src/Config/Validator.php
962967

963968
-
964-
message: "#^Only booleans are allowed in a ternary operator condition, int\\|false given\\.$#"
969+
message: "#^Parameter \\#1 \\$host of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:testDBConnection\\(\\) expects string, mixed given\\.$#"
965970
count: 2
966971
path: src/Config/Validator.php
967972

968973
-
969-
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
974+
message: "#^Parameter \\#1 \\$path of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:getCanonicalPath\\(\\) expects string, \\(int\\|string\\) given\\.$#"
970975
count: 1
971976
path: src/Config/Validator.php
972977

973978
-
974-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string, bool\\=\\)\\: string given\\.$#"
979+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateByRegex\\(\\) expects string, mixed given\\.$#"
975980
count: 1
976981
path: src/Config/Validator.php
977982

978983
-
979-
message: "#^Parameter \\#1 \\$haystack of function mb_strpos expects string, \\(int\\|string\\) given\\.$#"
984+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateNonNegativeNumber\\(\\) expects string, mixed given\\.$#"
980985
count: 1
981986
path: src/Config/Validator.php
982987

983988
-
984-
message: "#^Parameter \\#1 \\$haystack of function str_starts_with expects string, mixed given\\.$#"
989+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validatePMAStorage\\(\\) expects string, mixed given\\.$#"
985990
count: 1
986991
path: src/Config/Validator.php
987992

988993
-
989-
message: "#^Parameter \\#1 \\$host of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:testDBConnection\\(\\) expects string, mixed given\\.$#"
990-
count: 2
994+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validatePortNumber\\(\\) expects string, mixed given\\.$#"
995+
count: 1
991996
path: src/Config/Validator.php
992997

993998
-
994-
message: "#^Parameter \\#1 \\$path of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:getCanonicalPath\\(\\) expects string, \\(int\\|string\\) given\\.$#"
999+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validatePositiveNumber\\(\\) expects string, mixed given\\.$#"
1000+
count: 1
1001+
path: src/Config/Validator.php
1002+
1003+
-
1004+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateRegex\\(\\) expects string, mixed given\\.$#"
1005+
count: 1
1006+
path: src/Config/Validator.php
1007+
1008+
-
1009+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateServer\\(\\) expects string, mixed given\\.$#"
1010+
count: 1
1011+
path: src/Config/Validator.php
1012+
1013+
-
1014+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateTrustedProxies\\(\\) expects string, mixed given\\.$#"
9951015
count: 1
9961016
path: src/Config/Validator.php
9971017

9981018
-
999-
message: "#^Parameter \\#1 \\$path of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:getCanonicalPath\\(\\) expects string, mixed given\\.$#"
1019+
message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Validator\\:\\:validateUpperBound\\(\\) expects string, mixed given\\.$#"
10001020
count: 1
10011021
path: src/Config/Validator.php
10021022

‎psalm-baseline.xml‎

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,31 @@
570570
<code><![CDATA[Config::getInstance()]]></code>
571571
</DeprecatedMethod>
572572
<MixedArgument>
573+
<code><![CDATA[$args]]></code>
574+
<code><![CDATA[$args]]></code>
575+
<code><![CDATA[$args]]></code>
576+
<code><![CDATA[$args]]></code>
577+
<code><![CDATA[$args]]></code>
578+
<code><![CDATA[$args]]></code>
579+
<code><![CDATA[$args]]></code>
580+
<code><![CDATA[$args]]></code>
581+
<code><![CDATA[$args]]></code>
582+
<code><![CDATA[$args]]></code>
583+
<code><![CDATA[$args]]></code>
584+
<code><![CDATA[$args]]></code>
585+
<code><![CDATA[$args]]></code>
586+
<code><![CDATA[$args]]></code>
587+
<code><![CDATA[$args]]></code>
588+
<code><![CDATA[$args]]></code>
589+
<code><![CDATA[$args]]></code>
590+
<code><![CDATA[$args]]></code>
591+
<code><![CDATA[$args]]></code>
592+
<code><![CDATA[$args]]></code>
573593
<code><![CDATA[$ip]]></code>
574594
<code><![CDATA[$password]]></code>
575595
<code><![CDATA[$uv[$i]]]></code>
576596
<code><![CDATA[$uv[$i]]]></code>
577597
<code><![CDATA[$values[$path]]]></code>
578-
<code><![CDATA[$vid]]></code>
579598
<code><![CDATA[empty($values['Servers/1/controlpass']) ? '' : $values['Servers/1/controlpass']]]></code>
580599
<code><![CDATA[empty($values['Servers/1/controluser']) ? '' : $values['Servers/1/controluser']]]></code>
581600
<code><![CDATA[empty($values['Servers/1/host']) ? '' : $values['Servers/1/host']]]></code>
@@ -602,7 +621,6 @@
602621
</MixedArrayOffset>
603622
<MixedAssignment>
604623
<code><![CDATA[$arguments[$k2]]]></code>
605-
<code><![CDATA[$errorList]]></code>
606624
<code><![CDATA[$field]]></code>
607625
<code><![CDATA[$ip]]></code>
608626
<code><![CDATA[$password]]></code>
@@ -614,15 +632,13 @@
614632
<code><![CDATA[$v]]></code>
615633
<code><![CDATA[$validator]]></code>
616634
<code><![CDATA[$validators]]></code>
617-
<code><![CDATA[$vid]]></code>
618635
<code><![CDATA[$vname]]></code>
619636
</MixedAssignment>
620637
<MixedInferredReturnType>
621638
<code><![CDATA[mixed[]]]></code>
622639
</MixedInferredReturnType>
623640
<MixedOperand>
624641
<code><![CDATA[$ip]]></code>
625-
<code><![CDATA[$vname]]></code>
626642
</MixedOperand>
627643
<MixedReturnStatement>
628644
<code><![CDATA[$validators]]></code>
@@ -638,30 +654,38 @@
638654
<code><![CDATA[$k2]]></code>
639655
<code><![CDATA[$k2]]></code>
640656
</PossiblyInvalidCast>
641-
<PossiblyUnusedMethod>
642-
<code><![CDATA[validateByRegex]]></code>
643-
<code><![CDATA[validateNonNegativeNumber]]></code>
644-
<code><![CDATA[validatePMAStorage]]></code>
645-
<code><![CDATA[validatePortNumber]]></code>
646-
<code><![CDATA[validatePositiveNumber]]></code>
647-
<code><![CDATA[validateRegex]]></code>
648-
<code><![CDATA[validateServer]]></code>
649-
<code><![CDATA[validateTrustedProxies]]></code>
650-
<code><![CDATA[validateUpperBound]]></code>
651-
</PossiblyUnusedMethod>
652-
<PossiblyUnusedParam>
653-
<code><![CDATA[$path]]></code>
654-
<code><![CDATA[$path]]></code>
655-
</PossiblyUnusedParam>
656657
<ReferenceReusedFromConfusingScope>
657658
<code><![CDATA[$vid]]></code>
658659
</ReferenceReusedFromConfusingScope>
659660
<RiskyTruthyFalsyComparison>
660661
<code><![CDATA[$config->get('is_setup')]]></code>
662+
<code><![CDATA[empty($errorList)]]></code>
661663
<code><![CDATA[empty($values['Servers/1/controlpass'])]]></code>
662664
<code><![CDATA[empty($values['Servers/1/controluser'])]]></code>
663665
<code><![CDATA[mb_strpos($k2, '/')]]></code>
664666
</RiskyTruthyFalsyComparison>
667+
<TooFewArguments>
668+
<code><![CDATA[self::validateByRegex(...$args)]]></code>
669+
<code><![CDATA[self::validateByRegex(...$args)]]></code>
670+
<code><![CDATA[self::validateByRegex(...$args)]]></code>
671+
<code><![CDATA[self::validateNonNegativeNumber(...$args)]]></code>
672+
<code><![CDATA[self::validateNonNegativeNumber(...$args)]]></code>
673+
<code><![CDATA[self::validatePMAStorage(...$args)]]></code>
674+
<code><![CDATA[self::validatePMAStorage(...$args)]]></code>
675+
<code><![CDATA[self::validatePortNumber(...$args)]]></code>
676+
<code><![CDATA[self::validatePortNumber(...$args)]]></code>
677+
<code><![CDATA[self::validatePositiveNumber(...$args)]]></code>
678+
<code><![CDATA[self::validatePositiveNumber(...$args)]]></code>
679+
<code><![CDATA[self::validateRegex(...$args)]]></code>
680+
<code><![CDATA[self::validateRegex(...$args)]]></code>
681+
<code><![CDATA[self::validateServer(...$args)]]></code>
682+
<code><![CDATA[self::validateServer(...$args)]]></code>
683+
<code><![CDATA[self::validateTrustedProxies(...$args)]]></code>
684+
<code><![CDATA[self::validateTrustedProxies(...$args)]]></code>
685+
<code><![CDATA[self::validateUpperBound(...$args)]]></code>
686+
<code><![CDATA[self::validateUpperBound(...$args)]]></code>
687+
<code><![CDATA[self::validateUpperBound(...$args)]]></code>
688+
</TooFewArguments>
665689
</file>
666690
<file src="src/ConfigStorage/Relation.php">
667691
<DeprecatedMethod>

0 commit comments

Comments
 (0)