Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Config] Add ExprBuilder::ifEmpty()#19764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromogizanagi:feature/3.2/config/if_empty_expr_builder
Aug 31, 2016
Merged

[Config] Add ExprBuilder::ifEmpty()#19764

fabpot merged 1 commit intosymfony:masterfromogizanagi:feature/3.2/config/if_empty_expr_builder
Aug 31, 2016

Conversation

@ogizanagi
Copy link
Contributor

@ogizanagiogizanagi commentedAug 27, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PRsymfony/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:

$builder =newTreeBuilder();$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' => []]);>>> []

chalasr, javiereguiluz, and linaori reacted with thumbs up emoji
* @return ExprBuilder
*/
publicfunctionifEmpty()
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What if$v equals0 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

having the same behavior thanempty($v) is fine with me. If we do something else, we should change the name away fromifEmpty to avoid WTF moments IMO

ogizanagi and fsevestre reacted with thumbs up emoji
Copy link
ContributorAuthor

@ogizanagiogizanagiAug 30, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

As@stof said, it isn't an issue to me, because anyone using it must understand it behaves like its phpempty function counterpart, and know the limitations.
Otherwise, we have to rename it toisEmptyArray, or whatever, but right now I think the expression builder should stick with simple expressions like this.

If you really expect'',false,null,'0' or0 to be valid for your node, you shouldn't useifEmpty.

fsevestre reacted with thumbs up emoji
@fabpot
Copy link
Member

Thank you@ogizanagi.

@fabpotfabpot merged commit4e46f64 intosymfony:masterAug 31, 2016
fabpot added a commit that referenced this pull requestAug 31, 2016
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#6922Useful 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()
@ogizanagiogizanagi deleted the feature/3.2/config/if_empty_expr_builder branchAugust 31, 2016 18:31
weaverryan added a commit to symfony/symfony-docs that referenced this pull requestSep 18, 2016
This PR was merged into the master branch.Discussion----------[Config] Add ExprBuilder::ifEmpty()Aftersymfony/symfony#19764Commits-------f0fe739 [WCM][Config] Add ExprBuilder::ifEmpty()
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@ogizanagi@fabpot@stof@fsevestre@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp