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

False positive: null-coalesce suggested: "$test::class ?? null" #1933

Open
linaori opened this issue Mar 7, 2024 · 0 comments
Open

False positive: null-coalesce suggested: "$test::class ?? null" #1933

linaori opened this issue Mar 7, 2024 · 0 comments

Comments

@linaori
Copy link

linaori commented Mar 7, 2024

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

Current behaviour

$test = null;
echo $test ? $test::class : null;

is suggested to be changed to:

$test = null;
echo $test::class ?? null;

This results in an error up to php 8.3 (though 8.3 has a different error): https://3v4l.org/rHFdh

  • 8.3: Fatal error: Uncaught TypeError: Cannot use "::class" on null
  • lower: Fatal error: Uncaught TypeError: Cannot use "::class" on value of type null

image

Expected behaviour

I think the correct behavior is to not suggest null-coalesce

Environment details

IntelliJ IDEA 2023.3.4 (Ultimate Edition)
Build #IU-233.14475.28, built on February 13, 2024
Runtime version: 17.0.10+1-b1087.17 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-97-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 4000M
Cores: 12
Registry:
ide.balloon.shadow.size=0
editor.focus.mode.color.light=474747
editor.focus.mode.color.dark=474747
ide.new.editor.tabs.vertical.borders=true
ide.experimental.ui=true
ide.editor.tab.selection.animation=true
Non-Bundled Plugins:
com.intellij.apacheConfig (233.14475.38)
name.kropp.intellij.makefile (233.13135.65)
com.jetbrains.php (233.14475.35)
org.jetbrains.plugins.phpstorm-remote-interpreter (233.11799.172)
com.kalessil.phpStorm.phpInspectionsEA (5.0.0.0)
net.king2500.plugins.PhpAdvancedAutoComplete (1.1.0)
de.espend.idea.php.annotation (9.4.0)
com.intellij.php.psalm (233.14475.35)
com.intellij.php.tools.quality.phpstan (233.14475.35)
org.jetbrains.plugins.phpstorm-docker (233.13135.67)
com.jetbrains.twig (233.14475.38)
ru.adelf.idea.dotenv (2024.1)
mobi.hsz.idea.gitignore (4.5.2)
fr.adrienbrault.idea.symfony2plugin (2023.1.265)
com.chrisrm.idea.MaterialThemeUI (8.13.2)
de.espend.idea.php.phpunit (7.1)
Kotlin: 233.14475.28-IJ
Current Desktop: ubuntu:GNOME

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