minor #32235 [OptionResolver] Add type-hints to OptionResolver class (jschaedl)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[OptionResolver] Add type-hints to OptionResolver class

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #32179  <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A <!-- required for new features -->

This PR adds type hints to the `OptionResolver` class.

Commits
-------

b26b37dffc [OptionResolver] Add type-hints to OptionResolver class
This commit is contained in:
Fabien Potencier 2019-06-29 08:47:46 +02:00
commit 7485b6f94d
1 changed files with 10 additions and 10 deletions

View File

@ -163,7 +163,7 @@ class OptionsResolver implements Options
*
* @throws AccessException If called from a lazy option or normalizer
*/
public function setDefault($option, $value)
public function setDefault(string $option, $value)
{
// Setting is not possible once resolving starts, because then lazy
// options could manipulate the state of the object, leading to
@ -257,7 +257,7 @@ class OptionsResolver implements Options
*
* @return bool Whether a default value is set
*/
public function hasDefault($option)
public function hasDefault(string $option)
{
return \array_key_exists($option, $this->defaults);
}
@ -294,7 +294,7 @@ class OptionsResolver implements Options
*
* @return bool Whether the option is required
*/
public function isRequired($option)
public function isRequired(string $option)
{
return isset($this->required[$option]);
}
@ -322,7 +322,7 @@ class OptionsResolver implements Options
*
* @return bool Whether the option is missing
*/
public function isMissing($option)
public function isMissing(string $option)
{
return isset($this->required[$option]) && !\array_key_exists($option, $this->defaults);
}
@ -375,7 +375,7 @@ class OptionsResolver implements Options
*
* @return bool Whether the option is defined
*/
public function isDefined($option)
public function isDefined(string $option)
{
return isset($this->defined[$option]);
}
@ -474,7 +474,7 @@ class OptionsResolver implements Options
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function setNormalizer($option, \Closure $normalizer)
public function setNormalizer(string $option, \Closure $normalizer)
{
if ($this->locked) {
throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.');
@ -562,7 +562,7 @@ class OptionsResolver implements Options
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function setAllowedValues($option, $allowedValues)
public function setAllowedValues(string $option, $allowedValues)
{
if ($this->locked) {
throw new AccessException('Allowed values cannot be set from a lazy option or normalizer.');
@ -603,7 +603,7 @@ class OptionsResolver implements Options
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function addAllowedValues($option, $allowedValues)
public function addAllowedValues(string $option, $allowedValues)
{
if ($this->locked) {
throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.');
@ -644,7 +644,7 @@ class OptionsResolver implements Options
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function setAllowedTypes($option, $allowedTypes)
public function setAllowedTypes(string $option, $allowedTypes)
{
if ($this->locked) {
throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.');
@ -679,7 +679,7 @@ class OptionsResolver implements Options
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function addAllowedTypes($option, $allowedTypes)
public function addAllowedTypes(string $option, $allowedTypes)
{
if ($this->locked) {
throw new AccessException('Allowed types cannot be added from a lazy option or normalizer.');