use AST for Symfony annotations

This commit is contained in:
Tomas Votruba 2019-08-28 21:53:17 +02:00
parent e473f6b5ae
commit 8811c900ea
2 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,66 @@
<?php declare(strict_types=1);
namespace Rector\Symfony\PhpDoc\Ast\PhpDoc;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Rector\BetterPhpDocParser\Attributes\Contract\Ast\AttributeAwareNodeInterface;
final class RouteTagValueNode implements AttributeAwareNodeInterface, PhpDocTagValueNode
{
use AttributeTrait;
/**
* @var string
*/
public const SHORT_NAME = '@Route';
public function __toString(): string
{
// TODO: Implement __toString() method.
}
// public function __toString(): string
// {
// $contentItems = [];
//
// if ($this->type !== null) {
// $contentItems['type'] = sprintf('type="%s"', $this->type);
// }
//
// if ($this->name !== null) {
// $contentItems['name'] = sprintf('name="%s"', $this->name);
// }
//
// if ($this->length !== null) {
// $contentItems['length'] = sprintf('length=%s', $this->length);
// }
//
// if ($this->precision !== null) {
// $contentItems['precision'] = sprintf('precision=%s', $this->precision);
// }
//
// if ($this->scale !== null) {
// $contentItems['scale'] = sprintf('scale=%s', $this->scale);
// }
//
// if ($this->unique !== null) {
// $contentItems['unique'] = sprintf('unique=%s', $this->unique ? 'true' : 'false');
// }
//
// if ($this->nullable !== null) {
// $contentItems['nullable'] = sprintf('nullable=%s', $this->nullable ? 'true' : 'false');
// }
//
// if ($this->options) {
// $contentItems['options'] = $this->printArrayItem($this->options, 'options');
// }
//
// if ($this->columnDefinition !== null) {
// $contentItems['columnDefinition'] = sprintf('columnDefinition="%s"', $this->columnDefinition);
// }
//
// return $this->printContentItems($contentItems);
// }
}

View File

@ -0,0 +1,66 @@
<?php declare(strict_types=1);
namespace Rector\Symfony\PhpDoc\Ast\PhpDoc;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Rector\BetterPhpDocParser\Attributes\Contract\Ast\AttributeAwareNodeInterface;
final class TemplateTagValueNode implements AttributeAwareNodeInterface, PhpDocTagValueNode
{
use AttributeTrait;
/**
* @var string
*/
public const SHORT_NAME = '@Template';
public function __toString(): string
{
// TODO: Implement __toString() method.
}
// public function __toString(): string
// {
// $contentItems = [];
//
// if ($this->type !== null) {
// $contentItems['type'] = sprintf('type="%s"', $this->type);
// }
//
// if ($this->name !== null) {
// $contentItems['name'] = sprintf('name="%s"', $this->name);
// }
//
// if ($this->length !== null) {
// $contentItems['length'] = sprintf('length=%s', $this->length);
// }
//
// if ($this->precision !== null) {
// $contentItems['precision'] = sprintf('precision=%s', $this->precision);
// }
//
// if ($this->scale !== null) {
// $contentItems['scale'] = sprintf('scale=%s', $this->scale);
// }
//
// if ($this->unique !== null) {
// $contentItems['unique'] = sprintf('unique=%s', $this->unique ? 'true' : 'false');
// }
//
// if ($this->nullable !== null) {
// $contentItems['nullable'] = sprintf('nullable=%s', $this->nullable ? 'true' : 'false');
// }
//
// if ($this->options) {
// $contentItems['options'] = $this->printArrayItem($this->options, 'options');
// }
//
// if ($this->columnDefinition !== null) {
// $contentItems['columnDefinition'] = sprintf('columnDefinition="%s"', $this->columnDefinition);
// }
//
// return $this->printContentItems($contentItems);
// }
}