-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate annotations to attributes in fixtures
- Loading branch information
Showing
7 changed files
with
54 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,43 +13,26 @@ | |
namespace Tests\Fixtures\AppBundle\Entity; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\GeneratedValue; | ||
use Doctrine\ORM\Mapping\Id; | ||
use Doctrine\ORM\Mapping\OneToMany; | ||
|
||
/** | ||
* Company. | ||
* | ||
* @author Niels Keurentjes <[email protected]> | ||
* | ||
* @ORM\Entity | ||
*/ | ||
#[Entity] | ||
class Company | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Column(type="integer", nullable=false) | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="IDENTITY") | ||
*/ | ||
private $id; | ||
#[Id, GeneratedValue(strategy: 'IDENTITY'), Column] | ||
private int $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", nullable=false) | ||
*/ | ||
private $name; | ||
#[Column] | ||
private string $name; | ||
|
||
/** | ||
* @var ArrayCollection|array | ||
* | ||
* @ORM\OneToMany(targetEntity="Employee", mappedBy="company") | ||
*/ | ||
private $employees; | ||
/** @var Collection<Employee> */ | ||
#[OneToMany(mappedBy: 'company', targetEntity: Employee::class)] | ||
private Collection $employees; | ||
|
||
/** | ||
* Company constructor. | ||
*/ | ||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
|
@@ -67,17 +50,14 @@ public function getName(): string | |
} | ||
|
||
/** | ||
* @return Person[]|ArrayCollection | ||
* @return Collection<Employee> | ||
*/ | ||
public function getEmployees() | ||
public function getEmployees(): Collection | ||
{ | ||
return $this->employees; | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function setName(string $name): Company | ||
public function setName(string $name): static | ||
{ | ||
$this->name = $name; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,43 +12,29 @@ | |
|
||
namespace Tests\Fixtures\AppBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\ManyToOne; | ||
|
||
/** | ||
* Employee. | ||
* | ||
* @author Niels Keurentjes <[email protected]> | ||
* | ||
* @ORM\Entity | ||
*/ | ||
#[Entity] | ||
class Employee extends Person | ||
{ | ||
/** | ||
* @var \DateTime | ||
* | ||
* @ORM\Column(type="datetime", nullable=true) | ||
*/ | ||
private $employedSince; | ||
|
||
/** | ||
* @var Company | ||
* | ||
* @ORM\ManyToOne(targetEntity="Company", inversedBy="employees") | ||
*/ | ||
private $company; | ||
|
||
/** | ||
* Person constructor. | ||
*/ | ||
public function __construct(string $firstName, string $lastName, \DateTime $employedSince = null, Company $company) | ||
#[Column(type: Types::DATETIME_MUTABLE, nullable: true)] | ||
private ?\DateTime $employedSince; | ||
|
||
#[ManyToOne(targetEntity: Company::class, inversedBy: 'employees')] | ||
private Company $company; | ||
|
||
public function __construct(string $firstName, string $lastName, ?\DateTime $employedSince, Company $company) | ||
{ | ||
parent::__construct($firstName, $lastName); | ||
|
||
$this->company = $company; | ||
$this->employedSince = $employedSince; | ||
} | ||
|
||
public function getEmployedSince() | ||
public function getEmployedSince(): \DateTime | ||
{ | ||
return $this->employedSince; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,44 +12,24 @@ | |
|
||
namespace Tests\Fixtures\AppBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\GeneratedValue; | ||
use Doctrine\ORM\Mapping\Id; | ||
use Doctrine\ORM\Mapping\InheritanceType; | ||
|
||
/** | ||
* Person. | ||
* | ||
* @author Niels Keurentjes <[email protected]> | ||
* | ||
* @ORM\Entity | ||
* @ORM\InheritanceType("JOINED") | ||
*/ | ||
#[Entity, InheritanceType('JOINED')] | ||
class Person | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Column(type="integer", nullable=false) | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="IDENTITY") | ||
*/ | ||
private $id; | ||
#[Id, GeneratedValue(strategy: 'IDENTITY'), Column] | ||
private int $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", nullable=false) | ||
*/ | ||
private $firstName; | ||
#[Column] | ||
private string $firstName; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", nullable=false) | ||
*/ | ||
private $lastName; | ||
#[Column] | ||
private string $lastName; | ||
|
||
/** | ||
* Person constructor. | ||
*/ | ||
public function __construct(string $firstName, string $lastName) | ||
{ | ||
$this->firstName = $firstName; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters