Skip to content

Commit 3fdc7ba

Browse files
committed
refactor: clear out phpstan errors in Validation source and tests
1 parent 2ac2615 commit 3fdc7ba

14 files changed

Lines changed: 352 additions & 939 deletions

File tree

system/Validation/CreditCardRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CreditCardRules
3131
* prefixes - List of possible prefixes for the card
3232
* checkdigit - Boolean on whether we should do a modulus10 check on the numbers.
3333
*
34-
* @var array
34+
* @var array<string, array{name: string, length: string, prefixes: string, checkdigit: bool}>
3535
*/
3636
protected $cards = [
3737
'American Express' => [

system/Validation/DotArrayFilter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ final class DotArrayFilter
2121
/**
2222
* Creates a new array with only the elements specified in dot array syntax.
2323
*
24-
* @param array $indexes The dot array syntax pattern to use for filtering.
25-
* @param array $array The array to filter.
24+
* @param list<string> $indexes The dot array syntax pattern to use for filtering.
25+
* @param array<array-key, mixed> $array The array to filter.
2626
*
27-
* @return array The filtered array.
27+
* @return array<array-key, mixed> The filtered array.
2828
*/
2929
public static function run(array $indexes, array $array): array
3030
{
@@ -47,10 +47,10 @@ public static function run(array $indexes, array $array): array
4747
/**
4848
* Used by `run()` to recursively filter the array with wildcards.
4949
*
50-
* @param array $indexes The dot array syntax pattern to use for filtering.
51-
* @param array $array The array to filter.
50+
* @param list<string> $indexes The dot array syntax pattern to use for filtering.
51+
* @param array<array-key, mixed> $array The array to filter.
5252
*
53-
* @return array The filtered array.
53+
* @return array<array-key, mixed> The filtered array.
5454
*/
5555
private static function filter(array $indexes, array $array): array
5656
{

system/Validation/Rules.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Rules
2828
/**
2929
* The value does not match another field in $data.
3030
*
31-
* @param string|null $str
32-
* @param array $data Other field/value pairs
31+
* @param string|null $str
32+
* @param array<array-key, mixed> $data Other field/value pairs
3333
*/
3434
public function differs($str, string $field, array $data): bool
3535
{
@@ -110,12 +110,14 @@ public function greater_than_equal_to($str, string $min): bool
110110
* Can ignore records by field/value to filter (currently
111111
* accept only one filter).
112112
*
113-
* Example:
113+
* ```
114114
* is_not_unique[dbGroup.table.field,where_field,where_value]
115115
* is_not_unique[table.field,where_field,where_value]
116116
* is_not_unique[menu.id,active,1]
117+
* ```
117118
*
118-
* @param string|null $str
119+
* @param string|null $str
120+
* @param array<array-key, mixed> $data
119121
*/
120122
public function is_not_unique($str, string $field, array $data): bool
121123
{
@@ -158,7 +160,8 @@ public function in_list($value, string $list): bool
158160
* is_unique[table.field,ignore_field,ignore_value]
159161
* is_unique[users.email,id,5]
160162
*
161-
* @param string|null $str
163+
* @param string|null $str
164+
* @param array<array-key, mixed> $data
162165
*/
163166
public function is_unique($str, string $field, array $data): bool
164167
{
@@ -178,9 +181,9 @@ public function is_unique($str, string $field, array $data): bool
178181
/**
179182
* Prepares the database query for uniqueness checks.
180183
*
181-
* @param mixed $value The value to check.
182-
* @param string $field The field parameters.
183-
* @param array<string, mixed> $data Additional data.
184+
* @param mixed $value The value to check.
185+
* @param string $field The field parameters.
186+
* @param array<array-key, mixed> $data Additional data.
184187
*
185188
* @return array{0: BaseBuilder, 1: string|null, 2: string|null}
186189
*/
@@ -247,8 +250,8 @@ public function less_than_equal_to($str, string $max): bool
247250
/**
248251
* Matches the value of another field in $data.
249252
*
250-
* @param string|null $str
251-
* @param array $data Other field/value pairs
253+
* @param string|null $str
254+
* @param array<array-key, mixed> $data Other field/value pairs
252255
*/
253256
public function matches($str, string $field, array $data): bool
254257
{
@@ -343,9 +346,9 @@ public function required($str = null): bool
343346
*
344347
* required_with[password]
345348
*
346-
* @param string|null $str
347-
* @param string|null $fields List of fields that we should check if present
348-
* @param array $data Complete list of fields from the form
349+
* @param string|null $str
350+
* @param string|null $fields List of fields that we should check if present
351+
* @param array<array-key, mixed> $data Complete list of fields from the form
349352
*/
350353
public function required_with($str = null, ?string $fields = null, array $data = []): bool
351354
{
@@ -387,9 +390,10 @@ public function required_with($str = null, ?string $fields = null, array $data =
387390
*
388391
* required_without[id,email]
389392
*
390-
* @param string|null $str
391-
* @param string|null $otherFields The param fields of required_without[].
392-
* @param string|null $field This rule param fields aren't present, this field is required.
393+
* @param string|null $str
394+
* @param string|null $otherFields The param fields of required_without[].
395+
* @param string|null $field This rule param fields aren't present, this field is required.
396+
* @param array<array-key, mixed> $data
393397
*/
394398
public function required_without(
395399
$str = null,
@@ -454,10 +458,10 @@ public function required_without(
454458
/**
455459
* The field exists in $data.
456460
*
457-
* @param mixed $value The field value.
458-
* @param string|null $param The rule's parameter.
459-
* @param array $data The data to be validated.
460-
* @param string|null $field The field name.
461+
* @param mixed $value The field value.
462+
* @param string|null $param The rule's parameter.
463+
* @param array<array-key, mixed> $data The data to be validated.
464+
* @param string|null $field The field name.
461465
*/
462466
public function field_exists(
463467
$value = null,

system/Validation/StrictRules/Rules.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function __construct()
3333
/**
3434
* The value does not match another field in $data.
3535
*
36-
* @param mixed $str
37-
* @param array $data Other field/value pairs
36+
* @param mixed $str
37+
* @param array<array-key, mixed> $data Other field/value pairs
3838
*/
3939
public function differs(
4040
$str,
@@ -137,7 +137,8 @@ public function greater_than_equal_to($str, string $min): bool
137137
* is_not_unique[table.field,where_field,where_value]
138138
* is_not_unique[menu.id,active,1]
139139
*
140-
* @param mixed $str
140+
* @param mixed $str
141+
* @param array<array-key, mixed> $data
141142
*/
142143
public function is_not_unique($str, string $field, array $data): bool
143144
{
@@ -176,7 +177,8 @@ public function in_list($value, string $list): bool
176177
* is_unique[table.field,ignore_field,ignore_value]
177178
* is_unique[users.email,id,5]
178179
*
179-
* @param mixed $str
180+
* @param mixed $str
181+
* @param array<array-key, mixed> $data
180182
*/
181183
public function is_unique($str, string $field, array $data): bool
182184
{
@@ -226,8 +228,8 @@ public function less_than_equal_to($str, string $max): bool
226228
/**
227229
* Matches the value of another field in $data.
228230
*
229-
* @param mixed $str
230-
* @param array $data Other field/value pairs
231+
* @param mixed $str
232+
* @param array<array-key, mixed> $data Other field/value pairs
231233
*/
232234
public function matches(
233235
$str,
@@ -339,9 +341,9 @@ public function required($str = null): bool
339341
*
340342
* required_with[password]
341343
*
342-
* @param mixed $str
343-
* @param string|null $fields List of fields that we should check if present
344-
* @param array $data Complete list of fields from the form
344+
* @param mixed $str
345+
* @param string|null $fields List of fields that we should check if present
346+
* @param array<array-key, mixed> $data Complete list of fields from the form
345347
*/
346348
public function required_with($str = null, ?string $fields = null, array $data = []): bool
347349
{
@@ -356,9 +358,10 @@ public function required_with($str = null, ?string $fields = null, array $data =
356358
*
357359
* required_without[id,email]
358360
*
359-
* @param mixed $str
360-
* @param string|null $otherFields The param fields of required_without[].
361-
* @param string|null $field This rule param fields aren't present, this field is required.
361+
* @param mixed $str
362+
* @param string|null $otherFields The param fields of required_without[].
363+
* @param string|null $field This rule param fields aren't present, this field is required.
364+
* @param array<array-key, mixed> $data
362365
*/
363366
public function required_without(
364367
$str = null,
@@ -373,10 +376,10 @@ public function required_without(
373376
/**
374377
* The field exists in $data.
375378
*
376-
* @param mixed $value The field value.
377-
* @param string|null $param The rule's parameter.
378-
* @param array $data The data to be validated.
379-
* @param string|null $field The field name.
379+
* @param mixed $value The field value.
380+
* @param string|null $param The rule's parameter.
381+
* @param array<array-key, mixed> $data The data to be validated.
382+
* @param string|null $field The field name.
380383
*/
381384
public function field_exists(
382385
$value = null,

0 commit comments

Comments
 (0)