Php-cs-fixer: Increment/Decrement fixer

Created on 8 Nov 2017  路  7Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

// from
$i += 1;
// to
++$i;

// from
$i = $i + 1;
// to
++$i;

// from
$i -= 1;
// to
--$i;

// from
$i = $i - 1;
// to
--$i;
kinfeature request

Most helpful comment

then I;m afraid one will want to have reverse fixer...

All 7 comments

then I;m afraid one will want to have reverse fixer...

I like this one :)

@keradus Fixer 'increment_style' already exists for this :)

I think it was about the reverse of;
proposed:

// from
$i = $i - 1;
// to
--$i;

reverse of proposed:

// from
--$i;
// to
$i = $i - 1;

we don't have a fixer for any of the two cases

@KacerCZ huh? increment_style is about post/pre increment, not about += operator at all!

exactly as @SpacePossum said

And what about:

// from
$i = $i + 42;
// to
$i += 42;

Or maybe it's the role of another fixer?

@Soullivaneuh
As discussed here https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3235#issuecomment-349463668 and here https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3235#issuecomment-361674308, I think the best course of action is two separate fixers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bilge picture Bilge  路  3Comments

ndench picture ndench  路  3Comments

amitbisht511 picture amitbisht511  路  3Comments

carusogabriel picture carusogabriel  路  3Comments

grachevko picture grachevko  路  3Comments