File tree 1 file changed +58
-0
lines changed
tests/PHPStan/Analyser/data
1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -158,4 +158,62 @@ public function testIntAlias($int)
158
158
assertType ('*ERROR* ' , (new Foo )->recursiveAliasProperty );
159
159
assertType ('*ERROR* ' , (new Foo )->circularAliasProperty );
160
160
161
+ trait FooTrait
162
+ {
163
+
164
+ /**
165
+ * @param Test $a
166
+ * @return Test
167
+ */
168
+ public function doFoo ($ a )
169
+ {
170
+ assertType (Test::class, $ a );
171
+ }
172
+
173
+ }
174
+
175
+ /** @phpstan-type Test array{string, int} */
176
+ class UsesTrait1
177
+ {
178
+
179
+ use FooTrait;
180
+
181
+ /** @param Test $a */
182
+ public function doBar ($ a )
183
+ {
184
+ assertType ('array(string, int) ' , $ a );
185
+ assertType (Test::class, $ this ->doFoo ());
186
+ }
187
+
188
+ }
189
+
190
+ /** @phpstan-type Test \stdClass */
191
+ class UsesTrait2
192
+ {
193
+
194
+ use FooTrait;
195
+
196
+ /** @param Test $a */
197
+ public function doBar ($ a )
198
+ {
199
+ assertType ('stdClass ' , $ a );
200
+ assertType (Test::class, $ this ->doFoo ());
201
+ }
202
+
203
+ }
204
+
205
+ class UsesTrait3
206
+ {
207
+
208
+ use FooTrait;
209
+
210
+ /** @param Test $a */
211
+ public function doBar ($ a )
212
+ {
213
+ assertType (Test::class, $ a );
214
+ assertType (Test::class, $ this ->doFoo ());
215
+ }
216
+
217
+ }
218
+
161
219
}
You can’t perform that action at this time.
0 commit comments