@@ -108,8 +108,7 @@ private function isControllerPlugin(\ReflectionClass $class): bool
108108 foreach ($ class ->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
109109 if (preg_match ('/^(after|around|before).+/i ' , $ method ->getName ())) {
110110 try {
111- $ parameter = $ method ->getParameters ()[0 ];
112- $ argument = $ this ->getParameterClass ($ parameter );
111+ $ argument = $ this ->getParameterClass ($ method ->getParameters ()[0 ]);
113112 } catch (\Throwable $ exception ) {
114113 //Non-existing class (autogenerated perhaps) or doesn't have an argument.
115114 continue ;
@@ -138,8 +137,7 @@ private function isBlockPlugin(\ReflectionClass $class): bool
138137 foreach ($ class ->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
139138 if (preg_match ('/^(after|around|before).+/i ' , $ method ->getName ())) {
140139 try {
141- $ parameter = $ method ->getParameters ()[0 ];
142- $ argument = $ this ->getParameterClass ($ parameter );
140+ $ argument = $ this ->getParameterClass ($ method ->getParameters ()[0 ]);
143141 } catch (\Throwable $ exception ) {
144142 //Non-existing class (autogenerated perhaps) or doesn't have an argument.
145143 continue ;
@@ -169,14 +167,16 @@ private function doesUseRestrictedClasses(\ReflectionClass $class): bool
169167 if ($ constructor ) {
170168 foreach ($ constructor ->getParameters () as $ argument ) {
171169 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 ;
180180 }
181181 } catch (\ReflectionException $ exception ) {
182182 //Failed to load the argument's class information
0 commit comments