Add property support

This commit is contained in:
Jaapio
2022-10-28 21:07:34 +02:00
parent 1dd491c8ec
commit cfe9845260
9 changed files with 288 additions and 6 deletions
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\Property;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
final class PropertyFactoryTest extends TagFactoryTestCase
{
/**
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory::supports
*/
public function testParamIsCreated(): void
{
$ast = $this->parseTag('@property string $var');
$factory = new PropertyFactory($this->giveTypeFactory(), $this->givenDescriptionFactory());
$context = new Context('global');
self::assertTrue($factory->supports($ast, $context));
self::assertEquals(
new Property(
'var',
new String_(),
new Description('')
),
$factory->create($ast, $context)
);
}
}
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
final class PropertyReadFactoryTest extends TagFactoryTestCase
{
/**
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory::supports
*/
public function testParamIsCreated(): void
{
$ast = $this->parseTag('@property-read string $var');
$factory = new PropertyReadFactory($this->giveTypeFactory(), $this->givenDescriptionFactory());
$context = new Context('global');
self::assertTrue($factory->supports($ast, $context));
self::assertEquals(
new PropertyRead(
'var',
new String_(),
new Description('')
),
$factory->create($ast, $context)
);
}
}
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
final class PropertyWriteFactoryTest extends TagFactoryTestCase
{
/**
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory::supports
*/
public function testParamIsCreated(): void
{
$ast = $this->parseTag('@property-write string $var');
$factory = new PropertyWriteFactory($this->giveTypeFactory(), $this->givenDescriptionFactory());
$context = new Context('global');
self::assertTrue($factory->supports($ast, $context));
self::assertEquals(
new PropertyWrite(
'var',
new String_(),
new Description('')
),
$factory->create($ast, $context)
);
}
}
@@ -21,9 +21,9 @@ use phpDocumentor\Reflection\Types\String_;
final class ReturnFactoryTest extends TagFactoryTestCase
{
/**
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::supports
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory::supports
*/
public function testParamIsCreated(): void
{
@@ -21,9 +21,9 @@ use phpDocumentor\Reflection\Types\String_;
final class VarFactoryTest extends TagFactoryTestCase
{
/**
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::supports
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory::supports
*/
public function testParamIsCreated(): void
{