Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit 9094005

Browse files
committed
Additional static code analysis rules and according autofixes
1 parent 5eb44b2 commit 9094005

File tree

9 files changed

+53
-1
lines changed

9 files changed

+53
-1
lines changed

phpcs.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,22 @@
1313
<rule ref="PSR2">
1414
<exclude name="Generic.Files.LineLength"/>
1515
</rule>
16-
</ruleset>
16+
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />
17+
<rule ref="Generic.Commenting.DocComment.MissingShort" />
18+
<rule ref="Generic.Commenting.DocComment.SpacingBeforeTags" />
19+
<rule ref="Generic.Commenting.DocComment.SpacingBeforeTags" />
20+
<rule ref="MySource.Commenting.FunctionComment.InvalidReturn" />
21+
<rule ref="MySource.Commenting.FunctionComment.MissingParamComment" />
22+
<rule ref="MySource.Commenting.FunctionComment.TypeHintMissing" />
23+
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
24+
<rule ref="Generic.Classes.DuplicateClassName" />
25+
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
26+
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" />
27+
<rule ref="Generic.CodeAnalysis.JumbledIncrementer" />
28+
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
29+
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />
30+
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
31+
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
32+
<rule ref="Generic.Commenting.Fixme" />
33+
<rule ref="Generic.Commenting.Todo" />
34+
<rule ref="Generic.ControlStructures.InlineControlStructure" /></ruleset>

src/FluentValidationServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* Service provider substitutes default Laravel's validation factory
10+
*
1011
* @see FluentValidatorFactory
1112
*/
1213
class FluentValidationServiceProvider extends ValidationServiceProvider

src/GenericRuleSet.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class GenericRuleSet extends RuleSet
4242

4343
/**
4444
* The field under validation must be an integer.
45+
*
4546
* @return IntRuleSet
4647
*/
4748
public function int(): IntRuleSet
@@ -51,6 +52,7 @@ public function int(): IntRuleSet
5152

5253
/**
5354
* The field under validation must be numeric.
55+
*
5456
* @return NumericRuleSet
5557
*/
5658
public function numeric(): NumericRuleSet
@@ -60,6 +62,7 @@ public function numeric(): NumericRuleSet
6062

6163
/**
6264
* The field under validation must be a string. If you would like to allow the field to also be null, you should assign the nullable rule to the field.
65+
*
6366
* @return StringRuleSet
6467
*/
6568
public function string(): StringRuleSet
@@ -69,6 +72,7 @@ public function string(): StringRuleSet
6972

7073
/**
7174
* The field under validation must be able to be cast as a boolean. Accepted input are true, false, 1, 0, "1", and "0".
75+
*
7276
* @return GenericRuleSet
7377
*/
7478
public function boolean(): GenericRuleSet
@@ -78,6 +82,7 @@ public function boolean(): GenericRuleSet
7882

7983
/**
8084
* The field under validation must be a valid date according to the strtotime PHP function.
85+
*
8186
* @return DateRuleSet
8287
*/
8388
public function date(): DateRuleSet
@@ -87,6 +92,7 @@ public function date(): DateRuleSet
8792

8893
/**
8994
* The field under validation must be a successfully uploaded file.
95+
*
9096
* @return FileRuleSet
9197
*/
9298
public function file(): FileRuleSet

src/ImageRuleSet.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ImageRuleSet extends FileRuleSet
2323

2424
/**
2525
* ImageRuleSet constructor.
26+
*
2627
* @param array|\Closure|Dimensions $constraints
2728
* @param array $rules
2829
*/
@@ -34,6 +35,7 @@ public function __construct(array $rules = [], $constraints = [])
3435

3536
/**
3637
* The field under validation must be a successfully uploaded file.
38+
*
3739
* @return $this|static
3840
*/
3941
public function file()

src/NumericRuleSet.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(array $rules = [])
1818

1919
/**
2020
* The field under validation must be numeric and must have an exact length of value.
21+
*
2122
* @return NumericRuleSet
2223
* @param int $length
2324
*/
@@ -28,6 +29,7 @@ public function digits($length): NumericRuleSet
2829

2930
/**
3031
* The field under validation must have a length between the given min and max.
32+
*
3133
* @param $minLength
3234
* @param $maxLength
3335
* @return NumericRuleSet

src/RequiredRules.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function required()
2424

2525
/**
2626
* The field under validation must be present and not empty only if any of the other specified fields are present.
27+
*
2728
* @param \string[] $otherFields
2829
* @return static
2930
*/
@@ -34,6 +35,7 @@ public function requiredWith(string ...$otherFields)
3435

3536
/**
3637
* The field under validation must be present and not empty only if all of the other specified fields are present.
38+
*
3739
* @param \string[] ...$otherFields
3840
* @return static
3941
*/
@@ -44,6 +46,7 @@ public function requiredWithAll(string ...$otherFields)
4446

4547
/**
4648
* The field under validation must be present and not empty only when any of the other specified fields are not present.
49+
*
4750
* @param \string[] ...$otherFields
4851
* @return static
4952
*/
@@ -54,6 +57,7 @@ public function requiredWithout(string ...$otherFields)
5457

