66
77use PhpParser \Node \Stmt \ClassMethod ;
88use PHPStan \Reflection \ClassReflection ;
9- use Rector \FileSystem \FilePathHelper ;
109use Rector \NodeNameResolver \NodeNameResolver ;
1110use Rector \Reflection \ReflectionResolver ;
1211
1514 public function __construct (
1615 private NodeNameResolver $ nodeNameResolver ,
1716 private ReflectionResolver $ reflectionResolver ,
18- private FilePathHelper $ filePathHelper
1917 ) {
2018 }
2119
@@ -38,11 +36,7 @@ public function isVendorLocked(ClassMethod $classMethod): bool
3836 $ methodName = $ this ->nodeNameResolver ->getName ($ classMethod );
3937
4038 // has interface vendor lock? → better skip it, as PHPStan has access only to just analyzed classes
41- if ($ this ->hasParentInterfaceMethod ($ classReflection , $ methodName )) {
42- return true ;
43- }
44-
45- return $ this ->hasClassMethodLockMatchingFileName ($ classReflection , $ methodName , '/vendor/ ' );
39+ return $ this ->hasParentInterfaceMethod ($ classReflection , $ methodName );
4640 }
4741
4842 /**
@@ -60,37 +54,4 @@ private function hasParentInterfaceMethod(ClassReflection $classReflection, stri
6054
6155 return false ;
6256 }
63-
64- private function hasClassMethodLockMatchingFileName (
65- ClassReflection $ classReflection ,
66- string $ methodName ,
67- string $ filePathPartName
68- ): bool {
69- $ ancestorClassReflections = [...$ classReflection ->getParents (), ...$ classReflection ->getInterfaces ()];
70- foreach ($ ancestorClassReflections as $ ancestorClassReflection ) {
71- // parent type
72- if (! $ ancestorClassReflection ->hasNativeMethod ($ methodName )) {
73- continue ;
74- }
75-
76- // is file in vendor?
77- $ fileName = $ ancestorClassReflection ->getFileName ();
78- // probably internal class
79- if ($ fileName === null ) {
80- continue ;
81- }
82-
83- // not conditions? its a match
84- if ($ filePathPartName === '' ) {
85- return true ;
86- }
87-
88- $ normalizedFileName = $ this ->filePathHelper ->normalizePathAndSchema ($ fileName );
89- if (str_contains ($ normalizedFileName , $ filePathPartName )) {
90- return true ;
91- }
92- }
93-
94- return false ;
95- }
9657}
0 commit comments