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
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<file>tests/Maker</file>

<rule ref="Doctrine">
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame" />
<!-- Allow short nullable syntax for non-union types -->
<exclude name="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat.DisallowedShortNullable" />
<exclude name="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat.DisallowedShortNullable" />
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ parameters:
excludePaths:
- tests/tmp

ignoreErrors:
- identifier: class.notFound
path: tests/MongoDB/__snapshots__/


includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
359 changes: 336 additions & 23 deletions src/Maker/MakeDocument.php

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/MongoDB/BaseCollectionRelation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBMakerBundle\MongoDB;

/** @internal */
abstract class BaseCollectionRelation extends BaseRelation
{
public function __construct(
string $propertyName,
string $targetClassName,
string|null $targetPropertyName = null,
bool $isSelfReferencing = false,
bool $mapInverseRelation = true,
bool $orphanRemoval = false,
) {
parent::__construct(
propertyName: $propertyName,
targetClassName: $targetClassName,
targetPropertyName: $targetPropertyName,
isSelfReferencing: $isSelfReferencing,
mapInverseRelation: $mapInverseRelation,
avoidSetter: true,
isCustomReturnTypeNullable: false,
customReturnType: 'Collection',
orphanRemoval: $orphanRemoval,
);
}
}
79 changes: 79 additions & 0 deletions src/MongoDB/BaseRelation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBMakerBundle\MongoDB;

/** @internal */
abstract class BaseRelation
{
public function __construct(
private string $propertyName,
private string $targetClassName,
private string|null $targetPropertyName = null,
private bool $isSelfReferencing = false,
private bool $mapInverseRelation = true,
private bool $avoidSetter = false,
private bool $isCustomReturnTypeNullable = false,
private string|null $customReturnType = null,
private bool $isOwning = false,
private bool $orphanRemoval = false,
private bool $isNullable = false,
) {
}

public function getPropertyName(): string
{
return $this->propertyName;
}

public function getTargetClassName(): string
{
return $this->targetClassName;
}

public function getTargetPropertyName(): string|null
{
return $this->targetPropertyName;
}

public function isSelfReferencing(): bool
{
return $this->isSelfReferencing;
}

public function getMapInverseRelation(): bool
{
return $this->mapInverseRelation;
}

public function shouldAvoidSetter(): bool
{
return $this->avoidSetter;
}

public function getCustomReturnType(): string|null
{
return $this->customReturnType;
}

public function isCustomReturnTypeNullable(): bool
{
return $this->isCustomReturnTypeNullable;
}

public function isOwning(): bool
{
return $this->isOwning;
}

public function getOrphanRemoval(): bool
{
return $this->orphanRemoval;
}

public function isNullable(): bool
{
return $this->isNullable;
}
}
Loading