minor #12384 [OptionsResolver] Documented BC break (webmozart)
This PR was merged into the 2.6-dev branch.
Discussion
----------
[OptionsResolver] Documented BC break
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #12378
| License | MIT
| Doc PR | -
Commits
-------
0b0bfc0
[OptionsResolver] Documented BC break
This commit is contained in:
commit
4b01bc0ec4
@ -309,3 +309,43 @@ OptionsResolver
|
||||
$options = $resolver->resolve($options);
|
||||
```
|
||||
|
||||
* When undefined options are passed, `resolve()` now throws an
|
||||
`UndefinedOptionsException` instead of an `InvalidOptionsException`.
|
||||
`InvalidOptionsException` is only thrown when option values fail their
|
||||
validation constraints.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
$resolver->setDefaults(array(
|
||||
'transport' => 'smtp',
|
||||
'port' => 25,
|
||||
));
|
||||
$resolver->setAllowedTypes(array(
|
||||
'port' => 'integer',
|
||||
));
|
||||
|
||||
// throws InvalidOptionsException
|
||||
$resolver->resolve(array('foo' => 'bar'));
|
||||
|
||||
// throws InvalidOptionsException
|
||||
$resolver->resolve(array('port' => '25'));
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
$resolver->setDefaults(array(
|
||||
'transport' => 'smtp',
|
||||
'port' => 25,
|
||||
));
|
||||
$resolver->setAllowedTypes(array(
|
||||
'port' => 'integer',
|
||||
));
|
||||
|
||||
// throws UndefinedOptionsException
|
||||
$resolver->resolve(array('foo' => 'bar'));
|
||||
|
||||
// throws InvalidOptionsException
|
||||
$resolver->resolve(array('port' => '25'));
|
||||
```
|
||||
|
@ -42,3 +42,5 @@ CHANGELOG
|
||||
RuntimeException
|
||||
* [BC BREAK] normalizers are not executed anymore for unset options
|
||||
* normalizers are executed after validating the options now
|
||||
* [BC BREAK] an UndefinedOptionsException is now thrown instead of an
|
||||
InvalidOptionsException when non-existing options are passed
|
||||
|
Reference in New Issue
Block a user