Skip to content

False importing scalar types when generating a plugin class #2508

Open
@novikor

Description

@novikor

Describe the bug

When generating a before plugin for method that accepts scalar parameters, sometimes the generated plugin class contains imports for scalars like int, treating them as classes rather than built-in types.

To Reproduce (*)

Steps to reproduce the behavior:

  1. Have an original class to create a plugin for containing a method with the following signature:
    public function isActive(null|int|string $scope = null): bool
    {
        return true;
    }
  1. right click on the method and open plugin generation dialog, create a before plugin type.

Image
3. Navigate the newly created class
4. See the imports broken
Image
By a following code line:

use intuse Vendor\Module\Model\Config;class SomePlugin

Expected behavior (*)

use int is missing, PHP imports are valid

Screenshots

Attached above

Please complete the following information: (*)

PhpStorm 2024.3.2

Build #PS-243.23654.115, built on January 15, 2025
Subscription is active until April 3, 2025.
Runtime version: 21.0.5+8-b631.30 x86_64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.3
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 16
Metal Rendering is ON
Registry:
  ide.balloon.shadow.size=0
  debugger.new.tool.window.layout=true
  run.processes.with.pty=TRUE
  ide.intellij.laf.enable.animation=true
  ide.experimental.ui=true
Non-Bundled Plugins:
  Symlink Excluder (1.1)
  some.awesome (1.16)
  com.github.b3er.idea.plugins.arc.browser (0.32)
  org.toml.lang (243.23654.183)
  com.intellij.properties (243.22562.9)
  String Manipulation (9.15.0)
  org.albertzeyer.IdeaResolveSymlinks (1.2)
  com.atlassian.bitbucket.references (2023.1.304)
  com.laravel_idea.tailwind (1.4.2)
  com.intellij.lang.jsgraphql (243.22562.13)
  com.github.inxilpro.intellijalpine (v0.4.2)
  com.magento.idea.magento2plugin (2025.1.0)
  ru.adelf.idea.dotenv (2024.3)
  NEON support (0.5.4)
  com.atwix.magento (2025.1.0)
  de.espend.idea.php.annotation (11.1.1)
  com.github.copilot (1.5.38-243)
  zielu.gittoolbox (600.0.19+243)
  mobi.hsz.idea.gitignore (4.5.6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions