File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -91,10 +91,14 @@ public static function create(
91
91
)?
92
92
# Return type
93
93
(?:
94
- (
95
- (?:[\w\|_ \\\\]+)
96
- # array notation
97
- (?:\[\])*
94
+ (
95
+ (?:[\w\|_ \\\\]*\$this[\w\|_ \\\\]*)
96
+ |
97
+ (?:
98
+ (?:[\w\|_ \\\\]+)
99
+ # array notation
100
+ (?:\[\])*
101
+ )
98
102
)?
99
103
\s+
100
104
)?
Original file line number Diff line number Diff line change 22
22
use phpDocumentor \Reflection \Types \Integer ;
23
23
use phpDocumentor \Reflection \Types \Object_ ;
24
24
use phpDocumentor \Reflection \Types \String_ ;
25
+ use phpDocumentor \Reflection \Types \This ;
25
26
use phpDocumentor \Reflection \Types \Void_ ;
26
27
27
28
/**
@@ -276,6 +277,29 @@ public function testFactoryMethod()
276
277
$ this ->assertSame ($ description , $ fixture ->getDescription ());
277
278
}
278
279
280
+ public function testReturnTypeThis ()
281
+ {
282
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
283
+ $ resolver = new TypeResolver ();
284
+ $ context = new Context ('' );
285
+
286
+ $ description = new Description ('' );
287
+
288
+ $ descriptionFactory ->shouldReceive ('create ' )->with ('' , $ context )->andReturn ($ description );
289
+
290
+ $ fixture = Method::create (
291
+ 'static $this myMethod() ' ,
292
+ $ resolver ,
293
+ $ descriptionFactory ,
294
+ $ context
295
+ );
296
+
297
+ $ this ->assertTrue ($ fixture ->isStatic ());
298
+ $ this ->assertSame ('static $this myMethod() ' , (string )$ fixture );
299
+ $ this ->assertSame ('myMethod ' , $ fixture ->getMethodName ());
300
+ $ this ->assertInstanceOf (This::class, $ fixture ->getReturnType ());
301
+ }
302
+
279
303
public function collectionReturnTypesProvider ()
280
304
{
281
305
return [
You can’t perform that action at this time.
0 commit comments