Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PhpDocParser] Make use of native attributes #5841

Merged
merged 7 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"nette/robot-loader": "^3.4",
"nette/utils": "^3.2",
"nikic/php-parser": "^4.10.4",
"phpstan/phpdoc-parser": "^0.5",
"phpstan/phpstan": "^0.12.82",
"phpstan/phpdoc-parser": "^0.5.1",
"phpstan/phpstan-phpunit": "^0.12.18",
"rector/rector-symfony": "dev-main",
"rector/rector-nette": "dev-main",
Expand All @@ -52,32 +52,32 @@
"symfony/http-kernel": "^4.4.8|^5.1",
"symfony/process": "^4.4.8|^5.1",
"symfony/uid": "^4.4.8|^5.1",
"symplify/astral": "^9.2",
"symplify/autowire-array-parameter": "^9.2",
"symplify/console-color-diff": "^9.2",
"symplify/package-builder": "^9.2",
"symplify/rule-doc-generator-contracts": "^9.2",
"symplify/set-config-resolver": "^9.2",
"symplify/simple-php-doc-parser": "^9.2",
"symplify/skipper": "^9.2",
"symplify/smart-file-system": "^9.2",
"symplify/symfony-php-config": "^9.2",
"symplify/astral": "^9.2.12",
"symplify/autowire-array-parameter": "^9.2.12",
"symplify/console-color-diff": "^9.2.12",
"symplify/package-builder": "^9.2.12",
"symplify/rule-doc-generator-contracts": "^9.2.12",
TomasVotruba marked this conversation as resolved.
Show resolved Hide resolved
"symplify/set-config-resolver": "^9.2.12",
"symplify/simple-php-doc-parser": "^9.2.12",
"symplify/skipper": "^9.2.12",
"symplify/smart-file-system": "^9.2.12",
"symplify/symfony-php-config": "^9.2.12",
"webmozart/assert": "^1.10"
},
"require-dev": {
"symplify/rule-doc-generator": "^9.2",
"symplify/rule-doc-generator": "^9.2.12",
"friendsofphp/php-cs-fixer": "^2.18.3",
"nette/application": "^3.0.7",
"nette/di": "^3.0",
"nette/forms": "^3.0",
"phpstan/phpstan-nette": "^0.12.16",
"phpunit/phpunit": "^9.5",
"rector/rector-generator": "^0.1.1",
"symplify/coding-standard": "^9.2",
"symplify/easy-ci": "^9.2",
"symplify/easy-coding-standard": "^9.2",
"symplify/easy-testing": "^9.2",
"symplify/phpstan-extensions": "^9.2",
"symplify/coding-standard": "^9.2.12",
"symplify/easy-ci": "^9.2.12",
"symplify/easy-coding-standard": "^9.2.12",
"symplify/easy-testing": "^9.2.12",
"symplify/phpstan-extensions": "^9.2.12",
"symplify/phpstan-rules": "^9.2",
"tracy/tracy": "^2.8"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\NullableTypeNode;
use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocNode;
use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePropertyTagValueNode;
use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIdentifierTypeNode;
use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareNullableTypeNode;
use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory;
use Rector\Core\HttpKernel\RectorKernel;
use Symplify\PackageBuilder\Testing\AbstractKernelTestCase;
Expand Down Expand Up @@ -57,28 +54,17 @@ public function testPropertyTag(): void
/** @var PhpDocTagNode $childNode */
$propertyTagValueNode = $childNode->value;
$this->assertInstanceOf(PropertyTagValueNode::class, $propertyTagValueNode);
$this->assertInstanceOf(AttributeAwarePropertyTagValueNode::class, $propertyTagValueNode);

// test nullable
/** @var PropertyTagValueNode $propertyTagValueNode */
$nullableTypeNode = $propertyTagValueNode->type;

$this->assertInstanceOf(NullableTypeNode::class, $nullableTypeNode);
$this->assertInstanceOf(AttributeAwareNullableTypeNode::class, $nullableTypeNode);

// test type inside nullable
/** @var NullableTypeNode $nullableTypeNode */
$identifierTypeNode = $nullableTypeNode->type;
$this->assertInstanceOf(IdentifierTypeNode::class, $identifierTypeNode);
$this->assertInstanceOf(AttributeAwareIdentifierTypeNode::class, $identifierTypeNode);
}

public function testAlreadyAttributeAware(): void
{
$attributeAwarePhpDocNode = new AttributeAwarePhpDocNode([]);
$returnedNode = $this->attributeAwareNodeFactory->createFromNode($attributeAwarePhpDocNode, '');

$this->assertSame($returnedNode, $attributeAwarePhpDocNode);
}

/**
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc;

use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\TypeAwareTagValueNodeInterface;

final class AttributeAwareParamTagValueNode extends ParamTagValueNode implements AttributeAwareNodeInterface, TypeAwareTagValueNodeInterface
final class AttributeAwareParamTagValueNode extends ParamTagValueNode
{
use AttributeTrait;

public function __toString(): string
{
$variadic = $this->isVariadic ? '...' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc;

use PHPStan\PhpDocParser\Ast\NodeAttributes;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface;
use Symplify\SimplePhpDocParser\ValueObject\Ast\PhpDoc\SimplePhpDocNode;

final class AttributeAwarePhpDocNode extends SimplePhpDocNode implements AttributeAwareNodeInterface
final class AttributeAwarePhpDocNode extends SimplePhpDocNode
{
use AttributeTrait;
use NodeAttributes;

/**
* @var PhpDocChildNode[]|AttributeAwareNodeInterface[]
* @var array<PhpDocChildNode>
*/
public $children = [];

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
use Nette\Utils\Strings;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface;

final class AttributeAwareTemplateTagValueNode extends TemplateTagValueNode implements AttributeAwareNodeInterface
final class AttributeAwareTemplateTagValueNode extends TemplateTagValueNode
{
use AttributeTrait;

/**
* @var string
* @see https://regex101.com/r/4WtsUS/1
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading