@@ -77,7 +77,12 @@ private function isControllerPlugin(\ReflectionClass $class): bool
77
77
try {
78
78
foreach ($ class ->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
79
79
if (preg_match ('/^(after|around|before).+/i ' , $ method ->getName ())) {
80
- $ argument = $ method ->getParameters ()[0 ]->getClass ();
80
+ try {
81
+ $ argument = $ method ->getParameters ()[0 ]->getClass ();
82
+ } catch (\ReflectionException $ exception ) {
83
+ //Non-existing class (autogenerated perhaps)
84
+ continue ;
85
+ }
81
86
$ isAction = $ argument ->isSubclassOf (\Magento \Framework \App \ActionInterface::class)
82
87
|| $ argument ->getName () === \Magento \Framework \App \ActionInterface::class;
83
88
if ($ isAction ) {
@@ -101,7 +106,12 @@ private function isBlockPlugin(\ReflectionClass $class): bool
101
106
try {
102
107
foreach ($ class ->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
103
108
if (preg_match ('/^(after|around|before).+/i ' , $ method ->getName ())) {
104
- $ argument = $ method ->getParameters ()[0 ]->getClass ();
109
+ try {
110
+ $ argument = $ method ->getParameters ()[0 ]->getClass ();
111
+ } catch (\ReflectionException $ exception ) {
112
+ //Non-existing class (autogenerated perhaps)
113
+ continue ;
114
+ }
105
115
$ isBlock = $ argument ->isSubclassOf (\Magento \Framework \View \Element \BlockInterface::class)
106
116
|| $ argument ->getName () === \Magento \Framework \View \Element \BlockInterface::class;
107
117
if ($ isBlock ) {
@@ -125,14 +135,19 @@ private function doesUseRestrictedClasses(\ReflectionClass $class): bool
125
135
$ constructor = $ class ->getConstructor ();
126
136
if ($ constructor ) {
127
137
foreach ($ constructor ->getParameters () as $ argument ) {
128
- if ($ class = $ argument ->getClass ()) {
129
- if ($ class ->isSubclassOf (\Magento \Framework \Session \SessionManagerInterface::class)
130
- || $ class ->getName () === \Magento \Framework \Session \SessionManagerInterface::class
131
- || $ class ->isSubclassOf (\Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class)
132
- || $ class ->getName () === \Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class
133
- ) {
134
- return true ;
138
+ try {
139
+ if ($ class = $ argument ->getClass ()) {
140
+ if ($ class ->isSubclassOf (\Magento \Framework \Session \SessionManagerInterface::class)
141
+ || $ class ->getName () === \Magento \Framework \Session \SessionManagerInterface::class
142
+ || $ class ->isSubclassOf (\Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class)
143
+ || $ class ->getName () === \Magento \Framework \Stdlib \Cookie \CookieReaderInterface::class
144
+ ) {
145
+ return true ;
146
+ }
135
147
}
148
+ } catch (\ReflectionException $ exception ) {
149
+ //Failed to load the argument's class information
150
+ continue ;
136
151
}
137
152
}
138
153
}
0 commit comments