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
@@ -0,0 +1,44 @@
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromToManyRelationTypeRector\Fixture\ODM;

use Doctrine\Common\Collections\ArrayCollection;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromToManyRelationTypeRector\Source\TrainingTerm;

final class ODMEmbedMany
{
/**
* @\Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedMany(targetDocument="TrainingTerm")
*/
private $trainingTerms;

public function __construct()
{
$this->trainingTerms = new ArrayCollection();
}
}

?>
-----
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromToManyRelationTypeRector\Fixture\ODM;

use Doctrine\Common\Collections\ArrayCollection;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromToManyRelationTypeRector\Source\TrainingTerm;

final class ODMEmbedMany
{
/**
* @\Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedMany(targetDocument="TrainingTerm")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromToManyRelationTypeRector\Source\TrainingTerm>
*/
private \Doctrine\Common\Collections\Collection $trainingTerms;

public function __construct()
{
$this->trainingTerms = new ArrayCollection();
}
}

?>
1 change: 1 addition & 0 deletions rules/CodeQuality/Enum/CollectionMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class CollectionMapping
MappingClass::ONE_TO_MANY,
MappingClass::MANY_TO_MANY,
OdmMappingClass::REFERENCE_MANY,
OdmMappingClass::EMBED_MANY,
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
'Complete @var annotations or types based on @ORM\*toMany annotations or attributes',
'Complete Collection @var annotations and property type declarations, based on @ORM\*toMany and @ODM\*toMany annotations or attributes',
[
new CodeSample(
<<<'CODE_SAMPLE'
Expand All @@ -58,14 +58,15 @@ class SimpleColumn
,
<<<'CODE_SAMPLE'
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;

class SimpleColumn
{
/**
* @ORM\OneToMany(targetEntity="App\Product")
* @var \Doctrine\Common\Collections\Collection<int, \App\Product>
* @var Collection<int, \App\Product>
*/
private \Doctrine\Common\Collections\Collection $products;
private Collection $products;
}
CODE_SAMPLE
),
Expand Down
2 changes: 2 additions & 0 deletions src/Enum/OdmMappingClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ final class OdmMappingClass
* @var string
*/
public const REFERENCE_MANY = 'Doctrine\ODM\MongoDB\Mapping\Annotations\ReferenceMany';

public const EMBED_MANY = 'Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedMany';
}
Loading