Skip to content

Commit

Permalink
add fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 15, 2024
1 parent a241a58 commit 001b5fa
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\YamlToAttributeDoctrineMappingRector\Fixture;

final class IdMappingConstructor
{
public function __construct(
private $id,
) {
}
}

?>
-----
<?php

namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\YamlToAttributeDoctrineMappingRector\Fixture;

#[\Doctrine\ORM\Mapping\Table]
final class IdMappingConstructor
{
public function __construct(
#[\Doctrine\ORM\Mapping\Id]
#[\Doctrine\ORM\Mapping\Column(type: 'integer')]
#[\Doctrine\ORM\Mapping\GeneratedValue(strategy: 'AUTO')]
private $id,
) {
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ Rector\Doctrine\Tests\CodeQuality\Rector\Class_\YamlToAttributeDoctrineMappingRe
type: integer
generator:
strategy: auto

Rector\Doctrine\Tests\CodeQuality\Rector\Class_\YamlToAttributeDoctrineMappingRector\Fixture\IdMappingConstructor:
id:
id:
type: integer
generator:
strategy: auto
6 changes: 4 additions & 2 deletions src/NodeManipulator/ToManyRelationPropertyTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ private function processToManyRelation(
return $this->resolveTypeFromTargetEntity($targetEntityClass, $property);
}

private function resolveTypeFromTargetEntity(Expr|string $targetEntity, Property $property): Type
{
private function resolveTypeFromTargetEntity(
Expr|string $targetEntity,
Property|\PhpParser\Node\Param $property
): Type {
if ($targetEntity instanceof Expr) {
$targetEntity = $this->valueResolver->getValue($targetEntity);
}
Expand Down

0 comments on commit 001b5fa

Please sign in to comment.