Skip to content

Commit

Permalink
Merge AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRec…
Browse files Browse the repository at this point in the history
…tor to single rule (#331)
  • Loading branch information
TomasVotruba authored Jul 25, 2024
1 parent 8bcc255 commit d609a83
Show file tree
Hide file tree
Showing 21 changed files with 167 additions and 605 deletions.
35 changes: 6 additions & 29 deletions docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,26 @@
# 19 Rules Overview
# 18 Rules Overview

## AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector

Adds `@return` PHPDoc type to Collection property getter by *ToMany annotation
Adds `@return` PHPDoc type to Collection property getter by *ToMany annotation/attribute

- class: [`Rector\Doctrine\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector`](../rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector.php)

```diff
-use App\Entity\Training;
-
/**
* @ORM\Entity
*/
final class Trainer
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @ORM\OneToMany(targetEntity=Training::class)
*/
private $trainings;

+ /**
+ * @return \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source>
+ */
public function getTrainings()
{
return $this->trainings;
}
}
```

<br>

## AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector

Adds `@return` PHPDoc type to Collection property getter by *ToMany attribute

- class: [`Rector\Doctrine\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector`](../rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php)

```diff
#[ORM\Entity]
final class Trainer
{
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings;

+ /**
+ * @return \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>
+ * @return \Doctrine\Common\Collections\Collection<int, \App\Entity\Training>
+ */
public function getTrainings()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\ManyToMany;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training;

#[ORM\Entity]
final class Trainer
{
#[ORM\ManyToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings;

public function getTrainings(): Collection
{
return $this->trainings;
}
}

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

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Fixture\ManyToMany;
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\ManyToMany;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Source\Training;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training;

#[ORM\Entity]
final class Trainer
Expand All @@ -22,11 +22,11 @@ final class Trainer
-----
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Fixture\ManyToMany;
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\ManyToMany;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Source\Training;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training;

#[ORM\Entity]
final class Trainer
Expand All @@ -35,7 +35,7 @@ final class Trainer
private $trainings;

/**
* @return \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Source\Training>
* @return \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training>
*/
public function getTrainings(): Collection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Fixture\OneToMany;
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\OneToMany;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Source\Training;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training;

#[ORM\Entity]
final class Trainer
final class AttributeGetterWithReturnType
{
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings;
Expand All @@ -22,20 +22,20 @@ final class Trainer
-----
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Fixture\OneToMany;
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Fixture\OneToMany;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Source\Training;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training;

#[ORM\Entity]
final class Trainer
final class AttributeGetterWithReturnType
{
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings;

/**
* @return \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector\Source\Training>
* @return \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\AddReturnDocBlockToCollectionPropertyGetterByToManyAnnotationRector\Source\Training>
*/
public function getTrainings(): Collection
{
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d609a83

Please sign in to comment.