magento / magento/magento2-phpstorm-plugin

DI inspection complains about a class suffixes with Factory

Open
#1,607 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
463
Forks
98
Avg merge
1h 6m
Merged PRs (30d)
3

Description

**Describe the bug**

If you create a class with the suffix **Factory** and then try to add it as an argument to another class the validation complains about:
`The class "..\Model\ItemFactory" does not exist ` but it exists.
Example:
```


...\Model\ItemFactory

```
![image](https://github.com/magento/magento2-phpstorm-plugin/assets/8819844/bd30a824-761e-4634-9a04-a41763ed8c3f)

**To Reproduce**
1. Create a new module
2. Create a model with the suffix **Factory**
3. Created another model which can accept the previously created model as an argument
4. Add configuration to `etc/di.xml`
```


...\Model\ItemFactory

```
5. The complaint appears

**Expected behavior**
No complaint.

**Information:**

PhpStorm 2023.1.2
Build #PS-231.9011.38, built on May 17, 2023
Runtime version: 17.0.6+10-b829.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.0-72-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 5120M
Cores: 12
Registry:
editor.focus.mode.color.light=5b595c
ide.editor.tab.selection.animation=true
debugger.watches.in.variables=false
debugger.new.tool.window.layout=true
editor.caret.width=1
run.processes.with.pty=true
vcs.new.widget=true
ide.new.editor.tabs.vertical.borders=true
ide.experimental.ui=true
ide.balloon.shadow.size=0
editor.focus.mode.color.dark=5b595c

Non-Bundled Plugins:
de.femtopedia.diffplugin (2.1.10)
intellij-awk (0.4.0)
org.toml.lang (231.8109.91)
com.nasller.CodeGlancePro (1.6.3)
com.ultrahob.zerolength.plugin (0.95)
org.elasticsearch4idea (2023.1.6-231)
com.intellij.properties (231.8770.3)
String Manipulation (9.7.1)
ir.msdehghan.plugins.ansible (0.92)
indent-rainbow.indent-rainbow (2.1.0)
com.intellij.grazie.pro (0.3.224)
com.kalessil.phpStorm.phpInspectionsEA (5.0.0.0)
ru.adelf.idea.dotenv (2023.1)
de.espend.idea.php.annotation (9.3.1)
com.virtuslab.git-machete (3.8.0)
izhangzhihao.rainbow.brackets (2023.2.8)
pro.bashsupport (3.2.2.231)
lv.midiana.misc.phpstorm-plugins.deep-keys (2022.08.03.001)
fr.adrienbrault.idea.symfony2plugin (2022.1.250)
com.chrisrm.idea.MaterialThemeUI (8.6.4)
com.intellij.lang.jsgraphql (4.0.1)
com.magento.idea.magento2plugin (5.1.1)
org.sonarlint.idea (8.2.0.68615)
com.mallowigi (90.0.0)
zielu.gittoolbox (500.0.8+213)
mobi.hsz.idea.gitignore (4.5.0)
com.github.blarc.gitlab-template-lint-plugin (1.13.0)

Current Desktop: ubuntu:GNOME

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the inspection using the Magento module, ItemFactory, DataProvider, and the etc/di.xml configuration shown in the report. Trace the DI validation that handles classes ending in Factory and verify the fix by confirming the valid class no longer produces a complaint.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.