8000 [OptionsResolver] Fixed exceptions thrown by the Options class · symfony/symfony@cf3ccc3 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf3ccc3

Browse files
committed
[OptionsResolver] Fixed exceptions thrown by the Options class
1 parent 78f1e33 commit cf3ccc3

File tree

7 files< 8000 !-- --> changed

+93
-57
lines changed

7 files changed

+93
-57
lines changed

src/Symfony/Component/OptionsResolver/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ CHANGELOG
2828
lazy option/normalizer closures resulted in exceptions
2929
* [BC BREAK] removed Options::all() since using within lazy option/normalizer
3030
closures resulted in exceptions
31+
* [BC BREAK] OptionDefinitionException now extends LogicException instead of
32+
RuntimeException
33+
* [BC BREAK] the modifying methods in Options (set(), setNormalizer(), ...) now
34+
throw an AccessException if they may not be accessed anymore because resolving
35+
has started. Previously, they threw an OptionDefinitionException

src/Symfony/Component/OptionsResolver/Exception/ReadException.php renamed to src/Symfony/Component/OptionsResolver/Exception/AccessException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
namespace Symfony\Component\OptionsResolver\Exception;
1313

1414
/**
15-
* Thrown when trying to read an option outside of {@link Options::resolve()}.
15+
* Thrown when trying to read an option outside of or write it inside of
16+
* {@link Options::resolve()}.
1617
*
1718
* @author Bernhard Schussek <bschussek@gmail.com>
1819
*/
19-
class ReadException extends \RuntimeException implements ExceptionInterface
20+
class AccessException extends \LogicException implements ExceptionInterface
2021
{
2122
}

src/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
namespace Symfony\Component\OptionsResolver\Exception;
1313

1414
/**
15-
* Exception thrown when an invalid option is passed.
15+
* Thrown when the value of an option does not match its validation rules.
16+
*
17+
* You should make sure a valid value is passed to the option.
1618
*
1719
* @author Bernhard Schussek <bschussek@gmail.com>
1820
*/
19-
class InvalidOptionsException extends \InvalidArgumentException implements ExceptionInterface
21+
class InvalidOptionsException extends InvalidArgumentException
2022
{
2123
}

src/Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
/**
1515
* Exception thrown when a required option is missing.
1616
*
17+
* Add the option to the passed options array.
18+
*
1719
* @author Bernhard Schussek <bschussek@gmail.com>
1820
*/
19-
class MissingOptionsException extends \InvalidArgumentException implements ExceptionInterface
21+
class MissingOptionsException extends InvalidArgumentException
2022
{
2123
}

src/Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php

Lines changed: 2 additions & 2 deletions
E30A
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
namespace Symfony\Component\OptionsResolver\Exception;
1313

1414
/**
15-
* Thrown when an option definition is invalid.
15+
* Thrown when two lazy options have a cyclic dependency.
1616
*
1717
* @author Bernhard Schussek <bschussek@gmail.com>
1818
*/
19-
class OptionDefinitionException extends \RuntimeException implements ExceptionInterface
19+
class OptionDefinitionException extends \LogicException implements ExceptionInterface
2020
{
2121
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\OptionsResolver\Exception;
13+
14+
/**
15+
* Exception thrown when an undefined option is passed.
16+
*
17+
* You should remove the options in question from your code or define them
18+
* beforehand.
19+
*
20+
* @author Bernhard Schussek <bschussek@gmail.com>
21+
*/
22+
class UndefinedOptionsException extends InvalidArgumentException
23+
{
24+
}

0 commit comments

Comments
 (0)
0