Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace Rector\Tests\Php82\Rector\Class_\ReadOnlyClassRector\Fixture;

namespace Rector\Tests\Php82\Rector\Class_\ReadOnlyClassRector\Fixture;

#[SomeAttribute]
final readonly class ClassWithAttributeInline
#[SomeAttribute]final readonly class ClassWithAttributeInline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We changed this to different formatting 👍

{
private string $property;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Rector\Tests\Php82\Rector\Class_\ReadOnlyClassRector\Fixture;

#[SomeAttribute]
final class ClassWithAttribute
final class ClassWithAttributeNewLine
{
private readonly string $property;
}
Expand All @@ -15,7 +15,7 @@ final class ClassWithAttribute
namespace Rector\Tests\Php82\Rector\Class_\ReadOnlyClassRector\Fixture;

#[SomeAttribute]
final readonly class ClassWithAttribute
final readonly class ClassWithAttributeNewLine
{
private string $property;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Rector\Tests\Privatization\Rector\Class_\FinalizeTestCaseClassRector\F
use PHPUnit\Framework\TestCase;

#[CoversClass(Advisor::class)]
class WithAttribute extends TestCase
class WithAttributeNewLine extends TestCase
{
}

Expand All @@ -18,7 +18,7 @@ namespace Rector\Tests\Privatization\Rector\Class_\FinalizeTestCaseClassRector\F
use PHPUnit\Framework\TestCase;

#[CoversClass(Advisor::class)]
final class WithAttribute extends TestCase
final class WithAttributeNewLine extends TestCase
{
}

Expand Down
73 changes: 0 additions & 73 deletions rules/Php81/NodeManipulator/AttributeGroupNewLiner.php

This file was deleted.

11 changes: 2 additions & 9 deletions rules/Php82/NodeManipulator/ReadonlyClassManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
use PHPStan\Reflection\ReflectionProvider;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php81\Enum\AttributeName;
use Rector\Php81\NodeManipulator\AttributeGroupNewLiner;
use Rector\PHPStan\ScopeFetcher;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
use Rector\ValueObject\Application\File;
use Rector\ValueObject\MethodName;
use Rector\ValueObject\Visibility;

Expand All @@ -27,12 +25,11 @@
public function __construct(
private VisibilityManipulator $visibilityManipulator,
private PhpAttributeAnalyzer $phpAttributeAnalyzer,
private ReflectionProvider $reflectionProvider,
private AttributeGroupNewLiner $attributeGroupNewLiner
private ReflectionProvider $reflectionProvider
) {
}

public function process(Class_ $class, File $file): Class_|null
public function process(Class_ $class): Class_|null
{
$scope = ScopeFetcher::fetch($class);
if ($this->shouldSkip($class, $scope)) {
Expand All @@ -53,10 +50,6 @@ public function process(Class_ $class, File $file): Class_|null
$this->visibilityManipulator->removeReadonly($property);
}

if ($class->attrGroups !== []) {
$this->attributeGroupNewLiner->newLine($file, $class);
}

return $class;
}

Expand Down
2 changes: 1 addition & 1 deletion rules/Php82/Rector/Class_/ReadOnlyClassRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function refactor(Node $node): ?Node
return null;
}

return $this->readonlyClassManipulator->process($node, $this->file);
return $this->readonlyClassManipulator->process($node);
}

public function provideMinPhpVersion(): int
Expand Down
2 changes: 1 addition & 1 deletion rules/Php83/Rector/Class_/ReadOnlyAnonymousClassRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function refactor(Node $node): ?Node
return null;
}

return $this->readonlyClassManipulator->process($node, $this->file);
return $this->readonlyClassManipulator->process($node);
}

public function provideMinPhpVersion(): int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Php81\NodeManipulator\AttributeGroupNewLiner;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
Expand All @@ -20,8 +19,7 @@ final class FinalizeTestCaseClassRector extends AbstractRector
{
public function __construct(
private readonly ReflectionProvider $reflectionProvider,
private readonly VisibilityManipulator $visibilityManipulator,
private readonly AttributeGroupNewLiner $attributeGroupNewLiner
private readonly VisibilityManipulator $visibilityManipulator
) {
}

Expand Down Expand Up @@ -85,10 +83,6 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node->attrGroups !== []) {
$this->attributeGroupNewLiner->newLine($this->file, $node);
}

$this->visibilityManipulator->makeFinal($node);

return $node;
Expand Down