5558
/**
5659
* The field under validation must be present and not empty only when all of the other specified fields are not present.
60+
*
5761
* @param \string[] ...$otherFields
5862
* @return static
5963
*/
@@ -64,6 +68,7 @@ public function requiredWithoutAll(string ...$otherFields)
6468

6569
/**
6670
* The field under validation must be present and not empty if the anotherField field is equal to any value.
71+
*
6772
* @param string $anotherField
6873
* @param mixed $value
6974
* @return static
@@ -75,6 +80,7 @@ public function requiredIf(string $anotherField, $value)
7580

7681
/**
7782
* The field under validation must be present and not empty unless the anotherField field is equal to any value.
83+
*
7884
* @param string $anotherField
7985
* @param mixed $value
8086
* @return static

src/Rule.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public static function required(): GenericRuleSet
8181

8282
/**
8383
* The field under validation must be an integer.
84+
*
8485
* @return IntRuleSet
8586
*/
8687
public static function int(): IntRuleSet
@@ -90,6 +91,7 @@ public static function int(): IntRuleSet
9091

9192
/**
9293
* The field under validation must be numeric.
94+
*
9395
* @return NumericRuleSet
9496
*/
9597
public static function numeric(): NumericRuleSet
@@ -99,6 +101,7 @@ public static function numeric(): NumericRuleSet
99101

100102
/**
101103
* The field under validation must be a string. If you would like to allow the field to also be null, you should assign the nullable rule to the field.
104+
*
102105
* @return StringRuleSet
103106
*/
104107
public static function string(): StringRuleSet
@@ -108,6 +111,7 @@ public static function string(): StringRuleSet
108111

109112
/**
110113
* The field under validation must be a successfully uploaded file.
114+
*
111115
* @return FileRuleSet
112116
*/
113117
public static function file(): FileRuleSet
@@ -117,6 +121,7 @@ public static function file(): FileRuleSet
117121

118122
/**
119123
* The field under validation must be a valid date according to the strtotime PHP function.
124+
*
120125
* @return DateRuleSet
121126
*/
122127
public static function date(): DateRuleSet
@@ -126,6 +131,7 @@ public static function date(): DateRuleSet
126131

127132
/**
128133
* The file under validation must be an image (jpeg, png, bmp, gif, or svg)
134+
*
129135
* @param array|\Closure|\Illuminate\Validation\Rules\Dimensions $constraints
130136
* @return ImageRuleSet
131137
*/

src/SimpleRules.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ trait SimpleRules
1212
{
1313
/**
1414
* The field under validation must exist in anotherField's values.
15+
*
1516
* @param string $anotherFiled
1617
* @return static
1718
*/
@@ -22,6 +23,7 @@ public function inArray(string $anotherFiled)
2223

2324
/**
2425
* The field under validation must be included in the given list of values.
26+
*
2527
* @param array ...$values
2628
* @return static
2729
*/
@@ -33,6 +35,7 @@ public function in(...$values)
3335

3436
/**
3537
* The field under validation must not be included in the given list of values.
38+
*
3639
* @param array ...$values
3740
* @return static
3841
*/
@@ -44,6 +47,7 @@ public function notIn(...$values)
4447

4548
/**
4649
* The given field must match the field under validation.
50+
*
4751
* @param string $anotherField
4852
* @return static
4953
*/
@@ -54,6 +58,7 @@ public function same(string $anotherField)
5458

5559
/**
5660
* The field under validation must have a different value than field.
61+
*
5762
* @param string $anotherFiled
5863
* @return static
5964
*/
@@ -64,6 +69,7 @@ public function different(string $anotherFiled)
6469

6570
/**
6671
* The field under validation must have a minimum value. Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.
72+
*
6773
* @param integer $minimalValue For numeric data, value corresponds to a given integer value.
6874
* For an array, size corresponds to the count of the array.
6975
* For string data, value corresponds to the number of characters.
@@ -77,6 +83,7 @@ public function min($minimalValue)
7783

7884
/**
7985
* The field under validation must be less than or equal to a maximum value. Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.
86+
*
8087
* @param integer $maximalValue For numeric data, value corresponds to a given integer value.
8188
* For an array, size corresponds to the count of the array.
8289
* For string data, value corresponds to the number of characters.
@@ -90,6 +97,7 @@ public function max($maximalValue)
9097

9198
/**
9299
* The field under validation must have a size between the given min and max. Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.
100+
*
93101
* @param integer $minimalValue For numeric data, value corresponds to a given integer value.
94102
* For an array, size corresponds to the count of the array.
95103
* For string data, value corresponds to the number of characters.
@@ -123,6 +131,7 @@ public function size(int $value)
123131

124132
/**
125133
* Run validation checks against a field only if that field is present in the input array.
134+
*
126135
* @return static
127136
*/
128137
public function sometimes()
@@ -132,6 +141,7 @@ public function sometimes()
132141

133142
/**
134143
* The field under validation must pass custom validation rule.
144+
*
135145
* @param string $customRule
136146
* @return GenericRuleSet
137147
* @throws ConfigurationException

src/StringRuleSet.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function regex(string $pattern, bool $ignoreCase = false): StringRuleSet
6363

6464
/**
6565
* Field under validation must match one of values of specified Enum
66+
*
6667
* @see https://github.com/Saritasa/php-common#enum
6768
*
6869
* @param string $enumClass Enumeration to validate against

0 commit comments

Comments
 (0)