[DoctrineCodeQuality] Remove redundant default values from annotations (#4542)

* Move duplicated getAttributableItems() method to abstract parent

* Add removeItem() method to AbstractTagValueNode class

* Add RemoveRedundantDefaultAnnotationValuesRector rule with tests

* Link second test case of RemoveRedundantDefaultAnnotationValuesRector

* Add to set and docs

* Rename variable in DoctrineClassAnalyzer::matchDoctrineEntityTagValueNode()

* Remove redundant docblocks in RemoveRedundantDefaultAnnotationValuesRector

* Extract hasItemWithDefaultValue method in RemoveRedundantDefaultAnnotationValuesRector

* Optimize RemoveRedundantDefaultAnnotationValuesRector

* Split rule into two separate: one for Property and one for Class_

* PHP CS Fixer

* PHPStan
This commit is contained in:
Krystian Marcisz 2020-11-04 22:51:11 +01:00 committed by GitHub
parent 600334eafa
commit a92f4c1e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 1508 additions and 41 deletions

View File

@ -5,11 +5,13 @@ declare(strict_types=1);
use Rector\Doctrine\Rector\Class_\ManagerRegistryGetManagerToEntityManagerRector;
use Rector\DoctrineCodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector;
use Rector\DoctrineCodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector;
use Rector\DoctrineCodeQuality\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector;
use Rector\DoctrineCodeQuality\Rector\ClassMethod\MakeEntityDateTimePropertyDateTimeInterfaceRector;
use Rector\DoctrineCodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector;
use Rector\DoctrineCodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector;
use Rector\DoctrineCodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector;
use Rector\DoctrineCodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector;
use Rector\DoctrineCodeQuality\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
@ -22,4 +24,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(CorrectDefaultTypesOnEntityPropertyRector::class);
$services->set(ChangeBigIntEntityPropertyToIntTypeRector::class);
$services->set(ImproveDoctrineCollectionDocTypeInEntityRector::class);
$services->set(RemoveRedundantDefaultPropertyAnnotationValuesRector::class);
$services->set(RemoveRedundantDefaultClassAnnotationValuesRector::class);
};

View File

@ -13,7 +13,7 @@
- [DeadCode](#deadcode) (41)
- [Defluent](#defluent) (8)
- [Doctrine](#doctrine) (17)
- [DoctrineCodeQuality](#doctrinecodequality) (9)
- [DoctrineCodeQuality](#doctrinecodequality) (11)
- [DoctrineGedmoToKnplabs](#doctrinegedmotoknplabs) (7)
- [DowngradePhp71](#downgradephp71) (3)
- [DowngradePhp72](#downgradephp72) (2)
@ -4449,6 +4449,53 @@ Turns parent EntityRepository class to constructor dependency
<br><br>
### `RemoveRedundantDefaultPropertyAnnotationValuesRector`
- class: [`Rector\DoctrineCodeQuality\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector`](/rules/doctrine-code-quality/src/Rector/Property/RemoveRedundantDefaultPropertyAnnotationValuesRector.php)
- [test fixtures](/rules/doctrine-code-quality/tests/Rector/Property/RemoveRedundantDefaultPropertyAnnotationValuesRector/Fixture)
Removes redundant default values from Doctrine ORM annotations on class property level
```diff
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class SomeClass
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
- * @ORM\JoinColumn(name="training", unique=false)
+ * @ORM\JoinColumn(name="training")
*/
private $training;
}
```
<br><br>
### `RemoveRedundantDefaultPropertyAnnotationValuesRector`
- class: [`Rector\DoctrineCodeQuality\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector`](/rules/doctrine-code-quality/src/Rector/Class_/RemoveRedundantDefaultClassAnnotationValuesRector.php)
- [test fixtures](/rules/doctrine-code-quality/tests/Rector/Class_/RemoveRedundantDefaultClassAnnotationValuesRector/Fixture)
Removes redundant default values from Doctrine ORM annotations on class level
```diff
use Doctrine\ORM\Mapping as ORM;
/**
- * @ORM\Entity(readOnly=false)
+ * @ORM\Entity()
*/
class SomeClass
{
}
```
<br><br>
## DoctrineGedmoToKnplabs
### `BlameableBehaviorRector`

View File

@ -65,6 +65,11 @@ abstract class AbstractTagValueNode implements AttributeAwareNodeInterface, PhpD
$this->items[$key] = $value;
}
public function removeItem(string $key): void
{
unset($this->items[$key]);
}
/**
* @param mixed[] $contentItems
* @return mixed[]

View File

@ -10,4 +10,11 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\AbstractTagValueNode;
abstract class AbstractDoctrineTagValueNode extends AbstractTagValueNode implements DoctrineTagNodeInterface, ShortNameAwareTagInterface
{
/**
* @return mixed[]
*/
public function getAttributableItems(): array
{
return $this->filterOutMissingItems($this->items);
}
}

View File

@ -37,14 +37,6 @@ final class ColumnTagValueNode extends AbstractDoctrineTagValueNode implements P
return $this->items['options'] ?? [];
}
/**
* @return mixed[]
*/
public function getAttributableItems(): array
{
return $this->filterOutMissingItems($this->items);
}
public function getAttributeClassName(): string
{
return 'TBA';

View File

@ -23,14 +23,6 @@ final class GeneratedValueTagValueNode extends AbstractDoctrineTagValueNode impl
return 'strategy';
}
/**
* @return mixed[]
*/
public function getAttributableItems(): array
{
return $this->filterOutMissingItems($this->items);
}
public function getAttributeClassName(): string
{
return 'TBA';

View File

@ -14,14 +14,6 @@ final class IdTagValueNode extends AbstractDoctrineTagValueNode implements PhpAt
return '@ORM\Id';
}
/**
* @return mixed[]
*/
public function getAttributableItems(): array
{
return $this->filterOutMissingItems($this->items);
}
public function getAttributeClassName(): string
{
return 'TBA';

View File

@ -52,14 +52,6 @@ final class JoinColumnTagValueNode extends AbstractDoctrineTagValueNode implemen
$this->shortName = $shortName;
}
/**
* @return mixed[]
*/
public function getAttributableItems(): array
{
return $this->filterOutMissingItems($this->items);
}
public function getAttributeClassName(): string
{
return 'TBA';

View File

@ -72,14 +72,6 @@ final class ManyToManyTagValueNode extends AbstractDoctrineTagValueNode implemen
return '@ORM\ManyToMany';
}
/**
* @return mixed[]
*/
public function getAttributableItems(): array
{
return $this->filterOutMissingItems($this->items);
}
public function getAttributeClassName(): string
{
return 'TBA';

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Rector\DoctrineCodeQuality\NodeAnalyzer;
use PhpParser\Node\Stmt\Class_;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Class_\EntityTagValueNode;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class DoctrineClassAnalyzer
{
public function matchDoctrineEntityTagValueNode(Class_ $class_): ?EntityTagValueNode
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $class_->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return null;
}
return $phpDocInfo->getByType(EntityTagValueNode::class);
}
}

View File

@ -7,7 +7,12 @@ namespace Rector\DoctrineCodeQuality\NodeAnalyzer;
use PhpParser\Node\Stmt\Property;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\ColumnTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\GeneratedValueTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\JoinColumnTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\ManyToManyTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\ManyToOneTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\OneToManyTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\OneToOneTagValueNode;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class DoctrinePropertyAnalyzer
@ -33,4 +38,59 @@ final class DoctrinePropertyAnalyzer
return $phpDocInfo->getByType(OneToManyTagValueNode::class);
}
public function matchDoctrineOneToOneTagValueNode(Property $property): ?OneToOneTagValueNode
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return null;
}
return $phpDocInfo->getByType(OneToOneTagValueNode::class);
}
public function matchDoctrineManyToManyTagValueNode(Property $property): ?ManyToManyTagValueNode
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return null;
}
return $phpDocInfo->getByType(ManyToManyTagValueNode::class);
}
public function matchDoctrineManyToOneTagValueNode(Property $property): ?ManyToOneTagValueNode
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return null;
}
return $phpDocInfo->getByType(ManyToOneTagValueNode::class);
}
public function matchDoctrineJoinColumnTagValueNode(Property $property): ?JoinColumnTagValueNode
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return null;
}
return $phpDocInfo->getByType(JoinColumnTagValueNode::class);
}
public function matchDoctrineGeneratedValueTagValueNode(Property $property): ?GeneratedValueTagValueNode
{
/** @var PhpDocInfo|null $phpDocInfo */
$phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo === null) {
return null;
}
return $phpDocInfo->getByType(GeneratedValueTagValueNode::class);
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace Rector\DoctrineCodeQuality\NodeManipulator;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\AbstractDoctrineTagValueNode;
final class DoctrineItemDefaultValueManipulator
{
/** @var bool */
private $hasModifiedAnnotation = false;
/**
* @param string|bool|int $defaultValue
*/
public function remove(
AbstractDoctrineTagValueNode $doctrineTagValueNode,
string $item,
$defaultValue
): void {
if (! $this->hasItemWithDefaultValue($doctrineTagValueNode, $item, $defaultValue)) {
return;
}
$this->hasModifiedAnnotation = true;
$doctrineTagValueNode->removeItem($item);
}
/**
* @param string|bool|int $defaultValue
*/
private function hasItemWithDefaultValue(
AbstractDoctrineTagValueNode $doctrineTagValueNode,
string $item,
$defaultValue
): bool {
$attributableItems = $doctrineTagValueNode->getAttributableItems();
if (! isset($attributableItems[$item])) {
return false;
}
return $attributableItems[$item] === $defaultValue;
}
public function resetHasModifiedAnnotation(): void
{
$this->hasModifiedAnnotation = false;
}
public function hasModifiedAnnotation(): bool
{
return $this->hasModifiedAnnotation;
}
}

View File

@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
namespace Rector\DoctrineCodeQuality\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\CodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\DoctrineCodeQuality\NodeAnalyzer\DoctrineClassAnalyzer;
use Rector\DoctrineCodeQuality\NodeManipulator\DoctrineItemDefaultValueManipulator;
/**
* @see \Rector\DoctrineCodeQuality\Tests\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector\RemoveRedundantDefaultClassAnnotationValuesRectorTest
*/
final class RemoveRedundantDefaultClassAnnotationValuesRector extends AbstractRector
{
/**
* @var DoctrineClassAnalyzer
*/
private $doctrineClassAnalyzer;
/**
* @var DoctrineItemDefaultValueManipulator
*/
private $doctrineItemDefaultValueManipulator;
public function __construct(
DoctrineClassAnalyzer $doctrineClassAnalyzer,
DoctrineItemDefaultValueManipulator $doctrineItemDefaultValueManipulator
) {
$this->doctrineClassAnalyzer = $doctrineClassAnalyzer;
$this->doctrineItemDefaultValueManipulator = $doctrineItemDefaultValueManipulator;
}
public function getDefinition(): RectorDefinition
{
return new RectorDefinition(
'Removes redundant default values from Doctrine ORM annotations on class level',
[
new CodeSample(
<<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(readOnly=false)
*/
class SomeClass
{
}
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SomeClass
{
}
CODE_SAMPLE
),
]
);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [Class_::class];
}
public function refactor(Node $node): ?Node
{
$this->doctrineItemDefaultValueManipulator->resetHasModifiedAnnotation();
if ($node instanceof Class_) {
$this->refactorClassAnnotations($node);
}
if (! $this->doctrineItemDefaultValueManipulator->hasModifiedAnnotation()) {
return null;
}
return $node;
}
private function refactorClassAnnotations(Class_ $node): void
{
$this->refactorEntityAnnotation($node);
}
private function refactorEntityAnnotation(Class_ $node): void
{
$entityTagValueNode = $this->doctrineClassAnalyzer->matchDoctrineEntityTagValueNode($node);
if ($entityTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($entityTagValueNode, 'readOnly', false);
}
}

View File

@ -0,0 +1,191 @@
<?php
declare(strict_types=1);
namespace Rector\DoctrineCodeQuality\Rector\Property;
use PhpParser\Node;
use PhpParser\Node\Stmt\Property;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\CodeSample;
use Rector\Core\RectorDefinition\RectorDefinition;
use Rector\DoctrineCodeQuality\NodeAnalyzer\DoctrinePropertyAnalyzer;
use Rector\DoctrineCodeQuality\NodeManipulator\DoctrineItemDefaultValueManipulator;
/**
* @see \Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\RemoveRedundantDefaultPropertyAnnotationValuesRectorTest
*/
final class RemoveRedundantDefaultPropertyAnnotationValuesRector extends AbstractRector
{
/**
* @var DoctrinePropertyAnalyzer
*/
private $doctrinePropertyAnalyzer;
/**
* @var DoctrineItemDefaultValueManipulator
*/
private $doctrineItemDefaultValueManipulator;
public function __construct(
DoctrinePropertyAnalyzer $doctrinePropertyAnalyzer,
DoctrineItemDefaultValueManipulator $doctrineItemDefaultValueManipulator
) {
$this->doctrinePropertyAnalyzer = $doctrinePropertyAnalyzer;
$this->doctrineItemDefaultValueManipulator = $doctrineItemDefaultValueManipulator;
}
public function getDefinition(): RectorDefinition
{
return new RectorDefinition(
'Removes redundant default values from Doctrine ORM annotations on class property level',
[
new CodeSample(
<<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class SomeClass
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", unique=false)
*/
private $training;
}
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class SomeClass
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training")
*/
private $training;
}
CODE_SAMPLE
),
]
);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [Property::class];
}
public function refactor(Node $node): ?Node
{
$this->doctrineItemDefaultValueManipulator->resetHasModifiedAnnotation();
if ($node instanceof Property) {
$this->refactorPropertyAnnotations($node);
}
if (! $this->doctrineItemDefaultValueManipulator->hasModifiedAnnotation()) {
return null;
}
return $node;
}
private function refactorPropertyAnnotations(Property $node): void
{
$this->refactorColumnAnnotation($node);
$this->refactorGeneratedValueAnnotation($node);
$this->refactorJoinColumnAnnotation($node);
$this->refactorManyToManyAnnotation($node);
$this->refactorManyToOneAnnotation($node);
$this->refactorOneToManyAnnotation($node);
$this->refactorOneToOneAnnotation($node);
}
private function refactorColumnAnnotation(Property $node): void
{
$columnTagValueNode = $this->doctrinePropertyAnalyzer->matchDoctrineColumnTagValueNode($node);
if ($columnTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($columnTagValueNode, 'nullable', false);
$this->doctrineItemDefaultValueManipulator->remove($columnTagValueNode, 'unique', false);
$this->doctrineItemDefaultValueManipulator->remove($columnTagValueNode, 'precision', 0);
$this->doctrineItemDefaultValueManipulator->remove($columnTagValueNode, 'scale', 0);
}
private function refactorJoinColumnAnnotation(Property $node): void
{
$joinColumnTagValueNode = $this->doctrinePropertyAnalyzer->matchDoctrineJoinColumnTagValueNode($node);
if ($joinColumnTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($joinColumnTagValueNode, 'nullable', true);
$this->doctrineItemDefaultValueManipulator->remove($joinColumnTagValueNode, 'referencedColumnName', 'id');
$this->doctrineItemDefaultValueManipulator->remove($joinColumnTagValueNode, 'unique', false);
}
private function refactorGeneratedValueAnnotation(Property $node): void
{
$generatedValue = $this->doctrinePropertyAnalyzer->matchDoctrineGeneratedValueTagValueNode($node);
if ($generatedValue === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($generatedValue, 'strategy', 'AUTO');
}
private function refactorManyToManyAnnotation(Property $node): void
{
$manyToManyTagValueNode = $this->doctrinePropertyAnalyzer->matchDoctrineManyToManyTagValueNode($node);
if ($manyToManyTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($manyToManyTagValueNode, 'orphanRemoval', false);
$this->doctrineItemDefaultValueManipulator->remove($manyToManyTagValueNode, 'fetch', 'LAZY');
}
private function refactorManyToOneAnnotation(Property $node): void
{
$manyToOneTagValueNode = $this->doctrinePropertyAnalyzer->matchDoctrineManyToOneTagValueNode($node);
if ($manyToOneTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($manyToOneTagValueNode, 'fetch', 'LAZY');
}
private function refactorOneToManyAnnotation(Property $node): void
{
$oneToManyTagValueNode = $this->doctrinePropertyAnalyzer->matchDoctrineOneToManyTagValueNode($node);
if ($oneToManyTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($oneToManyTagValueNode, 'orphanRemoval', false);
$this->doctrineItemDefaultValueManipulator->remove($oneToManyTagValueNode, 'fetch', 'LAZY');
}
private function refactorOneToOneAnnotation(Property $node): void
{
$oneToManyTagValueNode = $this->doctrinePropertyAnalyzer->matchDoctrineOneToOneTagValueNode($node);
if ($oneToManyTagValueNode === null) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($oneToManyTagValueNode, 'orphanRemoval', false);
$this->doctrineItemDefaultValueManipulator->remove($oneToManyTagValueNode, 'fetch', 'LAZY');
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector\Fixture\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(readOnly=false)
*/
class ReadOnlyFalse
{
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector\Fixture\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class ReadOnlyFalse
{
}
?>

View File

@ -0,0 +1,14 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector\Fixture\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(readOnly=true)
*/
class ReadOnlySkipped
{
}
?>

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Rector\DoctrineCodeQuality\Tests\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector;
use Iterator;
use Rector\DoctrineCodeQuality\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class RemoveRedundantDefaultClassAnnotationValuesRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return RemoveRedundantDefaultClassAnnotationValuesRector::class;
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class NullableFalse
{
/**
* @ORM\Column(type="string", nullable=false)
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class NullableFalse
{
/**
* @ORM\Column(type="string")
*/
private $training;
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class NullableSkipped
{
/**
* @ORM\Column(type="string", nullable=true)
*/
private $training;
}
?>

View File

@ -0,0 +1,19 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class PrecisionSkipped
{
/**
* @ORM\Column(type="integer", precision=1)
*/
private $training;
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class PrecisionZero
{
/**
* @ORM\Column(type="integer", precision=0)
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class PrecisionZero
{
/**
* @ORM\Column(type="integer")
*/
private $training;
}
?>

View File

@ -0,0 +1,19 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class ScaleSkipped
{
/**
* @ORM\Column(type="decimal", precision=1)
*/
private $training;
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class ScaleZero
{
/**
* @ORM\Column(type="decimal", scale=0)
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class ScaleZero
{
/**
* @ORM\Column(type="decimal")
*/
private $training;
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class UniqueFalse
{
/**
* @ORM\Column(type="string", unique=false)
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class UniqueFalse
{
/**
* @ORM\Column(type="string")
*/
private $training;
}
?>

View File

@ -0,0 +1,19 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\Column;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class UniqueSkipped
{
/**
* @ORM\Column(type="string", unique=true)
*/
private $training;
}
?>

View File

@ -0,0 +1,43 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\GeneratedValue;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class StrategyAuto
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id = null;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\GeneratedValue;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class StrategyAuto
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue()
*/
protected $id = null;
}
?>

View File

@ -0,0 +1,21 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\GeneratedValue;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class StrategySkipped
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="SEQUENCE")
*/
protected $id = null;
}
?>

View File

@ -0,0 +1,21 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class NullableFalseSkipped
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", nullable=false)
*/
private $training;
}
?>

View File

@ -0,0 +1,41 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class NullableTrue
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", nullable=true)
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class NullableTrue
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training")
*/
private $training;
}
?>

View File

@ -0,0 +1,41 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class ReferencedColumnNameId
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", referencedColumnName="id")
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class ReferencedColumnNameId
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training")
*/
private $training;
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class ReferencedColumnNameSkipped
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", referencedColumnName="uniqId")
*/
private $training;
}
?>

View File

@ -0,0 +1,41 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class UniqueFalse
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", unique=false)
*/
private $training;
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class UniqueFalse
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training")
*/
private $training;
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\JoinColumn;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class UniqueSkipped
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
* @ORM\JoinColumn(name="training", unique=true)
*/
private $training;
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\ManyToMany(targetEntity=Training::class, fetch="LAZY")
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\ManyToMany(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchSkipped
{
/**
* @ORM\ManyToMany(targetEntity=Training::class, fetch="AUTO")
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalFalse
{
/**
* @ORM\ManyToMany(targetEntity=Training::class, orphanRemoval=false)
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalFalse
{
/**
* @ORM\ManyToMany(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalSkipped
{
/**
* @ORM\ManyToMany(targetEntity=Training::class, orphanRemoval=true)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\ManyToOne(targetEntity=Training::class, fetch="LAZY")
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\ManyToOne(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\ManyToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchSkipped
{
/**
* @ORM\ManyToOne(targetEntity=Training::class, fetch="AUTO")
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\OneToMany(targetEntity=Training::class, fetch="LAZY")
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\OneToMany(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchSkipped
{
/**
* @ORM\OneToMany(targetEntity=Training::class, fetch="AUTO")
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalFalse
{
/**
* @ORM\OneToMany(targetEntity=Training::class, orphanRemoval=false)
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalFalse
{
/**
* @ORM\OneToMany(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToMany;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalSkipped
{
/**
* @ORM\OneToMany(targetEntity=Training::class, orphanRemoval=true)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\OneToOne(targetEntity=Training::class, fetch="LAZY")
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchLazy
{
/**
* @ORM\OneToOne(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class FetchSkipped
{
/**
* @ORM\OneToOne(targetEntity=Training::class, fetch="AUTO")
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,39 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalFalse
{
/**
* @ORM\OneToOne(targetEntity=Training::class, orphanRemoval=false)
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalFalse
{
/**
* @ORM\OneToOne(targetEntity=Training::class)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Fixture\OneToOne;
use Doctrine\ORM\Mapping as ORM;
use Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source\Training;
/**
* @ORM\Entity
*/
class OrphanRemovalSkipped
{
/**
* @ORM\OneToOne(targetEntity=Training::class, orphanRemoval=true)
*/
private $trainings = [];
}
?>

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector;
use Iterator;
use Rector\DoctrineCodeQuality\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class RemoveRedundantDefaultPropertyAnnotationValuesRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return RemoveRedundantDefaultPropertyAnnotationValuesRector::class;
}
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\DoctrineCodeQuality\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\Source;
final class Training
{
}