Skip to content

Commit 667fee0

Browse files
committed
set customReturnType in the constructor
1 parent 929b460 commit 667fee0

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

src/Doctrine/BaseRelation.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
abstract class BaseRelation
1818
{
19-
private $customReturnType;
20-
2119
public function __construct(
2220
private ?string $propertyName = null,
2321
private ?string $targetClassName = null,
@@ -26,6 +24,7 @@ public function __construct(
2624
private bool $mapInverseRelation = true,
2725
private bool $avoidSetter = false,
2826
private bool $isCustomReturnTypeNullable = false,
27+
private ?string $customReturnType = null,
2928
) {
3029
// @TODO - triggers are tmp, do not merge w/ them in place.
3130
if (null === $this->propertyName) {
@@ -113,11 +112,4 @@ public function isCustomReturnTypeNullable(): bool
113112
{
114113
return $this->isCustomReturnTypeNullable;
115114
}
116-
117-
public function setCustomReturnType(string $customReturnType): self
118-
{
119-
$this->customReturnType = $customReturnType;
120-
121-
return $this;
122-
}
123115
}

src/Maker/MakeResetPassword.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,9 @@ private function generateRequestEntity(Generator $generator, ClassNameDetails $r
432432
targetClassName: $this->userClass,
433433
mapInverseRelation: false,
434434
avoidSetter: true,
435-
isCustomReturnTypeNullable: false
436-
))
437-
->setCustomReturnType('object')
438-
);
435+
isCustomReturnTypeNullable: false,
436+
customReturnType: 'object',
437+
)));
439438

440439
$this->fileManager->dumpFile($requestEntityPath, $manipulator->getSourceCode());
441440

src/Util/ClassSourceManipulator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,10 @@ private function addSingularRelation(BaseRelation $relation): void
579579

580580
$this->addGetter(
581581
$relation->getPropertyName(),
582-
$relation->getCustomReturnType() ?: $typeHint,
582+
$relation->getCustomReturnType() ?? $typeHint,
583583
// getter methods always have nullable return values
584584
// unless this has been customized explicitly
585-
$relation->getCustomReturnType() ? $relation->isCustomReturnTypeNullable() : true
585+
!$relation->getCustomReturnType() || $relation->isCustomReturnTypeNullable()
586586
);
587587

588588
if ($relation->shouldAvoidSetter()) {

0 commit comments

Comments
 (0)