@@ -80,45 +80,46 @@ public function validate($pluginClass, $interceptedType)
80
80
);
81
81
}
82
82
83
- switch ($ methodType ) {
84
- case self ::METHOD_AFTER :
85
- if (count ($ pluginMethodParameters ) > 1 ) {
86
- // remove result
87
- array_shift ($ pluginMethodParameters );
88
- $ matchedParameters = array_intersect_key ($ originMethodParameters , $ pluginMethodParameters );
89
- $ this ->validateMethodsParameters (
90
- $ pluginMethodParameters ,
91
- $ matchedParameters ,
92
- $ pluginClass ,
93
- $ pluginMethod ->getName ()
94
- );
95
- }
96
- break ;
97
- case self ::METHOD_BEFORE :
98
- $ this ->validateMethodsParameters (
99
- $ pluginMethodParameters ,
100
- $ originMethodParameters ,
101
- $ pluginClass ,
102
- $ pluginMethod ->getName ()
103
- );
104
- break ;
105
- case self ::METHOD_AROUND :
106
- $ proceed = array_shift ($ pluginMethodParameters );
107
- if (!$ this ->_argumentsReader ->isCompatibleType ($ proceed ['type ' ], '\\Closure ' )) {
108
- throw new ValidatorException (
109
- new Phrase (
110
- 'Invalid [%1] $%2 type in %3::%4. It must be compatible with \\Closure ' ,
111
- [$ proceed ['type ' ], $ proceed ['name ' ], $ pluginClass , $ pluginMethod ->getName ()]
112
- )
113
- );
114
- }
115
- $ this ->validateMethodsParameters (
116
- $ pluginMethodParameters ,
117
- $ originMethodParameters ,
118
- $ pluginClass ,
119
- $ pluginMethod ->getName ()
83
+ if (self ::METHOD_AFTER === $ methodType && count ($ pluginMethodParameters ) > 1 ) {
84
+ // remove result
85
+ array_shift ($ pluginMethodParameters );
86
+ $ matchedParameters = array_intersect_key ($ originMethodParameters , $ pluginMethodParameters );
87
+ $ this ->validateMethodsParameters (
88
+ $ pluginMethodParameters ,
89
+ $ matchedParameters ,
90
+ $ pluginClass ,
91
+ $ pluginMethod ->getName ()
92
+ );
93
+ continue ;
94
+ }
95
+
96
+ if (self ::METHOD_BEFORE === $ methodType ) {
97
+ $ this ->validateMethodsParameters (
98
+ $ pluginMethodParameters ,
99
+ $ originMethodParameters ,
100
+ $ pluginClass ,
101
+ $ pluginMethod ->getName ()
102
+ );
103
+ continue ;
104
+ }
105
+
106
+ if (self ::METHOD_AROUND === $ methodType ) {
107
+ $ proceed = array_shift ($ pluginMethodParameters );
108
+ if (!$ this ->_argumentsReader ->isCompatibleType ($ proceed ['type ' ], '\\Closure ' )) {
109
+ throw new ValidatorException (
110
+ new Phrase (
111
+ 'Invalid [%1] $%2 type in %3::%4. It must be compatible with \\Closure ' ,
112
+ [$ proceed ['type ' ], $ proceed ['name ' ], $ pluginClass , $ pluginMethod ->getName ()]
113
+ )
120
114
);
121
- break ;
115
+ }
116
+ $ this ->validateMethodsParameters (
117
+ $ pluginMethodParameters ,
118
+ $ originMethodParameters ,
119
+ $ pluginClass ,
120
+ $ pluginMethod ->getName ()
121
+ );
122
+ continue ;
122
123
}
123
124
}
124
125
}
@@ -166,8 +167,7 @@ protected function validateMethodsParameters(array $pluginParameters, array $ori
166
167
protected function getParametersType (\ReflectionParameter $ parameter )
167
168
{
168
169
$ parameterClass = $ parameter ->getClass ();
169
- $ type = $ parameterClass ? '\\' . $ parameterClass ->getName () : ($ parameter ->isArray () ? 'array ' : null );
170
- return $ type ;
170
+ return $ parameterClass ? '\\' . $ parameterClass ->getName () : ($ parameter ->isArray () ? 'array ' : null );
171
171
}
172
172
173
173
/**
@@ -179,17 +179,16 @@ protected function getParametersType(\ReflectionParameter $parameter)
179
179
*/
180
180
protected function getOriginMethodName ($ pluginMethodName )
181
181
{
182
- switch ($ this ->getMethodType ($ pluginMethodName )) {
183
- case self ::METHOD_AFTER :
184
- return lcfirst (substr ($ pluginMethodName , 5 ));
185
-
186
- case self ::METHOD_BEFORE :
187
- case self ::METHOD_AROUND :
188
- return lcfirst (substr ($ pluginMethodName , 6 ));
182
+ $ methodType = $ this ->getMethodType ($ pluginMethodName );
189
183
190
- default :
191
- return null ;
184
+ if ( self :: METHOD_AFTER === $ methodType ) {
185
+ return lcfirst ( substr ( $ pluginMethodName , 5 )) ;
192
186
}
187
+ if (self ::METHOD_BEFORE === $ methodType || self ::METHOD_AROUND === $ methodType ) {
188
+ return lcfirst (substr ($ pluginMethodName , 6 ));
189
+ }
190
+
191
+ return null ;
193
192
}
194
193
195
194
/**
0 commit comments