Skip to content

Commit

Permalink
Small coding standards and docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquemoody committed Oct 24, 2015
1 parent 474afaa commit cd46545
Show file tree
Hide file tree
Showing 38 changed files with 66 additions and 66 deletions.
2 changes: 1 addition & 1 deletion docs/ArrayVal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- `v::arrayVal()`

Validates if the input is an array or if the input be used as an array
Validates if the input is an array or if the input can be used as an array
(instance of `ArrayAccess`).

```php
Expand Down
2 changes: 1 addition & 1 deletion library/Exceptions/BoolValException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class BoolValException extends ValidationException
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} must not be a boolean value',
]
],
];
}
2 changes: 1 addition & 1 deletion library/Exceptions/FloatTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class FloatTypeException extends ValidationException
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} must not be of the type float',
]
],
];
}
4 changes: 2 additions & 2 deletions library/Rules/Bsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Respect\Validation\Rules;

/**
* Validates a Dutch citizen service number (BSN)
* Validates a Dutch citizen service number (BSN).
*
* @author Ronald Drenth <[email protected]>
*
Expand All @@ -34,7 +34,7 @@ public function validate($input)
}

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

Expand Down
6 changes: 3 additions & 3 deletions library/Rules/CountryCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
class CountryCode extends AbstractSearcher
{
const ALPHA2 = 'alpha-2';
const ALPHA3 = 'alpha-3';
const ALPHA2 = 'alpha-2';
const ALPHA3 = 'alpha-3';
const NUMERIC = 'numeric';

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

$this->set = $set;
$this->set = $set;
$this->index = $index;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Rules/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private function verifyMod10($input)
{
$sum = 0;
$input = strrev($input);
for ($i = 0; $i < strlen($input); $i++) {
for ($i = 0; $i < strlen($input); ++$i) {
$current = substr($input, $i, 1);
if ($i % 2 == 1) {
$current *= 2;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/NfeAccessKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function validate($aK)
}

$w = [];
for ($i = 0, $z = 5, $m = 43; $i <= $m; $i++) {
for ($i = 0, $z = 5, $m = 43; $i <= $m; ++$i) {
$z = ($i < $m) ? ($z - 1) == 1 ? 9 : ($z - 1) : 0;
$w[] = $z;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/VideoUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class VideoUrl extends AbstractRule
];

/**
* Create a new instance VideoUrl
* Create a new instance VideoUrl.
*
* @param string $service
*/
Expand Down
2 changes: 1 addition & 1 deletion library/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* @method static Validator each(Validatable $itemValidator = null, Validatable $keyValidator = null)
* @method static Validator email()
* @method static Validator endsWith(mixed $endValue, bool $identical = false)
* @method static Validator equals(mixed $compareTo, bool $compareIdentical = false)
* @method static Validator equals(mixed $compareTo)
* @method static Validator even()
* @method static Validator executable()
* @method static Validator exists()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/exception_update.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Respect\Validation\Validator as v;
try {
v::not(v::alnum())->check('abc123');
} catch (Exception $exception) {
$exception->setParam('translator', function() {
$exception->setParam('translator', function () {
return '{{name}} não deve conter letras (a-z) ou dígitos (0-9)';
});
echo $exception->getMessage();
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/issue-425.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\AllOfException;
use Respect\Validation\Validator as v;

$validator = v::create()
->key('age', v::intType()->notEmpty()->noneOf(v::stringType()))
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/readme/example_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ require 'vendor/autoload.php';

use Respect\Validation\Validator as v;

$user = new stdClass;
$user = new stdClass();
$user->name = 'Alexandre';
$user->birthdate = '1987-07-01';

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

$userValidator->assert($user);
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/readme/example_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v;

$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
try {
$usernameValidator->assert('really messed up screen#name');
} catch(NestedValidationException $exception) {
echo $exception->getFullMessage();
} catch (NestedValidationException $exception) {
echo $exception->getFullMessage();
}
?>
--EXPECTF--
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/readme/example_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v;

$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
try {
$usernameValidator->assert('really messed up screen#name');
} catch(NestedValidationException $exception) {
} catch (NestedValidationException $exception) {
print_r($exception->findMessages(['alnum', 'noWhitespace']));
}
?>
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/readme/example_4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Validator as v;

$usernameValidator = v::alnum()->noWhitespace()->length(1, 15);
try {
$usernameValidator->assert('really messed up screen#name');
} catch(NestedValidationException $exception) {
} catch (NestedValidationException $exception) {
print_r($exception->getMessages());
}
?>
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/allOf_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\ConsonantException;
use Respect\Validation\Validator as v;

try {
v::allOf(v::stringType(), v::consonant())->check('Luke i\'m your father');
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/allOf_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\AllOfException;
use Respect\Validation\Validator as v;

try {
v::allOf(v::stringType(), v::consonant())->assert(42);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/allOf_4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\IntTypeException;
use Respect\Validation\Validator as v;

try {
v::not(v::allOf(v::intType(), v::positive()))->check(42);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/allOf_5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<?php
require 'vendor/autoload.php';

use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\AllOfException;
use Respect\Validation\Validator as v;

try {
v::not(v::allOf(v::stringType(), v::length(10)))->assert('Frank Zappa is fantastic');
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/beetwen_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Respect\Validation\Validator as v;

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

?>
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/rules/boolval_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ use Respect\Validation\Validator as v;
try {
v::boolVal()->check('ok');
} catch (BoolValException $e) {
echo $e->getMainMessage() . PHP_EOL;
echo $e->getMainMessage().PHP_EOL;
}

try {
v::not(v::boolVal())->check('yes');
} catch (BoolValException $e) {
echo $e->getMainMessage() . PHP_EOL;
echo $e->getMainMessage().PHP_EOL;
}

try {
v::boolVal()->assert('yep');
} catch (AllOfException $e) {
echo $e->getFullMessage() . PHP_EOL;
echo $e->getFullMessage().PHP_EOL;
}

try {
v::not(v::boolVal())->assert('on');
} catch (AllOfException $e) {
echo $e->getFullMessage() . PHP_EOL;
echo $e->getFullMessage().PHP_EOL;
}
?>
--EXPECTF--
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/rules/ip_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use Respect\Validation\Validator as v;
try {
v::ip()->check('foo');
} catch (IpException $e) {
echo $e->getMainMessage() . PHP_EOL;
echo $e->getMainMessage().PHP_EOL;
}

try {
v::ip()->assert('foo');
} catch (AllOfException $e) {
echo $e->getFullMessage() . PHP_EOL;
echo $e->getFullMessage().PHP_EOL;
}
?>
--EXPECTF--
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/rules/ip_4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use Respect\Validation\Validator as v;
try {
v::not(v::ip())->check('10.0.0.1');
} catch (IpException $e) {
echo $e->getMainMessage() . PHP_EOL;
echo $e->getMainMessage().PHP_EOL;
}

try {
v::not(v::ip())->assert('10.0.0.1');
} catch (AllOfException $e) {
echo $e->getFullMessage() . PHP_EOL;
echo $e->getFullMessage().PHP_EOL;
}
?>
--EXPECTF--
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/rules/ip_5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use Respect\Validation\Validator as v;
try {
v::ip('127.0.1.*')->check('127.0.0.1');
} catch (IpException $e) {
echo $e->getMainMessage() . PHP_EOL;
echo $e->getMainMessage().PHP_EOL;
}

try {
v::ip('127.0.1.*')->assert('127.0.0.1');
} catch (AllOfException $e) {
echo $e->getFullMessage() . PHP_EOL;
echo $e->getFullMessage().PHP_EOL;
}
?>
--EXPECTF--
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/iterable_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ require 'vendor/autoload.php';
use Respect\Validation\Validator as v;

v::iterable()->assert([1, 2, 3]);
v::iterable()->check(new ArrayObject);
v::iterable()->check(new ArrayObject());
?>
--EXPECTF--
2 changes: 1 addition & 1 deletion tests/integration/rules/keyValue_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
$data = [
'password' => 'shuberry',
'password_confirmation' => 'shuberry',
'valid_passwords' => ['shuberry', 'monty-python']
'valid_passwords' => ['shuberry', 'monty-python'],
];

v::keyValue('password', 'equals', 'password_confirmation')->check($data);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/keyValue_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;

$data = [
'password' => 'shuberry',
'password_confirmation' => '_shuberry_'
'password_confirmation' => '_shuberry_',
];

try {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/notBlank_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
$notBlankValues = [
'a',
1,
1.0
1.0,
];

//Check the "pure" value
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/notEmpty_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Respect\Validation\Validator as v;
$notEmptyValues = [
'a',
1,
1.0
1.0,
];

//Check not empty values
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/rules/objectType_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'vendor/autoload.php';

use Respect\Validation\Validator as v;

v::objectType()->assert(new stdClass);
v::objectType()->check(new stdClass);
v::objectType()->assert(new stdClass());
v::objectType()->check(new stdClass());
?>
--EXPECTF--
2 changes: 1 addition & 1 deletion tests/unit/Exceptions/NestedValidationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* phpunit has an issue with mocking exceptions when in HHVM:
* https://github.com/sebastianbergmann/phpunit-mock-objects/issues/207
* https://github.com/sebastianbergmann/phpunit-mock-objects/issues/207.
*/
class PrivateNestedValidationException extends NestedValidationException
{
Expand Down
Loading

0 comments on commit cd46545

Please sign in to comment.