mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
UPDATE Method.php, MethodTest.php
- Modify the RegEx, so that an annotation like `@method static $this myMethod()` is parsed correctly - Write a Unittest for that usecase
This commit is contained in:
committed by
Jaap van Otterdijk
parent
c14a4abfd7
commit
e9454d844d
@@ -92,9 +92,13 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
# Return type
|
# Return type
|
||||||
(?:
|
(?:
|
||||||
(
|
(
|
||||||
|
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
||||||
|
|
|
||||||
|
(?:
|
||||||
(?:[\w\|_\\\\]+)
|
(?:[\w\|_\\\\]+)
|
||||||
# array notation
|
# array notation
|
||||||
(?:\[\])*
|
(?:\[\])*
|
||||||
|
)
|
||||||
)?
|
)?
|
||||||
\s+
|
\s+
|
||||||
)?
|
)?
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ use phpDocumentor\Reflection\Types\Context;
|
|||||||
use phpDocumentor\Reflection\Types\Integer;
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
use phpDocumentor\Reflection\Types\Object_;
|
use phpDocumentor\Reflection\Types\Object_;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
|
use phpDocumentor\Reflection\Types\This;
|
||||||
use phpDocumentor\Reflection\Types\Void_;
|
use phpDocumentor\Reflection\Types\Void_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -276,6 +277,29 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReturnTypeThis()
|
||||||
|
{
|
||||||
|
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||||
|
$resolver = new TypeResolver();
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$description = new Description('');
|
||||||
|
|
||||||
|
$descriptionFactory->shouldReceive('create')->with('', $context)->andReturn($description);
|
||||||
|
|
||||||
|
$fixture = Method::create(
|
||||||
|
'static $this myMethod()',
|
||||||
|
$resolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue($fixture->isStatic());
|
||||||
|
$this->assertSame('static $this myMethod() ', (string)$fixture);
|
||||||
|
$this->assertSame('myMethod', $fixture->getMethodName());
|
||||||
|
$this->assertInstanceOf(This::class, $fixture->getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
public function collectionReturnTypesProvider()
|
public function collectionReturnTypesProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user