diff --git a/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/association_with_no_target_entity.php.inc b/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/association_with_no_target_entity.php.inc new file mode 100644 index 00000000..b7bb1b0f --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/association_with_no_target_entity.php.inc @@ -0,0 +1,41 @@ +trainings; + } +} + +?> +----- +trainings; + } +} + +?> diff --git a/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/no_collection_methods.php.inc b/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/no_collection_methods.php.inc new file mode 100644 index 00000000..0c1e6c1f --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/no_collection_methods.php.inc @@ -0,0 +1,39 @@ +id; + } +} + +?> +----- +id; + } +} + +?> diff --git a/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/with_other_non_collection_methods.php.inc b/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/with_other_non_collection_methods.php.inc new file mode 100644 index 00000000..24bf6d27 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector/Fixture/OneToMany/with_other_non_collection_methods.php.inc @@ -0,0 +1,76 @@ +$name = $value; + } + + public function __get($name) + { + return $this->$name; + } + + public function __isset($name) + { + return isset($this->$name); + } + + public function getTrainings(): Collection + { + return $this->trainings; + } +} + +?> +----- +$name = $value; + } + + public function __get($name) + { + return $this->$name; + } + + public function __isset($name) + { + return isset($this->$name); + } + + /** + * @return \Doctrine\Common\Collections\Collection + */ + public function getTrainings(): Collection + { + return $this->trainings; + } +} + +?> diff --git a/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php b/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php index bccb2696..522ea676 100644 --- a/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php +++ b/rules/CodeQuality/Rector/Class_/AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector.php @@ -98,7 +98,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node foreach ($node->getMethods() as $classMethod) { if ($this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($classMethod, $scope)) { - return null; + continue; } $property = $this->methodUniqueReturnedPropertyResolver->resolve($node, $classMethod); @@ -110,7 +110,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node $collectionObjectType = $this->getCollectionObjectTypeFromToManyAttribute($property); if (! $collectionObjectType instanceof FullyQualifiedObjectType) { - return null; + continue; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);