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

Commit 546ad79

Browse files
committed
Update inline documentation
1 parent 9094005 commit 546ad79

13 files changed

+83
-52
lines changed

src/DatabaseRuleSet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function __construct(array $rules = [])
2626
/**
2727
* Get a exists constraint builder instance.
2828
*
29-
* @param string $table
30-
* @param string $column
29+
* @param string $table Table in database, in which lookup should be performed
30+
* @param string $column Column in table, in which lookup should be performed
3131
* @param \Closure|null $callback callback, that will receive \Illuminate\Validation\Rules\Exists $rule
3232
* @return GenericRuleSet
3333
* @see \Illuminate\Validation\Rules\Exists
@@ -44,8 +44,8 @@ public function exists(string $table, string $column = 'NULL', \Closure $callbac
4444
/**
4545
* Get a unique constraint builder instance.
4646
*
47-
* @param string $table
48-
* @param string $column
47+
* @param string $table Table in database, in which lookup should be performed
48+
* @param string $column Column in table, in which lookup should be performed
4949
* @param \Closure|null $callback callback, that will receive \Illuminate\Validation\Rules\Unique $rule
5050
* @return GenericRuleSet
5151
*/

src/DateRuleSet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(array $rules = [])
3434
*
3535
* 'finish_date' => 'required|date|after:start_date'
3636
*
37-
* @param Carbon|string $date
37+
* @param Carbon|string $date Value must be after this date
3838
* @return $this|static
3939
*/
4040
public function after($date)
@@ -47,7 +47,7 @@ public function after($date)
4747
* For more information, see the after rule.
4848
*
4949
* @see after
50-
* @param Carbon|string $date
50+
* @param Carbon|string $date Value must be after or equal this date
5151
* @return $this|static
5252
*/
5353
public function afterOrEqual($date)
@@ -59,7 +59,7 @@ public function afterOrEqual($date)
5959
* The field under validation must be a value preceding the given date.
6060
* The dates will be passed into the PHP strtotime function.
6161
*
62-
* @param Carbon|string $date
62+
* @param Carbon|string $date Value must be preceding this date
6363
* @return $this|static
6464
*/
6565
public function before($date)
@@ -71,7 +71,7 @@ public function before($date)
7171
* The field under validation must be a value preceding or equal to the given date.
7272
* The dates will be passed into the PHP strtotime function.
7373
*
74-
* @param Carbon|string $date
74+
* @param Carbon|string $date Value must be before or equal this date
7575
* @return $this|static
7676
*/
7777
public function beforeOrEqual($date)

src/FileRuleSet.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public function __construct(array $rules = [])
2323
}
2424

2525
/**
26-
* @param array|\Closure $constraints
26+
* Field under validation must contain image
27+
*
28+
* @param array|\Closure $constraints Image dimensions constraints
2729
* @return ImageRuleSet
2830
*/
2931
public function image($constraints = []): ImageRuleSet
@@ -35,7 +37,7 @@ public function image($constraints = []): ImageRuleSet
3537
* The file under validation must match one of the given MIME types
3638
* To determine the MIME type of the uploaded file, the file's contents will be read and the framework will attempt to guess the MIME type, which may be different from the client provided MIME type.
3739
*
38-
* @param \string[] ...$types
40+
* @param \string[] ...$types List of allowed MIME types
3941
* @return $this|static
4042
*/
4143
public function mimetypes(string ...$types)
@@ -54,7 +56,7 @@ public function mimetypes(string ...$types)
5456
* A full listing of MIME types and their corresponding extensions may be found at the following location:
5557
* https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
5658
*
57-
* @param \string[] ...$extensions
59+
* @param \string[] ...$extensions List of allowed file extensions
5860
* @return $this|static
5961
*/
6062
public function mimes(string ...$extensions)

