@@ -108,8 +108,7 @@ private function isControllerPlugin(\ReflectionClass $class): bool
108
108
foreach ($ class ->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
109
109
if (preg_match ('/^(after|around|before).+/i ' , $ method ->getName ())) {
110
110
try {
111
- $ parameter = $ method ->getParameters ()[0 ];
112
- $ argument = $ this ->getParameterClass ($ parameter );
111
+ $ argument = $ this ->getParameterClass ($ method ->getParameters ()[0 ]);
113
112
} catch (\Throwable $ exception ) {
114
113
//Non-existing class (autogenerated perhaps) or doesn't have an argument.
115
114
continue ;
@@ -138,8 +137,7 @@ private function isBlockPlugin(\ReflectionClass $class): bool
138
137
foreach ($ class ->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
139
138
if (preg_match ('/^(after|around|before).+/i ' , $ method ->getName ())) {
140
139
try {
141
- $ parameter = $ method ->getParameters ()[0 ];
142
- $ argument = $ this ->getParameterClass ($ parameter );
140
+ $ argument = $ this ->getParameterClass ($ method ->getParameters ()[0 ]);
143
141
} catch (\Throwable $ exception ) {
144
142
//Non-existing class (autogenerated perhaps) or doesn't have an argument.
145
143
continue ;
@@ -169,14 +167,16 @@ private function doesUseRestrictedClasses(\ReflectionClass $class): bool
169
167
if ($ constructor ) {
170
168
foreach ($ constructor ->getParameters () as $ argument ) {
171
169
try {
172
- if ($ class = $ this ->getParameterClass ($ argument )) {
173
- if ($ class ->isSubclassOf (\Magento \Framework \Session \SessionManagerInterface::class)
174
- || $ class ->getName () === \Magento \Framework \Session \SessionManagerInterface::class
175
- || $ class ->isSubclassOf (\Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class)
176
- || $ class ->getName () === \Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class
177
- ) {
178
- return true ;
179
- }
170
+ $ class = $ this ->getParameterClass ($ argument );
171
+ if ($ class === null ) {
172
+ continue ;
173
+ }
174
+ if ($ class ->isSubclassOf (\Magento \Framework \Session \SessionManagerInterface::class)
175
+ || $ class ->getName () === \Magento \Framework \Session \SessionManagerInterface::class
176
+ || $ class ->isSubclassOf (\Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class)
177
+ || $ class ->getName () === \Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class
178
+ ) {
179
+ return true ;
180
180
}
181
181
} catch (\ReflectionException $ exception ) {
182
182
//Failed to load the argument's class information
0 commit comments