Skip to content

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


$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
"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