Skip to content

Commit cd46545

Browse files
committed
Small coding standards and docs improvements
1 parent 474afaa commit cd46545

38 files changed

+66
-66
lines changed

docs/ArrayVal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- `v::arrayVal()`
44

5-
Validates if the input is an array or if the input be used as an array
5+
Validates if the input is an array or if the input can be used as an array
66
(instance of `ArrayAccess`).
77

88
```php

library/Exceptions/BoolValException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ class BoolValException extends ValidationException
1818
],
1919
self::MODE_NEGATIVE => [
2020
self::STANDARD => '{{name}} must not be a boolean value',
21-
]
21+
],
2222
];
2323
}

library/Exceptions/FloatTypeException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ class FloatTypeException extends ValidationException
1919
],
2020
self::MODE_NEGATIVE => [
2121
self::STANDARD => '{{name}} must not be of the type float',
22-
]
22+
],
2323
];
2424
}

library/Rules/Bsn.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Respect\Validation\Rules;
1313

1414
/**
15-
* Validates a Dutch citizen service number (BSN)
15+
* Validates a Dutch citizen service number (BSN).
1616
*
1717
* @author Ronald Drenth <[email protected]>
1818
*
@@ -34,7 +34,7 @@ public function validate($input)
3434
}
3535

3636
$sum = -1 * $input[8];
37-
for ($i = 9; $i > 1; $i--) {
37+
for ($i = 9; $i > 1; --$i) {
3838
$sum += $i * $input[9 - $i];
3939
}
4040

library/Rules/CountryCode.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class CountryCode extends AbstractSearcher
2020
{
21-
const ALPHA2 = 'alpha-2';
22-
const ALPHA3 = 'alpha-3';
21+
const ALPHA2 = 'alpha-2';
22+
const ALPHA3 = 'alpha-3';
2323
const NUMERIC = 'numeric';
2424

2525
/**
@@ -293,7 +293,7 @@ public function __construct($set = self::ALPHA2)
293293
throw new ComponentException(sprintf('"%s" is not a valid country set for ISO 3166-1', $set));
294294
}
295295

296-
$this->set = $set;
296+
$this->set = $set;
297297
$this->index = $index;
298298
}
299299

library/Rules/CreditCard.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private function verifyMod10($input)
2727
{
2828
$sum = 0;
2929
$input = strrev($input);
30-
for ($i = 0; $i < strlen($input); $i++) {
30+
for ($i = 0; $i < strlen($input); ++$i) {
3131
$current = substr($input, $i, 1);
3232
if ($i % 2 == 1) {
3333
$current *= 2;

library/Rules/NfeAccessKey.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function validate($aK)
3333
}
3434

3535
$w = [];
36-
for ($i = 0, $z = 5, $m = 43; $i <= $m; $i++) {
36+
for ($i = 0, $z = 5, $m = 43; $i <= $m; ++$i) {
3737
$z = ($i < $m) ? ($z - 1) == 1 ? 9 : ($z - 1) : 0;
3838
$w[] = $z;
3939
}

library/Rules/VideoUrl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class VideoUrl extends AbstractRule
3434
];
3535

3636
/**
37-
* Create a new instance VideoUrl
37+
* Create a new instance VideoUrl.
3838
*
3939
* @param string $service
4040
*/

library/Validator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* @method static Validator each(Validatable $itemValidator = null, Validatable $keyValidator = null)
5656
* @method static Validator email()
5757
* @method static Validator endsWith(mixed $endValue, bool $identical = false)
58-
* @method static Validator equals(mixed $compareTo, bool $compareIdentical = false)
58+
* @method static Validator equals(mixed $compareTo)
5959
* @method static Validator even()
6060
* @method static Validator executable()
6161
* @method static Validator exists()

tests/integration/exception_update.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Respect\Validation\Validator as v;
88
try {
99
v::not(v::alnum())->check('abc123');
1010
} catch (Exception $exception) {
11-
$exception->setParam('translator', function() {
11+
$exception->setParam('translator', function () {
1212
return '{{name}} não deve conter letras (a-z) ou dígitos (0-9)';
1313
});
1414
echo $exception->getMessage();

tests/integration/issue-425.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
require 'vendor/autoload.php';
55

6-
use Respect\Validation\Validator as v;
76
use Respect\Validation\Exceptions\AllOfException;
7+
use Respect\Validation\Validator as v;
88

99
$validator = v::create()
1010
->key('age', v::intType()->notEmpty()->noneOf(v::stringType()))

tests/integration/readme/example_1.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ require 'vendor/autoload.php';
44

55
use Respect\Validation\Validator as v;
66

7-
$user = new stdClass;
7+
$user = new stdClass();
88
$user->name = 'Alexandre';
99
$user->birthdate = '1987-07-01';
1010

11-
$userValidator = v::attribute('name', v::stringType()->length(1,32))
11+
$userValidator = v::attribute('name', v::stringType()->length(1, 32))
1212
->attribute('birthdate', v::date()->age(18));
1313

1414
$userValidator->assert($user);

tests/integration/readme/example_2.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\NestedValidationException;
6+
use Respect\Validation\Validator as v;
77

88
$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
99
try {
1010
$usernameValidator->assert('really messed up screen#name');
11-
} catch(NestedValidationException $exception) {
12-
echo $exception->getFullMessage();
11+
} catch (NestedValidationException $exception) {
12+
echo $exception->getFullMessage();
1313
}
1414
?>
1515
--EXPECTF--

tests/integration/readme/example_3.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\NestedValidationException;
6+
use Respect\Validation\Validator as v;
77

88
$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
99
try {
1010
$usernameValidator->assert('really messed up screen#name');
11-
} catch(NestedValidationException $exception) {
11+
} catch (NestedValidationException $exception) {
1212
print_r($exception->findMessages(['alnum', 'noWhitespace']));
1313
}
1414
?>

tests/integration/readme/example_4.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\NestedValidationException;
6+
use Respect\Validation\Validator as v;
77

88
$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
99
try {
1010
$usernameValidator->assert('really messed up screen#name');
11-
} catch(NestedValidationException $exception) {
11+
} catch (NestedValidationException $exception) {
1212
print_r($exception->getMessages());
1313
}
1414
?>

tests/integration/rules/allOf_2.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\ConsonantException;
6+
use Respect\Validation\Validator as v;
77

88
try {
99
v::allOf(v::stringType(), v::consonant())->check('Luke i\'m your father');

tests/integration/rules/allOf_3.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\AllOfException;
6+
use Respect\Validation\Validator as v;
77

88
try {
99
v::allOf(v::stringType(), v::consonant())->assert(42);

tests/integration/rules/allOf_4.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\IntTypeException;
6+
use Respect\Validation\Validator as v;
77

88
try {
99
v::not(v::allOf(v::intType(), v::positive()))->check(42);

tests/integration/rules/allOf_5.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<?php
33
require 'vendor/autoload.php';
44

5-
use Respect\Validation\Validator as v;
65
use Respect\Validation\Exceptions\AllOfException;
6+
use Respect\Validation\Validator as v;
77

88
try {
99
v::not(v::allOf(v::stringType(), v::length(10)))->assert('Frank Zappa is fantastic');

tests/integration/rules/beetwen_1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Respect\Validation\Validator as v;
88

99
v::intType()->between(1, 42)->check(2);
1010
v::intType()->between(1, 2)->assert(2);
11-
v::date()->between('1989-12-20', 'tomorrow', false)->assert(new DateTime);
11+
v::date()->between('1989-12-20', 'tomorrow', false)->assert(new DateTime());
1212
v::stringType()->between('a', 'e', false)->assert('d');
1313

1414
?>

tests/integration/rules/boolval_2.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ use Respect\Validation\Validator as v;
99
try {
1010
v::boolVal()->check('ok');
1111
} catch (BoolValException $e) {
12-
echo $e->getMainMessage() . PHP_EOL;
12+
echo $e->getMainMessage().PHP_EOL;
1313
}
1414

1515
try {
1616
v::not(v::boolVal())->check('yes');
1717
} catch (BoolValException $e) {
18-
echo $e->getMainMessage() . PHP_EOL;
18+
echo $e->getMainMessage().PHP_EOL;
1919
}
2020

2121
try {
2222
v::boolVal()->assert('yep');
2323
} catch (AllOfException $e) {
24-
echo $e->getFullMessage() . PHP_EOL;
24+
echo $e->getFullMessage().PHP_EOL;
2525
}
2626

2727
try {
2828
v::not(v::boolVal())->assert('on');
2929
} catch (AllOfException $e) {
30-
echo $e->getFullMessage() . PHP_EOL;
30+
echo $e->getFullMessage().PHP_EOL;
3131
}
3232
?>
3333
--EXPECTF--

tests/integration/rules/ip_3.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use Respect\Validation\Validator as v;
99
try {
1010
v::ip()->check('foo');
1111
} catch (IpException $e) {
12-
echo $e->getMainMessage() . PHP_EOL;
12+
echo $e->getMainMessage().PHP_EOL;
1313
}
1414

1515
try {
1616
v::ip()->assert('foo');
1717
} catch (AllOfException $e) {
18-
echo $e->getFullMessage() . PHP_EOL;
18+
echo $e->getFullMessage().PHP_EOL;
1919
}
2020
?>
2121
--EXPECTF--

tests/integration/rules/ip_4.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use Respect\Validation\Validator as v;
99
try {
1010
v::not(v::ip())->check('10.0.0.1');
1111
} catch (IpException $e) {
12-
echo $e->getMainMessage() . PHP_EOL;
12+
echo $e->getMainMessage().PHP_EOL;
1313
}
1414

1515
try {
1616
v::not(v::ip())->assert('10.0.0.1');
1717
} catch (AllOfException $e) {
18-
echo $e->getFullMessage() . PHP_EOL;
18+
echo $e->getFullMessage().PHP_EOL;
1919
}
2020
?>
2121
--EXPECTF--

tests/integration/rules/ip_5.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use Respect\Validation\Validator as v;
99
try {
1010
v::ip('127.0.1.*')->check('127.0.0.1');
1111
} catch (IpException $e) {
12-
echo $e->getMainMessage() . PHP_EOL;
12+
echo $e->getMainMessage().PHP_EOL;
1313
}
1414

1515
try {
1616
v::ip('127.0.1.*')->assert('127.0.0.1');
1717
} catch (AllOfException $e) {
18-
echo $e->getFullMessage() . PHP_EOL;
18+
echo $e->getFullMessage().PHP_EOL;
1919
}
2020
?>
2121
--EXPECTF--

tests/integration/rules/iterable_1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ require 'vendor/autoload.php';
66
use Respect\Validation\Validator as v;
77

88
v::iterable()->assert([1, 2, 3]);
9-
v::iterable()->check(new ArrayObject);
9+
v::iterable()->check(new ArrayObject());
1010
?>
1111
--EXPECTF--

tests/integration/rules/keyValue_1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
77
$data = [
88
'password' => 'shuberry',
99
'password_confirmation' => 'shuberry',
10-
'valid_passwords' => ['shuberry', 'monty-python']
10+
'valid_passwords' => ['shuberry', 'monty-python'],
1111
];
1212

1313
v::keyValue('password', 'equals', 'password_confirmation')->check($data);

tests/integration/rules/keyValue_2.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
77

88
$data = [
99
'password' => 'shuberry',
10-
'password_confirmation' => '_shuberry_'
10+
'password_confirmation' => '_shuberry_',
1111
];
1212

1313
try {

tests/integration/rules/notBlank_1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
77
$notBlankValues = [
88
'a',
99
1,
10-
1.0
10+
1.0,
1111
];
1212

1313
//Check the "pure" value

tests/integration/rules/notEmpty_1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
77
$notEmptyValues = [
88
'a',
99
1,
10-
1.0
10+
1.0,
1111
];
1212

1313
//Check not empty values

tests/integration/rules/objectType_1.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require 'vendor/autoload.php';
44

55
use Respect\Validation\Validator as v;
66

7-
v::objectType()->assert(new stdClass);
8-
v::objectType()->check(new stdClass);
7+
v::objectType()->assert(new stdClass());
8+
v::objectType()->check(new stdClass());
99
?>
1010
--EXPECTF--

tests/unit/Exceptions/NestedValidationExceptionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/**
1515
* phpunit has an issue with mocking exceptions when in HHVM:
16-
* https://github.com/sebastianbergmann/phpunit-mock-objects/issues/207
16+
* https://github.com/sebastianbergmann/phpunit-mock-objects/issues/207.
1717
*/
1818
class PrivateNestedValidationException extends NestedValidationException
1919
{

0 commit comments

Comments
 (0)