File tree Expand file tree Collapse file tree 3 files changed +23
-10
lines changed Expand file tree Collapse file tree 3 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ All notable changes to the "magento-toolbox" extension will be documented in thi
44
55Check [ Keep a Changelog] ( http://keepachangelog.com/ ) for recommendations on how to structure this file.
66
7+ ## [ Unreleased]
8+ - Fixed: Generated plugin class arguments contain an incorrect namespace
9+
710## [ 1.3.0] - 2025-03-17
811
912- Added: Jump to module command
Original file line number Diff line number Diff line change @@ -89,9 +89,22 @@ export default class PluginClassGenerator extends FileGenerator {
8989 return type ;
9090 }
9191
92- const namespace = this . subjectClass . namespace ;
93- const typeName = type . startsWith ( '\\' ) ? type . slice ( 1 ) : type ;
92+ if ( type . startsWith ( '\\' ) ) {
93+ return type ;
94+ }
95+
96+ if ( type === this . subjectClass . name ) {
97+ return `${ this . subjectClass . namespace } \\${ type } ` ;
98+ }
99+
100+ const useItems = this . subjectClass . parent . useItems ;
101+
102+ for ( const useItem of useItems ) {
103+ if ( useItem . name === type ) {
104+ return useItem . fullName ;
105+ }
106+ }
94107
95- return ` ${ namespace } \\ ${ typeName } ` ;
108+ return type ;
96109 }
97110}
Original file line number Diff line number Diff line change @@ -13,18 +13,15 @@ export class PhpUseItem extends PhpNode<NodeKind.UseItem> {
1313 }
1414
1515 public get fullName ( ) {
16- if ( this . ast . alias ) {
17- return this . ast . alias . name ;
18- }
1916 return this . ast . name ;
2017 }
2118
2219 public get name ( ) {
23- if ( this . ast . alias ) {
24- return this . ast . alias . name ;
25- }
26-
2720 const parts = this . ast . name . split ( '\\' ) ;
2821 return last ( parts ) ! ;
2922 }
23+
24+ public get alias ( ) {
25+ return this . ast . alias ?. name ;
26+ }
3027}
You can’t perform that action at this time.
0 commit comments