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 importing scalar types when generating a plugin class #2508

Open
novikor opened this issue Mar 11, 2025 · 1 comment
Open

False importing scalar types when generating a plugin class #2508

novikor opened this issue Mar 11, 2025 · 1 comment
Labels

Comments

@novikor
Copy link

novikor commented Mar 11, 2025

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)
@novikor novikor added the bug label Mar 11, 2025
Copy link

m2-assistant bot commented Mar 11, 2025

Hi @novikor. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant