Skip to content
Closed
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"php": ">=8.0",
"php-static-analysis/attributes": "^0.3.1 || dev-main",
"php-static-analysis/node-visitor": "^0.3.1 || dev-main",
"rector/rector": "^0.19 || ^1.0"
"rector/rector": "~2.0.0"
},
"require-dev": {
"php-static-analysis/phpstan-extension": "dev-main",
"php-static-analysis/psalm-plugin": "dev-main",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.0",
"symplify/easy-coding-standard": "^12.1",
"vimeo/psalm": "^5",
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ parameters:
excludePaths:
- tests/Fixture/*
- tests/SpecialFixture/*

ignoreErrors:
- '#::provideMinPhpVersion\(\) never returns \d+ so it can be removed from the return type#'
12 changes: 12 additions & 0 deletions src/AnnotationsToAttributesRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public function getNodeTypes(): array
#[Param(node: 'Stmt\Class_|Stmt\ClassConst|Stmt\ClassMethod|Stmt\Function_|Stmt\Interface_|Stmt\Property|Stmt\Trait_')]
public function refactor(Node $node): ?Node
{
$hasChanged = false;
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);

$attributeGroups = [];
Expand All @@ -215,6 +216,7 @@ public function refactor(Node $node): ?Node
}

if ($attributeGroups !== []) {
$hasChanged = true;
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);

$this->attributeGroupNamedArgumentManipulator->decorate($attributeGroups);
Expand Down Expand Up @@ -243,13 +245,16 @@ public function refactor(Node $node): ?Node
$arg->name = null;
$parameterAttributeGroups = [new AttributeGroup([$attribute])];
$parameter->attrGroups = array_merge($parameter->attrGroups, $parameterAttributeGroups);

$hasChanged = true;
}
}
}
}
}
if ($attributeGroup->attrs === []) {
unset($attributeGroups[$attrKey]);
$hasChanged = true;
}
}
}
Expand All @@ -266,6 +271,8 @@ public function refactor(Node $node): ?Node

$this->attributeGroupNamedArgumentManipulator->decorate($useAttributeGroups);
$attributeGroups = array_merge($attributeGroups, $useAttributeGroups);

$hasChanged = true;
}
}
}
Expand All @@ -274,6 +281,11 @@ public function refactor(Node $node): ?Node

if ($attributeGroups !== []) {
$node->attrGroups = array_merge($node->attrGroups, $attributeGroups);
$hasChanged = true;
}

if (! $hasChanged) {
return null;
}

return $node;
Expand Down