Skip to content
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

Merge with parent if removes comments #1937

Open
Simbiat opened this issue Apr 7, 2024 · 1 comment
Open

Merge with parent if removes comments #1937

Simbiat opened this issue Apr 7, 2024 · 1 comment

Comments

@Simbiat
Copy link

Simbiat commented Apr 7, 2024

Subject Details
Plugin Php Inspections (EA Extended)
Language level PHP 8.3

Current behaviour

Have and if construct like

if ($domething) {
            #Do something
} else {
            #Do something else
            if ($anything) {
                        #Do it all
            }
}

if ($anything) will be marked with suggestion [EA] If construct can be merged with parent one. (which is a valid one). If you chose to apply the automated fix, the line #Do something else will be removed` in result:

if ($domething) {
            #Do something
} elseif ($anything) {
            #Do it all
}

Expected behaviour

Result should be something like

if ($domething) {
            #Do something
#Do something else
} elseif ($anything) {
            #Do it all
}

or

```php
if ($domething) {
            #Do something
} elseif ($anything) {
#Do something else
            #Do it all
}

At the least comment should not be lost

Environment details

PhpStorm 2024.1
Build #PS-241.14494.237, built on March 27, 2024
Licensed to simbiat.ru / Dmitry Kustov
Subscription is active until May 11, 2024.
For non-commercial open source development only.
Runtime version: 17.0.10+8-b1207.12 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 5120M
Cores: 16
Registry:
  debugger.new.tool.window.layout=true
  run.processes.with.pty=TRUE
  ide.experimental.ui=true
Non-Bundled Plugins:
  com.jetbrains.space (241.14494.150)
  com.intellij.ml.llm (241.14494.240)
  com.kalessil.phpStorm.phpInspectionsEA (5.0.0.0)
@Simbiat
Copy link
Author

Simbiat commented Apr 7, 2024

Important to note, that this seems to be the case with merging to else.

if ($something) {
    #Comment
    if ($anything) {
        #Do something
    }
}

Gets transformed into

#Comment
if ($something && $anything) {
    #Do something
}

As expected

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

No branches or pull requests

1 participant