Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to the "magento-toolbox" extension will be documented in thi
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]
- Fixed: Generated plugin class arguments contain an incorrect namespace

## [1.3.0] - 2025-03-17

- Added: Jump to module command
- Changed: All dropdown inputs now support searching
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Magento 2 code generation, inspection and utility tools",
"publisher": "magebit",
"icon": "resources/logo.jpg",
"version": "1.2.0",
"version": "1.3.0",
"engines": {
"vscode": "^1.93.1"
},
Expand Down
19 changes: 16 additions & 3 deletions src/generator/plugin/PluginClassGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,22 @@ export default class PluginClassGenerator extends FileGenerator {
return type;
}

const namespace = this.subjectClass.namespace;
const typeName = type.startsWith('\\') ? type.slice(1) : type;
if (type.startsWith('\\')) {
return type;
}

if (type === this.subjectClass.name) {
return `${this.subjectClass.namespace}\\${type}`;
}

const useItems = this.subjectClass.parent.useItems;

for (const useItem of useItems) {
if (useItem.name === type) {
return useItem.fullName;
}
}

return `${namespace}\\${typeName}`;
return type;
}
}
11 changes: 4 additions & 7 deletions src/parser/php/PhpUseItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ export class PhpUseItem extends PhpNode<NodeKind.UseItem> {
}

public get fullName() {
if (this.ast.alias) {
return this.ast.alias.name;
}
return this.ast.name;
}

public get name() {
if (this.ast.alias) {
return this.ast.alias.name;
}

const parts = this.ast.name.split('\\');
return last(parts)!;
}

public get alias() {
return this.ast.alias?.name;
}
}