Skip to content

Commit

Permalink
Merge pull request #8758 from greg0ire/restore-bc-for-annotations
Browse files Browse the repository at this point in the history
Restore bc for annotations
  • Loading branch information
greg0ire authored Jun 10, 2021
2 parents fc7db8f + 10e41ec commit 1518b40
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/Doctrine/ORM/Mapping/Embedded.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Deprecations\Deprecation;

/**
* @Annotation
Expand All @@ -39,6 +40,14 @@ final class Embedded implements Annotation

public function __construct(?string $class = null, $columnPrefix = null)
{
if ($class === null) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8753',
'Passing no class is deprecated.'
);
}

$this->class = $class;
$this->columnPrefix = $columnPrefix;
}
Expand Down
13 changes: 11 additions & 2 deletions lib/Doctrine/ORM/Mapping/ManyToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Deprecations\Deprecation;

/**
* @Annotation
Expand All @@ -31,7 +32,7 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class ManyToMany implements Annotation
{
/** @var string */
/** @var string|null */
public $targetEntity;

/** @var string */
Expand Down Expand Up @@ -61,14 +62,22 @@ final class ManyToMany implements Annotation
* @param array<string> $cascade
*/
public function __construct(
string $targetEntity,
?string $targetEntity = null,
?string $mappedBy = null,
?string $inversedBy = null,
?array $cascade = null,
string $fetch = 'LAZY',
bool $orphanRemoval = false,
?string $indexBy = null
) {
if ($targetEntity === null) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8753',
'Passing no target entity is deprecated.'
);
}

$this->targetEntity = $targetEntity;
$this->mappedBy = $mappedBy;
$this->inversedBy = $inversedBy;
Expand Down
9 changes: 9 additions & 0 deletions lib/Doctrine/ORM/Mapping/ManyToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Deprecations\Deprecation;

/**
* @Annotation
Expand Down Expand Up @@ -57,6 +58,14 @@ public function __construct(
string $fetch = 'LAZY',
?string $inversedBy = null
) {
if ($targetEntity === null) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8753',
'Passing no target entity is deprecated.'
);
}

$this->targetEntity = $targetEntity;
$this->cascade = $cascade;
$this->fetch = $fetch;
Expand Down

0 comments on commit 1518b40

Please sign in to comment.