Skip to content

Commit c923389

Browse files
Fix YamlToAttributeDoctrineMappingRector (#377)
1 parent 37b796c commit c923389

22 files changed

Lines changed: 97 additions & 55 deletions

rules/CodeQuality/AttributeTransformer/ClassAttributeTransformer/EmbeddableClassAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212

1313
final class EmbeddableClassAttributeTransformer implements ClassAttributeTransformerInterface
1414
{
15-
public function transform(EntityMapping $entityMapping, Class_ $class): void
15+
public function transform(EntityMapping $entityMapping, Class_ $class): bool
1616
{
1717
$classMapping = $entityMapping->getClassMapping();
1818

1919
$type = $classMapping['type'] ?? null;
2020
if ($type !== 'embeddable') {
21-
return;
21+
return false;
2222
}
2323

2424
$class->attrGroups[] = AttributeFactory::createGroup($this->getClassName());
25+
return true;
2526
}
2627

2728
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/ClassAttributeTransformer/EntityClassAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ final class EntityClassAttributeTransformer implements ClassAttributeTransformer
1919
*/
2020
private const REPOSITORY_CLASS_KEY = 'repositoryClass';
2121

22-
public function transform(EntityMapping $entityMapping, Class_ $class): void
22+
public function transform(EntityMapping $entityMapping, Class_ $class): bool
2323
{
2424
$classMapping = $entityMapping->getClassMapping();
2525

2626
$type = $classMapping['type'] ?? null;
2727
if ($type !== 'entity') {
28-
return;
28+
return false;
2929
}
3030

3131
$args = [];
@@ -37,6 +37,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
3737
}
3838

3939
$class->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
40+
return true;
4041
}
4142

4243
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/ClassAttributeTransformer/InheritanceClassAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public function __construct(
2424
) {
2525
}
2626

27-
public function transform(EntityMapping $entityMapping, Class_ $class): void
27+
public function transform(EntityMapping $entityMapping, Class_ $class): bool
2828
{
2929
$classMapping = $entityMapping->getClassMapping();
3030

3131
$inheritanceType = $classMapping['inheritanceType'] ?? null;
3232
if ($inheritanceType === null) {
33-
return;
33+
return false;
3434
}
3535

3636
$class->attrGroups[] = AttributeFactory::createGroup(MappingClass::INHERITANCE_TYPE, [$inheritanceType]);
@@ -45,6 +45,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
4545
if (isset($classMapping['discriminatorMap'])) {
4646
$this->addDiscriminatorMap($classMapping['discriminatorMap'], $class);
4747
}
48+
return true;
4849
}
4950

5051
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/ClassAttributeTransformer/SoftDeletableClassAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public function __construct(
2020
) {
2121
}
2222

23-
public function transform(EntityMapping $entityMapping, Class_ $class): void
23+
public function transform(EntityMapping $entityMapping, Class_ $class): bool
2424
{
2525
$classMapping = $entityMapping->getClassMapping();
2626

2727
$softDeletableMapping = $classMapping['gedmo']['soft_deleteable'] ?? null;
2828
if (! is_array($softDeletableMapping)) {
29-
return;
29+
return false;
3030
}
3131

3232
$args = $this->nodeFactory->createArgs($softDeletableMapping);
@@ -40,6 +40,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
4040
}
4141

4242
$class->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
43+
return true;
4344
}
4445

4546
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/ClassAttributeTransformer/TableClassAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public function __construct(
2424
) {
2525
}
2626

27-
public function transform(EntityMapping $entityMapping, Class_ $class): void
27+
public function transform(EntityMapping $entityMapping, Class_ $class): bool
2828
{
2929
$classMapping = $entityMapping->getClassMapping();
3030

3131
$table = $classMapping[self::TABLE_KEY] ?? null;
3232
if (isset($classMapping['type']) && $classMapping['type'] !== 'entity') {
33-
return;
33+
return false;
3434
}
3535

3636
$args = [];
@@ -42,6 +42,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
4242

4343
$this->addIndexes($classMapping['indexes'] ?? [], $class, MappingClass::INDEX);
4444
$this->addIndexes($classMapping['uniqueConstraints'] ?? [], $class, MappingClass::UNIQUE_CONSTRAINT);
45+
return true;
4546
}
4647

4748
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/ColumnAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public function __construct(
2020
) {
2121
}
2222

23-
public function transform(EntityMapping $entityMapping, Property|Param $property): void
23+
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
2424
{
2525
$propertyMapping = $entityMapping->matchFieldPropertyMapping($property);
2626
if ($propertyMapping === null) {
27-
return;
27+
return false;
2828
}
2929

3030
// handled in another mapper
@@ -42,6 +42,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
4242

4343
$args = array_merge($args, $this->nodeFactory->createArgs($propertyMapping));
4444
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
45+
return true;
4546
}
4647

4748
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/EmbeddedPropertyAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public function __construct(
2020
) {
2121
}
2222

23-
public function transform(EntityMapping $entityMapping, Property|Param $property): void
23+
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
2424
{
2525
$propertyMapping = $entityMapping->matchEmbeddedPropertyMapping($property);
2626
if ($propertyMapping === null) {
27-
return;
27+
return false;
2828
}
2929

3030
// handled in another attribute
@@ -34,6 +34,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
3434
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
3535

3636
NodeValueNormalizer::ensureKeyIsClassConstFetch($args, 'class');
37+
return true;
3738
}
3839

3940
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/GedmoTimestampableAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ public function __construct(
1919
) {
2020
}
2121

22-
public function transform(EntityMapping $entityMapping, Property|Param $property): void
22+
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
2323
{
2424
$fieldPropertyMapping = $entityMapping->matchFieldPropertyMapping($property);
2525

2626
$timestampableMapping = $fieldPropertyMapping['gedmo']['timestampable'] ?? null;
2727
if (! is_array($timestampableMapping)) {
28-
return;
28+
return false;
2929
}
3030

3131
$args = $this->nodeFactory->createArgs($timestampableMapping);
3232
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
33+
return true;
3334
}
3435

3536
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
final class IdAttributeTransformer implements PropertyAttributeTransformerInterface
1515
{
16-
public function transform(EntityMapping $entityMapping, Property|Param $property): void
16+
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
1717
{
1818
$idMapping = $entityMapping->matchIdPropertyMapping($property);
1919
if (! is_array($idMapping)) {
20-
return;
20+
return false;
2121
}
2222

2323
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName());
24+
return true;
2425
}
2526

2627
public function getClassName(): string

rules/CodeQuality/AttributeTransformer/PropertyAttributeTransformer/IdColumnAttributeTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
final class IdColumnAttributeTransformer implements PropertyAttributeTransformerInterface
1515
{
16-
public function transform(EntityMapping $entityMapping, Property|Param $property): void
16+
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
1717
{
1818
$idMapping = $entityMapping->matchIdPropertyMapping($property);
1919
if (! is_array($idMapping)) {
20-
return;
20+
return false;
2121
}
2222

2323
$args = [];
@@ -28,6 +28,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
2828
}
2929

3030
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
31+
return true;
3132
}
3233

3334
public function getClassName(): string

0 commit comments

Comments
 (0)