Skip to content

Commit

Permalink
added promoted property test for annotation to attribute rule (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvera committed Jul 12, 2021
1 parent f17c388 commit d08a87f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture;

use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation;

final class PromotedProperty
{
public function __construct(
/**
* @GenericAnnotation
*/
private string $property,
) {}
}

?>
-----
<?php

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture;

use Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation;

final class PromotedProperty
{
public function __construct(
#[\Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Source\GenericAnnotation] private string $property,
) {}
}

?>
4 changes: 3 additions & 1 deletion rules/Php80/Rector/Class_/AnnotationToAttributeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser\Node\AttributeGroup;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
Expand Down Expand Up @@ -113,6 +114,7 @@ public function getNodeTypes(): array
return [
Class_::class,
Property::class,
Param::class,
ClassMethod::class,
Function_::class,
Closure::class,
Expand All @@ -121,7 +123,7 @@ public function getNodeTypes(): array
}

/**
* @param Class_|Property|ClassMethod|Function_|Closure|ArrowFunction $node
* @param Class_|Property|Param|ClassMethod|Function_|Closure|ArrowFunction $node
*/
public function refactor(Node $node): ?Node
{
Expand Down

0 comments on commit d08a87f

Please sign in to comment.