Skip to content
Open
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
2 changes: 1 addition & 1 deletion system/Validation/CreditCardRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CreditCardRules
* prefixes - List of possible prefixes for the card
* checkdigit - Boolean on whether we should do a modulus10 check on the numbers.
*
* @var array
* @var array<string, array{name: string, length: string, prefixes: string, checkdigit: bool}>
*/
protected $cards = [
'American Express' => [
Expand Down
12 changes: 6 additions & 6 deletions system/Validation/DotArrayFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ final class DotArrayFilter
/**
* Creates a new array with only the elements specified in dot array syntax.
*
* @param array $indexes The dot array syntax pattern to use for filtering.
* @param array $array The array to filter.
* @param list<string> $indexes The dot array syntax pattern to use for filtering.
* @param array<array-key, mixed> $array The array to filter.
*
* @return array The filtered array.
* @return array<array-key, mixed> The filtered array.
*/
public static function run(array $indexes, array $array): array
{
Expand All @@ -47,10 +47,10 @@ public static function run(array $indexes, array $array): array
/**
* Used by `run()` to recursively filter the array with wildcards.
*
* @param array $indexes The dot array syntax pattern to use for filtering.
* @param array $array The array to filter.
* @param list<string> $indexes The dot array syntax pattern to use for filtering.
* @param array<array-key, mixed> $array The array to filter.
*
* @return array The filtered array.
* @return array<array-key, mixed> The filtered array.
*/
private static function filter(array $indexes, array $array): array
{
Expand Down
44 changes: 24 additions & 20 deletions system/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Rules
/**
* The value does not match another field in $data.
*
* @param string|null $str
* @param array $data Other field/value pairs
* @param string|null $str
* @param array<array-key, mixed> $data Other field/value pairs
*/
public function differs($str, string $field, array $data): bool
{
Expand Down Expand Up @@ -110,12 +110,14 @@ public function greater_than_equal_to($str, string $min): bool
* Can ignore records by field/value to filter (currently
* accept only one filter).
*
* Example:
* ```
* is_not_unique[dbGroup.table.field,where_field,where_value]
* is_not_unique[table.field,where_field,where_value]
* is_not_unique[menu.id,active,1]
* ```
*
* @param string|null $str
* @param string|null $str
* @param array<array-key, mixed> $data
*/
public function is_not_unique($str, string $field, array $data): bool
{
Expand Down Expand Up @@ -158,7 +160,8 @@ public function in_list($value, string $list): bool
* is_unique[table.field,ignore_field,ignore_value]
* is_unique[users.email,id,5]
*
* @param string|null $str
* @param string|null $str
* @param array<array-key, mixed> $data
*/
public function is_unique($str, string $field, array $data): bool
{
Expand All @@ -178,9 +181,9 @@ public function is_unique($str, string $field, array $data): bool
/**
* Prepares the database query for uniqueness checks.
*
* @param mixed $value The value to check.
* @param string $field The field parameters.
* @param array<string, mixed> $data Additional data.
* @param mixed $value The value to check.
* @param string $field The field parameters.
* @param array<array-key, mixed> $data Additional data.
*
* @return array{0: BaseBuilder, 1: string|null, 2: string|null}
*/
Expand Down Expand Up @@ -247,8 +250,8 @@ public function less_than_equal_to($str, string $max): bool
/**
* Matches the value of another field in $data.
*
* @param string|null $str
* @param array $data Other field/value pairs
* @param string|null $str
* @param array<array-key, mixed> $data Other field/value pairs
*/
public function matches($str, string $field, array $data): bool
{
Expand Down Expand Up @@ -343,9 +346,9 @@ public function required($str = null): bool
*
* required_with[password]
*
* @param string|null $str
* @param string|null $fields List of fields that we should check if present
* @param array $data Complete list of fields from the form
* @param string|null $str
* @param string|null $fields List of fields that we should check if present
* @param array<array-key, mixed> $data Complete list of fields from the form
*/
public function required_with($str = null, ?string $fields = null, array $data = []): bool
{
Expand Down Expand Up @@ -387,9 +390,10 @@ public function required_with($str = null, ?string $fields = null, array $data =
*
* required_without[id,email]
*
* @param string|null $str
* @param string|null $otherFields The param fields of required_without[].
* @param string|null $field This rule param fields aren't present, this field is required.
* @param string|null $str
* @param string|null $otherFields The param fields of required_without[].
* @param string|null $field This rule param fields aren't present, this field is required.
* @param array<array-key, mixed> $data
*/
public function required_without(
$str = null,
Expand Down Expand Up @@ -454,10 +458,10 @@ public function required_without(
/**
* The field exists in $data.
*
* @param mixed $value The field value.
* @param string|null $param The rule's parameter.
* @param array $data The data to be validated.
* @param string|null $field The field name.
* @param mixed $value The field value.
* @param string|null $param The rule's parameter.
* @param array<array-key, mixed> $data The data to be validated.
* @param string|null $field The field name.
*/
public function field_exists(
$value = null,
Expand Down
35 changes: 19 additions & 16 deletions system/Validation/StrictRules/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __construct()
/**
* The value does not match another field in $data.
*
* @param mixed $str
* @param array $data Other field/value pairs
* @param mixed $str
* @param array<array-key, mixed> $data Other field/value pairs
*/
public function differs(
$str,
Expand Down Expand Up @@ -137,7 +137,8 @@ public function greater_than_equal_to($str, string $min): bool
* is_not_unique[table.field,where_field,where_value]
* is_not_unique[menu.id,active,1]
*
* @param mixed $str
* @param mixed $str
* @param array<array-key, mixed> $data
*/
public function is_not_unique($str, string $field, array $data): bool
{
Expand Down Expand Up @@ -176,7 +177,8 @@ public function in_list($value, string $list): bool
* is_unique[table.field,ignore_field,ignore_value]
* is_unique[users.email,id,5]
*
* @param mixed $str
* @param mixed $str
* @param array<array-key, mixed> $data
*/
public function is_unique($str, string $field, array $data): bool
{
Expand Down Expand Up @@ -226,8 +228,8 @@ public function less_than_equal_to($str, string $max): bool
/**
* Matches the value of another field in $data.
*
* @param mixed $str
* @param array $data Other field/value pairs
* @param mixed $str
* @param array<array-key, mixed> $data Other field/value pairs
*/
public function matches(
$str,
Expand Down Expand Up @@ -339,9 +341,9 @@ public function required($str = null): bool
*
* required_with[password]
*
* @param mixed $str
* @param string|null $fields List of fields that we should check if present
* @param array $data Complete list of fields from the form
* @param mixed $str
* @param string|null $fields List of fields that we should check if present
* @param array<array-key, mixed> $data Complete list of fields from the form
*/
public function required_with($str = null, ?string $fields = null, array $data = []): bool
{
Expand All @@ -356,9 +358,10 @@ public function required_with($str = null, ?string $fields = null, array $data =
*
* required_without[id,email]
*
* @param mixed $str
* @param string|null $otherFields The param fields of required_without[].
* @param string|null $field This rule param fields aren't present, this field is required.
* @param mixed $str
* @param string|null $otherFields The param fields of required_without[].
* @param string|null $field This rule param fields aren't present, this field is required.
* @param array<array-key, mixed> $data
*/
public function required_without(
$str = null,
Expand All @@ -373,10 +376,10 @@ public function required_without(
/**
* The field exists in $data.
*
* @param mixed $value The field value.
* @param string|null $param The rule's parameter.
* @param array $data The data to be validated.
* @param string|null $field The field name.
* @param mixed $value The field value.
* @param string|null $param The rule's parameter.
* @param array<array-key, mixed> $data The data to be validated.
* @param string|null $field The field name.
*/
public function field_exists(
$value = null,
Expand Down
Loading
Loading