Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Null Coalesce Operator #19

Closed
wants to merge 2 commits into from
Closed

Add Null Coalesce Operator #19

wants to merge 2 commits into from

Conversation

carusogabriel
Copy link
Contributor

@carusogabriel carusogabriel commented Jan 29, 2018

Some to help starts with: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.10/src/Fixer/Operator/TernaryToNullCoalescingFixer.php

Something to also be considering:

if (isset($foo)) {
    $bar = $foo;
} elseif (isset($baz)) {
    $bar = $baz;
} else {
    $bar = 'quux';
}

Already proposed and voted in #9 (comment)

@kukulich
Copy link
Contributor

@carusogabriel I can write the sniff for https://github.com/slevomat/coding-standard, would it be ok?

@carusogabriel
Copy link
Contributor Author

@kukulich Perfect. I'm not good at sniffers, so I appreciate your help 😄

@kukulich
Copy link
Contributor

Fine, I may write it in the evening if my children and wife allow :)

@kukulich
Copy link
Contributor

Ready for test: slevomat/coding-standard@476b0da


$bar = isset($bar['baz']) ? $bar['baz'] : 'baz';

if (isset($foo)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kukulich This case is already covered? I guess tests are failing here

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, it's not. It's a lot more complicated than simple ternary operator.

@carusogabriel
Copy link
Contributor Author

@Ocramius @Majkl578 @lcobucci How should we proceed now?

composer.json Outdated
@@ -18,7 +18,7 @@
"php": "^7.1",
"squizlabs/php_codesniffer": "^3.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2",
"slevomat/coding-standard": "^4.3.0"
"slevomat/coding-standard": "dev-master"
Copy link
Member

Choose a reason for hiding this comment

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

Same here: we need a stable release and then we can merge/release as well

@Majkl578 Majkl578 added this to the 3.0.0 milestone Feb 5, 2018
@carusogabriel carusogabriel changed the title [WIP] Add Null Coalesce Operator Add Null Coalesce Operator Feb 5, 2018
@Ocramius Ocramius self-assigned this Feb 6, 2018
@Ocramius Ocramius closed this in 2636a26 Feb 6, 2018
@Ocramius
Copy link
Member

Ocramius commented Feb 6, 2018

Manually merged in 2636a26

Thanks @kukulich and @carusogabriel!

@carusogabriel carusogabriel deleted the null-coalesce-operator branch February 6, 2018 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants