@@ -101,7 +101,7 @@ private static function validateMethod(
101101 {
102102 $ method = self ::validateMethodExistence ($ class , $ methodName );
103103
104- self ::validateMethodSignature ($ method , $ class , $ property );
104+ self ::validateMethodSignature ($ method , $ property );
105105
106106 return $ method ;
107107 }
@@ -132,34 +132,29 @@ private static function validateMethodExistence(ReflectionClass $class, string $
132132 return $ class ->getMethod ($ methodName );
133133 }
134134
135- /**
136- * @param ReflectionClass<MappedObject> $class
137- */
138135 private static function validateMethodSignature (
139136 ReflectionMethod $ method ,
140- ReflectionClass $ class ,
141137 ?ReflectionProperty $ property
142138 ): void
143139 {
144- [$ paramData , $ paramContext ] = self ::validateParametersCount ($ class , $ method );
140+ [$ paramData , $ paramContext ] = self ::validateParametersCount ($ method );
145141
146142 $ property === null
147- ? self ::validateClassMethodSignature ($ class , $ method , $ paramData , $ paramContext )
148- : self ::validatePropertyMethodSignature ($ class , $ method , $ paramData , $ paramContext );
143+ ? self ::validateClassMethodSignature ($ method , $ paramData , $ paramContext )
144+ : self ::validatePropertyMethodSignature ($ method , $ paramData , $ paramContext );
149145 }
150146
151147 /**
152- * @param ReflectionClass<MappedObject> $class
153148 * @return array{ReflectionParameter|null, ReflectionParameter|null}
154149 */
155- private static function validateParametersCount (ReflectionClass $ class , ReflectionMethod $ method ): array
150+ private static function validateParametersCount (ReflectionMethod $ method ): array
156151 {
157152 $ requiredCount = $ method ->getNumberOfRequiredParameters ();
158153 if ($ requiredCount > 2 ) {
159154 throw InvalidArgument::create ()
160155 ->withMessage (sprintf (
161156 'Callback method %s::%s should have only 2 required parameters, %s required parameters given ' ,
162- $ class ->getName (),
157+ $ method -> getDeclaringClass () ->getName (),
163158 $ method ->getName (),
164159 $ requiredCount ,
165160 ));
@@ -176,49 +171,34 @@ private static function validateParametersCount(ReflectionClass $class, Reflecti
176171 /**
177172 * beforeClass(<nothing>|mixed $data, MappedObjectContext $context): <anything>
178173 * afterClass(array $data, MappedObjectContext $context): array|void|never
179- *
180- * @param ReflectionClass<MappedObject> $class
181174 */
182175 private static function validateClassMethodSignature (
183- ReflectionClass $ class ,
184176 ReflectionMethod $ method ,
185177 ?ReflectionParameter $ paramData ,
186178 ?ReflectionParameter $ paramContext
187179 ): void
188180 {
189181 if ($ paramData !== null ) {
190- static ::validateClassMethodDataParam ($ class , $ method , $ paramData );
182+ static ::validateClassMethodDataParam ($ method , $ paramData );
191183 }
192184
193185 if ($ paramContext !== null ) {
194- self ::validateClassMethodContextParam ($ class , $ method , $ paramContext );
186+ self ::validateClassMethodContextParam ($ method , $ paramContext );
195187 }
196188
197- static ::validateClassMethodReturn ($ class , $ method );
189+ static ::validateClassMethodReturn ($ method );
198190 }
199191
200- /**
201- * @param ReflectionClass<MappedObject> $class
202- */
203192 abstract protected static function validateClassMethodDataParam (
204- ReflectionClass $ class ,
205193 ReflectionMethod $ method ,
206194 ReflectionParameter $ paramData
207195 ): void ;
208196
209- /**
210- * @param ReflectionClass<MappedObject> $class
211- */
212197 abstract protected static function validateClassMethodReturn (
213- ReflectionClass $ class ,
214198 ReflectionMethod $ method
215199 ): void ;
216200
217- /**
218- * @param ReflectionClass<MappedObject> $class
219- */
220201 private static function validateClassMethodContextParam (
221- ReflectionClass $ class ,
222202 ReflectionMethod $ method ,
223203 ReflectionParameter $ paramContext
224204 ): void
@@ -230,7 +210,7 @@ private static function validateClassMethodContextParam(
230210 throw InvalidArgument::create ()
231211 ->withMessage (sprintf (
232212 'Second parameter of class callback method %s::%s should have "%s" type instead of %s ' ,
233- $ class ->getName (),
213+ $ method -> getDeclaringClass () ->getName (),
234214 $ method ->getName (),
235215 ObjectContext::class,
236216 $ type ?? 'none ' ,
@@ -241,39 +221,28 @@ private static function validateClassMethodContextParam(
241221 /**
242222 * beforeField(<nothing>|mixed $data, FieldContext $context): <anything>
243223 * afterField(<anything> $data, FieldContext $context): <anything>
244- *
245- * @param ReflectionClass<MappedObject> $class
246224 */
247225 private static function validatePropertyMethodSignature (
248- ReflectionClass $ class ,
249226 ReflectionMethod $ method ,
250227 ?ReflectionParameter $ paramData ,
251228 ?ReflectionParameter $ paramContext
252229 ): void
253230 {
254231 if ($ paramData !== null ) {
255- static ::validatePropertyMethodDataParam ($ class , $ method , $ paramData );
232+ static ::validatePropertyMethodDataParam ($ method , $ paramData );
256233 }
257234
258235 if ($ paramContext !== null ) {
259- self ::validatePropertyMethodContextParam ($ class , $ method , $ paramContext );
236+ self ::validatePropertyMethodContextParam ($ method , $ paramContext );
260237 }
261238 }
262239
263- /**
264- * @param ReflectionClass<MappedObject> $class
265- */
266240 abstract protected static function validatePropertyMethodDataParam (
267- ReflectionClass $ class ,
268241 ReflectionMethod $ method ,
269242 ReflectionParameter $ paramData
270243 ): void ;
271244
272- /**
273- * @param ReflectionClass<MappedObject> $class
274- */
275245 private static function validatePropertyMethodContextParam (
276- ReflectionClass $ class ,
277246 ReflectionMethod $ method ,
278247 ReflectionParameter $ paramContext
279248 ): void
@@ -287,7 +256,7 @@ private static function validatePropertyMethodContextParam(
287256 throw InvalidArgument::create ()
288257 ->withMessage (sprintf (
289258 'Second parameter of field callback method %s::%s should have "%s" type instead of %s ' ,
290- $ class ->getName (),
259+ $ method -> getDeclaringClass () ->getName (),
291260 $ method ->getName (),
292261 FieldContext::class,
293262 $ type ?? 'none ' ,
0 commit comments