mirror of
https://github.com/Respect/Validation.git
synced 2024-06-18 13:35:06 +02:00
Make second argument of "AbstractEnvelope" optional
The argument "parameters" which is meant to give the wrapped rule's exception some extra information does not always need to be defined, for example when the exception does not need any parameter. The current version of "AbstractEnvelope" required that argument and the rules that are extending this class are passing an empty array. This commit will make the "parameters" argument optional. As an extra, it will make sure the tests from the children of "AbstractEnvelope" are also covering their parent. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
9595b3fd6c
commit
93e177a4c0
|
@ -42,7 +42,7 @@ abstract class AbstractEnvelope extends AbstractRule
|
|||
* @param Validatable $validatable
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(Validatable $validatable, array $parameters)
|
||||
public function __construct(Validatable $validatable, array $parameters = [])
|
||||
{
|
||||
$this->validatable = $validatable;
|
||||
$this->parameters = $parameters;
|
||||
|
|
|
@ -53,6 +53,6 @@ final class FilterVar extends AbstractEnvelope
|
|||
throw new ComponentException('Cannot accept the given filter');
|
||||
}
|
||||
|
||||
parent::__construct(new Callback('filter_var', $filter, $options), []);
|
||||
parent::__construct(new Callback('filter_var', $filter, $options));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,6 @@ final class Url extends AbstractEnvelope
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new FilterVar(FILTER_VALIDATE_URL), []);
|
||||
parent::__construct(new FilterVar(FILTER_VALIDATE_URL));
|
||||
}
|
||||
}
|
||||
|
|
0
tests/fixtures/non-writable
vendored
Normal file → Executable file
0
tests/fixtures/non-writable
vendored
Normal file → Executable file
|
@ -20,6 +20,7 @@ use Respect\Validation\Test\Stubs\CountableStub;
|
|||
/**
|
||||
* @group rule
|
||||
*
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\Between
|
||||
*/
|
||||
final class BetweenTest extends RuleTestCase
|
||||
|
|
|
@ -24,6 +24,7 @@ use const FILTER_VALIDATE_URL;
|
|||
/**
|
||||
* @group rule
|
||||
*
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\FilterVar
|
||||
*
|
||||
* @author Gabriel Caruso <carusogabriel34@gmail.com>
|
||||
|
|
|
@ -19,6 +19,7 @@ use Respect\Validation\Test\RuleTestCase;
|
|||
/**
|
||||
* @group rule
|
||||
*
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\LanguageCode
|
||||
*
|
||||
* @author Danilo Benevides <danilobenevides01@gmail.com>
|
||||
|
|
|
@ -18,6 +18,7 @@ use Respect\Validation\Test\RuleTestCase;
|
|||
/**
|
||||
* @group rule
|
||||
*
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\Url
|
||||
*
|
||||
* @author Gabriel Caruso <carusogabriel34@gmail.com>
|
||||
|
|
Loading…
Reference in a new issue