src/FluentValidatorFactory.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010
*/
1111
class FluentValidatorFactory extends LaravelValidatorFactory
1212
{
13-
/** @inheritdoc */
13+
/**
14+
* Create a new Validator instance.
15+
*
16+
* @param array $data Input data to validate
17+
* @param array $rules Set of validation rules
18+
* @param array $messages Custom messages for validation rules
19+
* @param array $customAttributes Human-readable attribute names for validated attributes
20+
* @return \Illuminate\Validation\Validator
21+
*/
1422
public function make(array $data, array $rules, array $messages = [], array $customAttributes = [])
1523
{
1624
$rules = array_map(function ($rule) {

src/GenericRuleSet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
class GenericRuleSet extends RuleSet
4040
{
41-
const EXPOSED_RULES = ['int', 'numeric', 'string'];
41+
const EXPOSED_RULES = ['int', 'numeric', 'string', 'boolean', 'date', 'file'];
4242

4343
/**
4444
* The field under validation must be an integer.
@@ -100,7 +100,7 @@ public function file(): FileRuleSet
100100
return new FileRuleSet($this->rules);
101101
}
102102

103-
public function __call($name, $arguments)
103+
public function __call(string $name, array $arguments)
104104
{
105105
$ruleSet = null;
106106
if (in_array($name, StringRuleSet::EXPOSED_RULES)) {

src/ImageRuleSet.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* Image validation rules. In addition to file validation has image dimensions rules
1010
* (width, height, ratio of width and height).
1111
*
12+
* @see https://laravel.com/docs/5.5/validation#rule-dimensions
13+
*
1214
* @method ImageRuleSet width(int $width)
1315
* @method ImageRuleSet height(int $height)
1416
* @method ImageRuleSet minWidth(int $width)
@@ -18,14 +20,21 @@
1820
*/
1921
class ImageRuleSet extends FileRuleSet
2022
{
21-
/** @var Dimensions */
23+
/**
24+
* Expected image dimensions
25+
*
26+
* @var Dimensions
27+
*/
2228
protected $dimensions;
2329

2430
/**
25-
* ImageRuleSet constructor.
31+
* Image validation rules. In addition to file validation has image dimensions rules
32+
* (width, height, ratio of width and height).
33+
*
34+
* @see https://laravel.com/docs/5.5/validation#rule-dimensions
2635
*
27-
* @param array|\Closure|Dimensions $constraints
28-
* @param array $rules
36+
* @param array $rules Additional validation rules
37+
* @param mixed|array|\Closure|Dimensions $constraints Image dimension constraints
2938
*/
3039
public function __construct(array $rules = [], $constraints = [])
3140
{
@@ -43,7 +52,7 @@ public function file()
4352
return $this->appendIfNotExists('file');
4453
}
4554

46-
public function __call($name, $arguments)
55+
public function __call(string $name, array $arguments)
4756
{
4857
if (in_array($name, ['width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight', 'ratio'])) {
4958
if ($this->dimensions == null) {
@@ -56,8 +65,11 @@ public function __call($name, $arguments)
5665
}
5766

5867
/**
59-
* @param array|\Closure|Dimensions $constraints
68+
* Image dimension constraints
69+
*
70+
* @param array|\Closure|Dimensions $constraints Image dimensions constraints
6071
* @return $this
72+
* @see \Illuminate\Validation\Rules\Dimensions
6173
*/
6274
public function dimensions($constraints)
6375
{

src/NumericRuleSet.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ public function __construct(array $rules = [])
1919
/**
2020
* The field under validation must be numeric and must have an exact length of value.
2121
*
22+
* @param int $length Expected number of digits
2223
* @return NumericRuleSet
23-
* @param int $length
2424
*/
25-
public function digits($length): NumericRuleSet
25+
public function digits(int $length): NumericRuleSet
2626
{
2727
return $this->appendIfNotExists("digits:$length");
2828
}
2929

3030
/**
3131
* The field under validation must have a length between the given min and max.
3232
*
33-
* @param $minLength
34-
* @param $maxLength
33+
* @param int $minLength Minimum number of digits
34+
* @param int $maxLength Maximum number of digits
3535
* @return NumericRuleSet
3636
*/
37-
public function digitsBetween($minLength, $maxLength): NumericRuleSet
37+
public function digitsBetween(int $minLength, int $maxLength): NumericRuleSet
3838
{
3939
return $this->appendIfNotExists("digits_between:$minLength,$maxLength");
4040
}

src/PhoneRuleSet.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
class PhoneRuleSet extends StringRuleSet
2525
{
2626
/**
27+
* Phone validation rule
28+
*
2729
* @var Phone
2830
*/
2931
protected $rule;
3032

3133
/**
3234
* PhoneRuleSet constructor.
3335
*
34-
* @param array $rules
36+
* @param array $rules Set of rules to merge with
3537
*/
3638
public function __construct(array $rules = [])
3739
{
@@ -49,7 +51,7 @@ public function __construct(array $rules = [])
4951
}
5052
}
5153

52-
public function __call($name, $arguments)
54+
public function __call(string $name, array $arguments)
5355
{
5456
if (method_exists($this->rule, $name)) {
5557
call_user_func_array([$this->rule, $name], $arguments);

src/RequiredRules.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function required()
2525
/**
2626
* The field under validation must be present and not empty only if any of the other specified fields are present.
2727
*
28-
* @param \string[] $otherFields
28+
* @param \string[] $otherFields Field is required, if any of these fields present
2929
* @return static
3030
*/
3131
public function requiredWith(string ...$otherFields)
@@ -36,7 +36,7 @@ public function requiredWith(string ...$otherFields)
3636
/**
3737
* The field under validation must be present and not empty only if all of the other specified fields are present.
3838
*
39-
* @param \string[] ...$otherFields
39+
* @param \string[] ...$otherFields Field is required, if all of these fields present
4040
* @return static
4141
*/
4242
public function requiredWithAll(string ...$otherFields)
@@ -47,7 +47,7 @@ public function requiredWithAll(string ...$otherFields)
4747
/**
4848
* The field under validation must be present and not empty only when any of the other specified fields are not present.
4949
*
50-
* @param \string[] ...$otherFields
50+
* @param \string[] ...$otherFields Field is required, if any of these fields is absent
5151
* @return static
5252
*/
5353
public function requiredWithout(string ...$otherFields)
@@ -58,7 +58,7 @@ public function requiredWithout(string ...$otherFields)
5858
/**
5959
* The field under validation must be present and not empty only when all of the other specified fields are not present.
6060
*
61-
* @param \string[] ...$otherFields
61+
* @param \string[] ...$otherFields Field is required, if all of these fields absent
6262
* @return static
6363
*/
6464
public function requiredWithoutAll(string ...$otherFields)
@@ -69,8 +69,8 @@ public function requiredWithoutAll(string ...$otherFields)
6969
/**
7070
* The field under validation must be present and not empty if the anotherField field is equal to any value.
7171
*
72-
* @param string $anotherField
73-
* @param mixed $value
72+
* @param string $anotherField Field name to compare with
73+
* @param mixed $value Value of another field to compare with
7474
* @return static
7575
*/
7676
public function requiredIf(string $anotherField, $value)
@@ -81,8 +81,8 @@ public function requiredIf(string $anotherField, $value)
8181
/**
8282
* The field under validation must be present and not empty unless the anotherField field is equal to any value.
8383
*
84-
* @param string $anotherField
85-
* @param mixed $value
84+
* @param string $anotherField Field to compare with
85+
* @param mixed $value Value of another field to compare with
8686
* @return static
8787
*/
8888
public function requiredUnless(string $anotherField, $value)

src/Rule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public static function date(): DateRuleSet
132132
/**
133133
* The file under validation must be an image (jpeg, png, bmp, gif, or svg)
134134
*
135-
* @param array|\Closure|\Illuminate\Validation\Rules\Dimensions $constraints
135+
* @param array|\Closure|\Illuminate\Validation\Rules\Dimensions $constraints Image constraints
136+
* @see https://laravel.com/docs/5.5/validation#rule-dimensions
136137
* @return ImageRuleSet
137138
*/
138139
public static function image($constraints = []): ImageRuleSet

0 commit comments

Comments
 (0)