Skip to content

Commit

Permalink
feature #13808 [OptionsResolver] removed deprecated functionality (To…
Browse files Browse the repository at this point in the history
…bion)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[OptionsResolver] removed deprecated functionality

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | -

Commits
-------

295bba2 [OptionsResolver] removed deprecated functionality
  • Loading branch information
Tobion committed Mar 2, 2015
2 parents 5bf779d + 295bba2 commit f538167
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1,211 deletions.
177 changes: 4 additions & 173 deletions src/Symfony/Component/OptionsResolver/OptionsResolver.php
Expand Up @@ -423,31 +423,6 @@ public function setNormalizer($option, \Closure $normalizer)
return $this;
}

/**
* Sets the normalizers for an array of options.
*
* @param array $normalizers An array of closures
*
* @return OptionsResolver This instance
*
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*
* @see setNormalizer()
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setNormalizers(array $normalizers)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use setNormalizer() instead.', E_USER_DEPRECATED);

foreach ($normalizers as $option => $normalizer) {
$this->setNormalizer($option, $normalizer);
}

return $this;
}

/**
* Sets allowed values for an option.
*
Expand All @@ -469,23 +444,12 @@ public function setNormalizers(array $normalizers)
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function setAllowedValues($option, $allowedValues = null)
public function setAllowedValues($option, $allowedValues)
{
if ($this->locked) {
throw new AccessException('Allowed values cannot be set from a lazy option or normalizer.');
}

// BC
if (is_array($option) && null === $allowedValues) {
trigger_error('Calling the '.__METHOD__.' method with an array of options is deprecated since version 2.6 and will be removed in 3.0. Use the new signature with a single option instead.', E_USER_DEPRECATED);

foreach ($option as $optionName => $optionValues) {
$this->setAllowedValues($optionName, $optionValues);
}

return $this;
}

if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf(
'The option "%s" does not exist. Defined options are: "%s".',
Expand Down Expand Up @@ -525,23 +489,12 @@ public function setAllowedValues($option, $allowedValues = null)
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function addAllowedValues($option, $allowedValues = null)
public function addAllowedValues($option, $allowedValues)
{
if ($this->locked) {
throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.');
}

// BC
if (is_array($option) && null === $allowedValues) {
trigger_error('Calling the '.__METHOD__.' method with an array of options is deprecated since version 2.6 and will be removed in 3.0. Use the new signature with a single option instead.', E_USER_DEPRECATED);

foreach ($option as $optionName => $optionValues) {
$this->addAllowedValues($optionName, $optionValues);
}

return $this;
}

if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf(
'The option "%s" does not exist. Defined options are: "%s".',
Expand Down Expand Up @@ -581,23 +534,12 @@ public function addAllowedValues($option, $allowedValues = null)
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function setAllowedTypes($option, $allowedTypes = null)
public function setAllowedTypes($option, $allowedTypes)
{
if ($this->locked) {
throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.');
}

// BC
if (is_array($option) && null === $allowedTypes) {
trigger_error('Calling the '.__METHOD__.' method with an array of options is deprecated since version 2.6 and will be removed in 3.0. Use the new signature with a single option instead.', E_USER_DEPRECATED);

foreach ($option as $optionName => $optionTypes) {
$this->setAllowedTypes($optionName, $optionTypes);
}

return $this;
}

if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf(
'The option "%s" does not exist. Defined options are: "%s".',
Expand Down Expand Up @@ -631,23 +573,12 @@ public function setAllowedTypes($option, $allowedTypes = null)
* @throws UndefinedOptionsException If the option is undefined
* @throws AccessException If called from a lazy option or normalizer
*/
public function addAllowedTypes($option, $allowedTypes = null)
public function addAllowedTypes($option, $allowedTypes)
{
if ($this->locked) {
throw new AccessException('Allowed types cannot be added from a lazy option or normalizer.');
}

// BC
if (is_array($option) && null === $allowedTypes) {
trigger_error('Calling the '.__METHOD__.' method with an array of options is deprecated since version 2.6 and will be removed in 3.0. Use the new signature with a single option instead.', E_USER_DEPRECATED);

foreach ($option as $optionName => $optionTypes) {
$this->addAllowedTypes($optionName, $optionTypes);
}

return $this;
}

if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf(
'The option "%s" does not exist. Defined options are: "%s".',
Expand Down Expand Up @@ -1031,106 +962,6 @@ public function count()
return count($this->defaults);
}

/**
* Alias of {@link setDefault()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function set($option, $value)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the setDefaults() method instead.', E_USER_DEPRECATED);

return $this->setDefault($option, $value);
}

/**
* Shortcut for {@link clear()} and {@link setDefaults()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function replace(array $defaults)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the clear() and setDefaults() methods instead.', E_USER_DEPRECATED);

$this->clear();

return $this->setDefaults($defaults);
}

/**
* Alias of {@link setDefault()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function overload($option, $value)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the setDefault() method instead.', E_USER_DEPRECATED);

return $this->setDefault($option, $value);
}

/**
* Alias of {@link offsetGet()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function get($option)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the ArrayAccess syntax instead to get an option value.', E_USER_DEPRECATED);

return $this->offsetGet($option);
}

/**
* Alias of {@link offsetExists()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function has($option)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the ArrayAccess syntax instead to get an option value.', E_USER_DEPRECATED);

return $this->offsetExists($option);
}

/**
* Shortcut for {@link clear()} and {@link setDefaults()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function replaceDefaults(array $defaultValues)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the clear() and setDefaults() methods instead.', E_USER_DEPRECATED);

$this->clear();

return $this->setDefaults($defaultValues);
}

/**
* Alias of {@link setDefined()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setOptional(array $optionNames)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the setDefined() method instead.', E_USER_DEPRECATED);

return $this->setDefined($optionNames);
}

/**
* Alias of {@link isDefined()}.
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function isKnown($option)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the isDefined() method instead.', E_USER_DEPRECATED);

return $this->isDefined($option);
}

/**
* Returns a string representation of the type of the value.
*
Expand Down

0 comments on commit f538167

Please sign in to comment.