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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"phpstan/phpstan": "^2.1.8",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.4",
"rector/rector-src": "dev-main",
"rector/rector-src": "dev-tv-abstract-annotation-to-attribute",
Copy link
Member Author

Choose a reason for hiding this comment

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

WIP

"rector/type-perfect": "^2.0",
"symfony/config": "^6.4",
"symfony/dependency-injection": "^6.4",
Expand Down
9 changes: 6 additions & 3 deletions config/sets/jms/annotations-to-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Symfony\JMS\Rector\AccessTypeAnnotationToAttributeRector;
use Rector\Symfony\JMS\Rector\Class_\AccessTypeAnnotationToAttributeRector;
use Rector\Symfony\JMS\Rector\Property\AccessorAnnotationToAttributeRector;

/**
* @see https://github.com/schmittjoh/serializer/pull/1320
Expand All @@ -14,7 +15,6 @@
*/
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
new AnnotationToAttribute('JMS\Serializer\Annotation\Accessor'),
new AnnotationToAttribute('JMS\Serializer\Annotation\AccessorOrder'),
new AnnotationToAttribute('JMS\Serializer\Annotation\Discriminator'),
new AnnotationToAttribute('JMS\Serializer\Annotation\Exclude'),
Expand Down Expand Up @@ -46,5 +46,8 @@
new AnnotationToAttribute('JMS\Serializer\Annotation\XmlValue'),
]);

$rectorConfig->rules([AccessTypeAnnotationToAttributeRector::class]);
$rectorConfig->rules([
AccessTypeAnnotationToAttributeRector::class,
AccessorAnnotationToAttributeRector::class,
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\JMS\Rector\AccessTypeAnnotationToAttributeRector;
use Rector\Symfony\JMS\Rector\Class_\AccessTypeAnnotationToAttributeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(AccessTypeAnnotationToAttributeRector::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\JMS\Rector\Property\AccessorAnnotationToAttributeRector;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class AccessorAnnotationToAttributeRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Symfony\Tests\JMS\Rector\Property\AccessorAnnotationToAttributeRector\Fixture;

use JMS\Serializer\Annotation as Serializer;

final class AnnotationTypes
{
/**
* @Serializer\Accessor("getSome")
*/
private $value;
}

?>
-----
<?php

namespace Rector\Symfony\Tests\JMS\Rector\Property\AccessorAnnotationToAttributeRector\Fixture;

use JMS\Serializer\Annotation as Serializer;

final class AnnotationTypes
{
#[Serializer\Accessor(getter: 'getSome')]
private $value;
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Symfony\Tests\JMS\Rector\Property\AccessorAnnotationToAttributeRector\Fixture;

use JMS\Serializer\Annotation as Serializer;

final class KeepGivenKey
{
/**
* @Serializer\Accessor(setter="setSome")
*/
private $value;
}

?>
-----
<?php

namespace Rector\Symfony\Tests\JMS\Rector\Property\AccessorAnnotationToAttributeRector\Fixture;

use JMS\Serializer\Annotation as Serializer;

final class KeepGivenKey
{
#[Serializer\Accessor(setter: 'setSome')]
private $value;
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Symfony\JMS\Rector\Property\AccessorAnnotationToAttributeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(AccessorAnnotationToAttributeRector::class);
};
180 changes: 0 additions & 180 deletions rules/JMS/Rector/AccessTypeAnnotationToAttributeRector.php

This file was deleted.

Loading