17
17
use PHPStan \Reflection \ParametersAcceptor ;
18
18
use PHPStan \Reflection \ParametersAcceptorSelector ;
19
19
use PHPStan \Reflection \Php \DummyParameter ;
20
- use PHPStan \Reflection \ReflectionProvider ;
21
20
use PHPStan \ShouldNotHappenException ;
22
21
use PHPStan \TrinaryLogic ;
23
- use PHPStan \Type \Generic \GenericObjectType ;
24
22
use PHPStan \Type \ObjectType ;
25
23
use PHPStan \Type \StaticType ;
26
24
use PHPStan \Type \ThisType ;
@@ -39,7 +37,6 @@ final class ModelForwardsCallsExtension implements MethodsClassReflectionExtensi
39
37
40
38
public function __construct (
41
39
private BuilderHelper $ builderHelper ,
42
- private ReflectionProvider $ reflectionProvider ,
43
40
private EloquentBuilderForwardsCallsExtension $ eloquentBuilderForwardsCallsExtension ,
44
41
) {
45
42
}
@@ -84,11 +81,12 @@ private function findMethod(ClassReflection $classReflection, string $methodName
84
81
return $ this ->counterMethodReflection ($ classReflection , $ methodName );
85
82
}
86
83
87
- $ builderName = $ this ->builderHelper ->determineBuilderName ($ classReflection ->getName ());
88
- $ builderReflection = $ this ->reflectionProvider ->getClass ($ builderName )->withTypes ([new ObjectType ($ classReflection ->getName ())]);
89
- $ builderType = $ builderReflection ->isGeneric ()
90
- ? new GenericObjectType ($ builderName , [new ObjectType ($ classReflection ->getName ())])
91
- : new ObjectType ($ builderName );
84
+ $ builderType = $ this ->builderHelper ->getBuilderTypeForModels ($ classReflection ->getName ());
85
+ $ builderReflection = $ builderType ->getClassReflection ();
86
+
87
+ if ($ builderReflection === null ) {
88
+ return null ;
89
+ }
92
90
93
91
if ($ builderReflection ->hasNativeMethod ($ methodName )) {
94
92
$ reflection = $ builderReflection ->getNativeMethod ($ methodName );
0 commit comments