This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony
Fabien Potencier 5c561d48f8 bug #15593 [Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors (ogizanagi)
This PR was merged into the 2.8 branch.

Discussion
----------

[Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors

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

Due to #14238 , no more exception is thrown when submitting extra keys to an `ArrayNode`.
For instance:

```php
$builder = new TreeBuilder();

$nodeDefinition = $builder->root('root')
    ->children()
        ->scalarNode('foo')
    ->end()
->end();

$node = $nodeDefinition->getNode(true);
$node->normalize(array(
    'foo' => 'ok',
    'bar' => 'ko',
));
```

will not throw a
> Symfony\Component\Config\Definition\Exception\InvalidConfigurationException: Unrecognized option "bar" under "root"`

anymore, as it does in 2.7.

I think the expected behavior is:

`Submitted data: ['bar' => 'ko']`

Ignore | Remove  | Expected | OK | Comment
---------| ------------ | ------------- | ------ | ----------
true    | true          | `[ ]`                   | ✔︎ | Previous behavior when ignoring.
true    | false          | `['bar' => 'ko']` | ✔︎ | This is the result targeted by #14238.
false    | true          | exception    | ✘ | Removing makes no sense when not ignoring extra keys. <br/>The exception should still be thrown.
false    | false          | exception    | ✘ | Previous behavior (2.7). <br/>Should not have changed

Commits
-------

d961f7f [Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors
2015-09-30 13:24:58 +02:00
..
Bridge Merge branch '2.7' into 2.8 2015-09-29 14:32:55 +02:00
Bundle Remove profiler storages 2015-09-30 11:11:05 +02:00
Component bug #15593 [Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors (ogizanagi) 2015-09-30 13:24:58 +02:00