Skip to content

Commit 842aa94

Browse files
committed
skip refernce one as well in /TypedPropertyFromJMSSerializerAttributeTypeRector
1 parent fbc3df9 commit 842aa94

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rules-tests/TypeDeclaration/Rector/Class_/TypedPropertyFromJMSSerializerAttributeTypeRector/Fixture/skip_to_many.php.inc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ use JMS\Serializer\Annotation\Type;
66
use Rector\Tests\TypeDeclaration\Rector\Class_\TypedPropertyFromJMSSerializerAttributeTypeRector\Source\SomeClassInSerializer;
77
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
88

9-
final class SkipToMany
9+
final class SkipToManyAndToOne
1010
{
1111
#[Type(SomeClassInSerializer::class)]
1212
#[MongoDB\EmbedMany(targetDocument: SomeClassInSerializer::class)]
1313
private $someClasses;
14+
15+
#[Type('string')]
16+
#[MongoDB\ReferenceOne(targetDocument: SomeClassInSerializer::class)]
17+
private $someObject;
1418
}

rules/TypeDeclaration/Rector/Class_/TypedPropertyFromJMSSerializerAttributeTypeRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function refactor(Node $node): ?Node
105105
}
106106

107107
// this will be most likely collection, not single type
108-
if ($this->phpAttributeAnalyzer->hasPhpAttributes($property, CollectionMapping::TO_MANY_CLASSES)) {
108+
if ($this->phpAttributeAnalyzer->hasPhpAttributes($property, array_merge(CollectionMapping::TO_MANY_CLASSES, CollectionMapping::TO_ONE_CLASSES))) {
109109
continue;
110110
}
111111

0 commit comments

Comments
 (0)