@@ -211,7 +211,6 @@ private function areConstructorAndParentParameterTypesMatching(
211211 ClassMethod $ classMethod ,
212212 ExtendedMethodReflection $ extendedMethodReflection
213213 ): bool {
214- $ methodName = $ this ->getName ($ classMethod );
215214 foreach ($ classMethod ->getParams () as $ position => $ param ) {
216215 $ parameterType = $ param ->type ;
217216
@@ -240,27 +239,38 @@ private function areConstructorAndParentParameterTypesMatching(
240239 continue ;
241240 }
242241
243- // native reflection is needed to get exact default value
244- if ($ extendedMethodReflection ->getDeclaringClass ()->getNativeReflection ()->hasMethod ($ methodName )) {
245- $ parentMethod = $ extendedMethodReflection ->getDeclaringClass ()
246- ->getNativeReflection ()
247- ->getMethod ($ methodName );
248- $ nativeParentParameterReflection = $ parentMethod ->getParameters ()[$ index ] ?? null ;
242+ if ($ this ->isDifferentDefaultValue ($ param ->default , $ extendedMethodReflection , $ index )) {
243+ return false ;
244+ }
245+ }
246+ }
249247
250- if (! $ nativeParentParameterReflection instanceof ReflectionParameter) {
251- continue ;
252- }
248+ return true ;
249+ }
253250
254- $ parentDefault = $ nativeParentParameterReflection ->getDefaultValue ();
255- $ currentDefault = $ this ->valueResolver ->getValue ($ param ->default );
251+ private function isDifferentDefaultValue (
252+ Expr $ defaultExpr ,
253+ ExtendedMethodReflection $ extendedMethodReflection ,
254+ int $ index
255+ ): bool {
256+ $ methodName = $ extendedMethodReflection ->getName ();
257+ // native reflection is needed to get exact default value
258+ if ($ extendedMethodReflection ->getDeclaringClass ()->getNativeReflection ()->hasMethod ($ methodName )) {
259+ $ parentMethod = $ extendedMethodReflection ->getDeclaringClass ()
260+ ->getNativeReflection ()
261+ ->getMethod ($ methodName );
262+ $ nativeParentParameterReflection = $ parentMethod ->getParameters ()[$ index ] ?? null ;
263+
264+ if (! $ nativeParentParameterReflection instanceof ReflectionParameter) {
265+ return false ;
266+ }
256267
257- if ($ parentDefault !== $ currentDefault ) {
258- return false ;
259- }
260- }
268+ $ parentDefault = $ nativeParentParameterReflection ->getDefaultValue ();
269+ if (! $ this ->valueResolver ->isValue ($ defaultExpr , $ parentDefault )) {
270+ return true ;
261271 }
262272 }
263273
264- return true ;
274+ return false ;
265275 }
266276}
0 commit comments