Skip to content

Conversation

@sidz
Copy link
Member

@sidz sidz commented Jul 14, 2024

This PR doesn't bring a big value it just replacing $variable ?? $variable = $this->dosmth() with Null Coalescing Assignment Operator $variable ??= $this->dosmth()

Unfortunately there is no any rule nor in Rector or PHP-CS-Fixer which may cover such cases and fail builds in the future.

Existing in both projects doesn't take into account properties.
PHP-CS-Fixer: https://cs.symfony.com/doc/rules/operator/assign_null_coalescing_to_coalesce_equal.html
Rector: https://github.com/rectorphp/rector/blob/main/rules/Php74/Rector/Assign/NullCoalescingOperatorRector.php

Copy link
Member

@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

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

up to you: does it make sense to create an issue in rector/php-cs-fixer to support properties? or is there any issue, probably you already found?

@sidz
Copy link
Member Author

sidz commented Jul 15, 2024

or is there any issue, probably you already found?

I didn't find any solution yet.

does it make sense to create an issue in rector/php-cs-fixer to support properties?

That was my plan to create an issue in Rector.

@sidz sidz merged commit b003774 into master Jul 15, 2024
@sidz sidz deleted the use-null-coalesce-assignment-operator branch July 15, 2024 07:40
@sidz
Copy link
Member Author

sidz commented Jul 15, 2024

thanks @maks-rafalko, @theofidry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants