-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
NoUnsetOnPropertyFixer breaks on function call as key in array class-property #3843
Comments
@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 😨 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. |
The PHP version you are using (
$ php -v
):PHP CS Fixer version you are using (
$ php-cs-fixer -V
):PHP CS Fixer 2.12.1 Long Journey by Fabien Potencier and Dariusz Ruminski
The command you use to run PHP CS Fixer:
vendor/bin/php-cs-fixer fix --rules=no_unset_on_property filename.php
If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):
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 ofArrayObject
, 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).The text was updated successfully, but these errors were encountered: