$ php -v):PHP 7.1.18 (cli) (built: May 25 2018 19:18:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.18, Copyright (c) 1999-2018, by Zend Technologies
$ php-cs-fixer -V):PHP CS Fixer 2.12.1 Long Journey by Fabien Potencier and Dariusz Ruminski
vendor/bin/php-cs-fixer fix --rules=no_unset_on_property filename.php
unset($this->profile->getSettings()[Settings::RANDOM_SETTING]);
with unexpected changes applied when running PHP CS Fixer:
Linting error after fixing
with the changes you expected instead:
None, it shouldn't have changed it.
The getSettings() call returns a magic subclass of ArrayObject, however the fixer thinks it's a property. I know it's ugly syntax but it's used all over the place because $this->profile->settings was changed to protected, and all occurrences were replaced with the getter (because lazy loading).
@SpacePossum , can you take a look ?
I might but let me ping the author of the fixer as well @BackEndTea ;)
I'll take a look either later today or tomorrow
I created a test case for
unset($this->profile->getSettings()[Settings::RANDOM_SETTING]);
But it does not get changed by the fixer. Is there any other place in the file that uses an unset which might cause thsi bug?
Before reporting the issue I tried disabling this fixer, and there is no problem. Re-enabling the fixer and commenting out this line, and again no problem.
It might conflict with other fixers or its surrounding code, which I will be able to test again tomorrow.
So yeah... different line now, don't know if inconsistent or just my bad 馃槰
Validated with -vvv --diff --using-cache=no in addition to the original command
It changes
unset($this->property[array_search(\Types::TYPE_RANDOM, $this->property)]);
To
unset($this->property[array_search(\Types::TYPE_RANDOM); $this->property)] = null;
Ah i think i know what causes that,and how to fix it
Sorry for the delay on this, but i haven't had much time to work on it, and i'm kinda unsure on how to fix it atm.
So if someone wants to take a look, feel free to do so.
Most helpful comment
I'll take a look either later today or tomorrow