Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #19764 [Config] Add ExprBuilder::ifEmpty() (ogizanagi)
This PR was merged into the 3.2-dev branch. Discussion ---------- [Config] Add ExprBuilder::ifEmpty() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | symfony/symfony-docs#6922 Useful for instance when you don't expect to have a key set in the resolved config if its content is empty: ```php $builder = new TreeBuilder(); $tree = $builder ->root('matcher') ->children() ->arrayNode('references_to_exclude') ->validate() ->ifEmpty() ->thenUnset() ->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->buildTree() ; $tree->finalize(['references_to_exclude' => ['foo', 'bar']]); >>> ['references_to_exclude' => ['foo', 'bar']] $tree->finalize(['references_to_exclude' => []]); >>> [] ``` Commits ------- 4e46f64 [Config] Add ExprBuilder::ifEmpty()
- Loading branch information