1010use PhpParser \Node \Identifier ;
1111use PhpParser \Node \Param ;
1212use PhpParser \Node \Stmt \ClassMethod ;
13+ use PHPStan \Analyser \NodeCallbackInvoker ;
14+ use PHPStan \Analyser \Scope ;
1315use PHPUnit \Framework \TestCase ;
1416
1517/**
@@ -39,7 +41,7 @@ public function testSingleArrayParamWithListDocblockIsFlagged(): void
3941 '/** @param list<ProductEnquiryItem> $items */ ' ,
4042 );
4143
42- self ::assertCount (1 , $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
44+ self ::assertCount (1 , $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
4345 }
4446
4547 public function testErrorMessageContainsMethodAndParamName (): void
@@ -50,11 +52,11 @@ public function testErrorMessageContainsMethodAndParamName(): void
5052 '/** @param list<string> $records */ ' ,
5153 );
5254
53- $ errors = $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class));
55+ $ errors = $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] ));
5456
5557 self ::assertCount (1 , $ errors );
56- self ::assertStringContainsString ('process() ' , ( string ) $ errors [0 ]->getMessage ());
57- self ::assertStringContainsString ('$records ' , ( string ) $ errors [0 ]->getMessage ());
58+ self ::assertStringContainsString ('process() ' , $ errors [0 ]->getMessage ());
59+ self ::assertStringContainsString ('$records ' , $ errors [0 ]->getMessage ());
5860 }
5961
6062 public function testMultipleParamsAreNotFlagged (): void
@@ -65,21 +67,21 @@ public function testMultipleParamsAreNotFlagged(): void
6567 '/** @param list<string> $items */ ' ,
6668 );
6769
68- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
70+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
6971 }
7072
7173 public function testZeroParamsAreNotFlagged (): void
7274 {
7375 $ method = $ this ->makeMethod ('render ' , [], '/** no params */ ' );
7476
75- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
77+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
7678 }
7779
7880 public function testNoDocblockIsNotFlagged (): void
7981 {
8082 $ method = $ this ->makeMethod ('render ' , [$ this ->makeArrayParam ('items ' )], null );
8183
82- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
84+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
8385 }
8486
8587 public function testArrayDocblockIsNotFlagged (): void
@@ -90,7 +92,7 @@ public function testArrayDocblockIsNotFlagged(): void
9092 '/** @param array<string> $items */ ' ,
9193 );
9294
93- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
95+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
9496 }
9597
9698 public function testIterableDocblockIsNotFlagged (): void
@@ -101,7 +103,7 @@ public function testIterableDocblockIsNotFlagged(): void
101103 '/** @param iterable<string> $items */ ' ,
102104 );
103105
104- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
106+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
105107 }
106108
107109 public function testAlreadyVariadicIsNotFlagged (): void
@@ -113,15 +115,15 @@ public function testAlreadyVariadicIsNotFlagged(): void
113115 '/** @param list<string> $items */ ' ,
114116 );
115117
116- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
118+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
117119 }
118120
119121 public function testNonArrayTypeIsNotFlagged (): void
120122 {
121123 $ param = new Param (new Variable ('items ' ), null , new Identifier ('string ' ));
122124 $ method = $ this ->makeMethod ('render ' , [$ param ], '/** @param list<string> $items */ ' );
123125
124- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
126+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
125127 }
126128
127129 public function testNullableArrayTypeIsNotFlagged (): void
@@ -130,15 +132,15 @@ public function testNullableArrayTypeIsNotFlagged(): void
130132 $ param = new Param (new Variable ('items ' ), null , $ nullableType );
131133 $ method = $ this ->makeMethod ('render ' , [$ param ], '/** @param list<string> $items */ ' );
132134
133- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
135+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
134136 }
135137
136138 public function testUntypedParamIsNotFlagged (): void
137139 {
138140 $ param = new Param (new Variable ('items ' ));
139141 $ method = $ this ->makeMethod ('render ' , [$ param ], '/** @param list<string> $items */ ' );
140142
141- self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
143+ self ::assertSame ([], $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
142144 }
143145
144146 public function testNestedGenericListIsFlagged (): void
@@ -149,7 +151,7 @@ public function testNestedGenericListIsFlagged(): void
149151 '/** @param list<Type<A, B>> $items */ ' ,
150152 );
151153
152- self ::assertCount (1 , $ this ->rule ->processNode ($ method , $ this ->createStub (\ PHPStan \ Analyser \ Scope::class)));
154+ self ::assertCount (1 , $ this ->rule ->processNode ($ method , $ this ->createMockForIntersectionOfInterfaces ([NodeCallbackInvoker::class, Scope::class] )));
153155 }
154156
155157 /**
0 commit comments