Double cast of NullToStrictStringFuncCallArgRector
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/c96ef6c0-7fad-444f-9fb8-5941280101fd
<?php
explode(',',
(string) $getInstance->get()
? $_SERVER['REMOTE_ADDR']
: $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '',
);
Responsible rules
-
NullToStrictStringFuncCallArgRector
Expected Behavior
No change. Double cast shouldn't be added.
I'm looking into it.
Btw, the (string) only affects the (string) $getInstance->get(), not the rest of ternary. So IMO can be removed as rest of ternary are always strings.
Btw, the (string) only affects the (string) $getInstance->get(), not the rest of ternary. So IMO can be removed as rest of ternary are always strings.
I'm aware of it. As addition whole ternary statement was surrounded by parenthesis that were removed. I have another example that would be good to add as a test case: https://getrector.com/demo/4d9920dd-7a76-404d-af4b-9b41a0952c0a