File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/bitExpert/PHPStan/Magento/Autoload Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ protected function getFileContents(string $class): string
76
76
$ originalClassname = implode ('\\' , $ namespace );
77
77
78
78
if (!class_exists ($ originalClassname )) {
79
- throw new \RuntimeException ("Class $ {class } for Interceptor does not exist " );
79
+ throw new \RuntimeException ("Class $ {originalClassname } for Interceptor does not exist " );
80
80
}
81
81
$ reflectionClass = new ReflectionClass ($ originalClassname );
82
82
@@ -90,12 +90,20 @@ protected function getFileContents(string $class): string
90
90
91
91
$ generator = new ClassGenerator ();
92
92
$ generator ->setName ($ class )
93
- ->setExtendedClass ($ originalClassname )
94
- ->addProperties ([])
95
93
->addMethods ($ methods );
96
94
95
+ $ interfaces = [];
96
+ if ($ reflectionClass ->isInterface ()) {
97
+ $ interfaces [] = $ originalClassname ;
98
+ } else {
99
+ $ generator ->setExtendedClass ($ originalClassname );
100
+ }
101
+ $ generator ->addTrait ('\\' . \Magento \Framework \Interception \Interceptor::class);
102
+ $ interfaces [] = '\\' . \Magento \Framework \Interception \InterceptorInterface::class;
103
+ $ generator ->setImplementedInterfaces ($ interfaces );
104
+
97
105
$ code = $ generator ->generate ();
98
- return $ this ->_fixCodeStyle ($ code );
106
+ return ' <?php ' . PHP_EOL . PHP_EOL . $ this ->_fixCodeStyle ($ code );
99
107
}
100
108
101
109
protected function _fixCodeStyle (string $ sourceCode ): string
You can’t perform that action at this time.
0 commit comments