KarlComSe /
mvc-report
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Entity; |
||
| 4 | |||
| 5 | use ApiPlatform\Metadata\ApiResource; |
||
| 6 | use App\Repository\JournalRepository; |
||
| 7 | use Doctrine\Common\Collections\ArrayCollection; |
||
| 8 | use Doctrine\Common\Collections\Collection; |
||
| 9 | use Doctrine\DBAL\Types\Types; |
||
| 10 | use Doctrine\ORM\Mapping as ORM; |
||
| 11 | |||
| 12 | #[ORM\Entity(repositoryClass: JournalRepository::class)] |
||
| 13 | #[ApiResource] |
||
| 14 | class Journal |
||
| 15 | { |
||
| 16 | #[ORM\Id] |
||
| 17 | #[ORM\GeneratedValue] |
||
| 18 | #[ORM\Column] |
||
| 19 | private ?int $id = null; |
||
| 20 | |||
| 21 | #[ORM\Column(type: Types::DATE_MUTABLE)] |
||
| 22 | private ?\DateTimeInterface $FirstDay = null; |
||
| 23 | |||
| 24 | #[ORM\Column(type: Types::DATE_MUTABLE)] |
||
| 25 | private ?\DateTimeInterface $LastDay = null; |
||
| 26 | |||
| 27 | #[ORM\Column(length: 255, nullable: true)] |
||
| 28 | private ?string $ChartOfAccount = null; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var Collection<int, JournalEntry> |
||
| 32 | */ |
||
| 33 | #[ORM\OneToMany(targetEntity: JournalEntry::class, mappedBy: 'Journal', orphanRemoval: true)] |
||
| 34 | private Collection $journalEntries; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var Collection<int, Organization> |
||
| 38 | */ |
||
| 39 | #[ORM\ManyToOne(targetEntity: Organization::class, inversedBy: 'journals')] |
||
| 40 | private ?Organization $organization = null; |
||
| 41 | |||
| 42 | public function __construct() |
||
| 43 | { |
||
| 44 | $this->journalEntries = new ArrayCollection(); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getId(): ?int |
||
| 48 | { |
||
| 49 | return $this->id; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getFirstDay(): ?\DateTimeInterface |
||
| 53 | { |
||
| 54 | return $this->FirstDay; |
||
| 55 | } |
||
| 56 | |||
| 57 | public function setFirstDay(\DateTimeInterface $FirstDay): static |
||
| 58 | { |
||
| 59 | $this->FirstDay = $FirstDay; |
||
| 60 | |||
| 61 | return $this; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function getLastDay(): ?\DateTimeInterface |
||
| 65 | { |
||
| 66 | return $this->LastDay; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function setLastDay(\DateTimeInterface $LastDay): static |
||
| 70 | { |
||
| 71 | $this->LastDay = $LastDay; |
||
| 72 | |||
| 73 | return $this; |
||
| 74 | } |
||
| 75 | |||
| 76 | public function getChartOfAccount(): ?string |
||
| 77 | { |
||
| 78 | return $this->ChartOfAccount; |
||
| 79 | } |
||
| 80 | |||
| 81 | public function setChartOfAccount(?string $ChartOfAccount): static |
||
| 82 | { |
||
| 83 | $this->ChartOfAccount = $ChartOfAccount; |
||
| 84 | |||
| 85 | return $this; |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @return Collection<int, JournalEntry> |
||
| 90 | */ |
||
| 91 | public function getJournalEntries(): Collection |
||
| 92 | { |
||
| 93 | return $this->journalEntries; |
||
| 94 | } |
||
| 95 | |||
| 96 | public function addJournalEntry(JournalEntry $journalEntry): static |
||
| 97 | { |
||
| 98 | if (!$this->journalEntries->contains($journalEntry)) { |
||
| 99 | $this->journalEntries->add($journalEntry); |
||
| 100 | $journalEntry->setJournal($this); |
||
| 101 | } |
||
| 102 | |||
| 103 | return $this; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function removeJournalEntry(JournalEntry $journalEntry): static |
||
| 107 | { |
||
| 108 | if ($this->journalEntries->removeElement($journalEntry)) { |
||
| 109 | // set the owning side to null (unless already changed) |
||
| 110 | if ($journalEntry->getJournal() === $this) { |
||
| 111 | $journalEntry->setJournal(null); |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | return $this; |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @return Collection<int, Organization> |
||
| 120 | */ |
||
| 121 | public function getOrganization(): Collection |
||
| 122 | { |
||
| 123 | return $this->organization; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 124 | } |
||
| 125 | |||
| 126 | public function setOrganization(?Organization $organization): void |
||
| 127 | { |
||
| 128 | $this->organization = $organization; |
||
|
0 ignored issues
–
show
It seems like
$organization can also be of type App\Entity\Organization. However, the property $organization is declared as type Doctrine\Common\Collections\Collection. Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
| 129 | } |
||
| 130 | } |
||
| 131 |