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(
9191 )?
9292 # Return type
9393 (?:
94- (
95- (?:[\w\|_ \\\\]+)
96- # array notation
97- (?:\[\])*
94+ (
95+ (?:[\w\|_ \\\\]*\$this[\w\|_ \\\\]*)
96+ |
97+ (?:
98+ (?:[\w\|_ \\\\]+)
99+ # array notation
100+ (?:\[\])*
101+ )
98102 )?
99103 \s+
100104 )?
Original file line number Diff line number Diff line change 2222use phpDocumentor \Reflection \Types \Integer ;
2323use phpDocumentor \Reflection \Types \Object_ ;
2424use phpDocumentor \Reflection \Types \String_ ;
25+ use phpDocumentor \Reflection \Types \This ;
2526use phpDocumentor \Reflection \Types \Void_ ;
2627
2728/**
@@ -276,6 +277,29 @@ public function testFactoryMethod()
276277 $ this ->assertSame ($ description , $ fixture ->getDescription ());
277278 }
278279
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+
279303 public function collectionReturnTypesProvider ()
280304 {
281305 return [
You can’t perform that action at this time.
0 commit comments