maker-bundle: [private $__EXTRA__LINE;]? Add field to related entity produces invalid code.

Made an entity with ManyToOne, and the generated code on the One-side looks like this:

...
private $__EXTRA__LINE;
  /**
   * @ORM\OneToMany(targetEntity="App\Entity\BusinessDay", mappedBy="shop", orphanRemoval=true)
   */
  private $businessDays;
...

private $__EXTRA__LINE;
  /**
   * @return Collection|BusinessDay[]
   */
  public function getBusinessDays(): Collection
  {
      return $this->businessDays;
  }
  private $__EXTRA__LINE;
  public function addBusinessDay(BusinessDay $businessDay): self
  {
      if (!$this->businessDays->contains($businessDay)) {
          $this->businessDays[] = $businessDay;
          $businessDay->setShop($this);
      }
      $__EXTRA__LINE;
      return $this;
  }
  private $__EXTRA__LINE;
  public function removeBusinessDay(BusinessDay $businessDay): self
  {
      if ($this->businessDays->contains($businessDay)) {
          $this->businessDays->removeElement($businessDay);
          // set the owning side to null (unless already changed)
          if ($businessDay->getShop() === $this) {
              $businessDay->setShop(null);
          }
      }
      $__EXTRA__LINE;
      return $this;
  }

Here’s what I did:

$ php bin/console make:entity

 Class name of the entity to create or update (e.g. BravePuppy):
 > BusinessDay
BusinessDay

 created: src/Entity/BusinessDay.php
 created: src/Repository/BusinessDayRepository.php

 Entity generated! Now let's add some fields!
 You can always add more fields later manually or by re-running this command.

 New property name (press <return> to stop adding fields):
 > shop

 Field type (enter ? to see all types) [string]:
 > ManyToOne
ManyToOne

 What class should this entity be related to?:
 > Shop
Shop

 Is the BusinessDay.shop property allowed to be null (nullable)? (
yes/no) [yes]:
 > no

 Do you want to add a new property to Shop so that you can access/update Bus
inessDay objects from it - e.g. $shop->getBusinessDays()? (yes/no) [yes
]:
 >

 A new property will also be added to the Shop class so that you can access the related Business
...
 New field name inside Shop [businessDays]:
 >

 Do you want to activate orphanRemoval on your relationship?
 A BusinessDay is "orphaned" when it is removed from its related Shop.
 e.g. $shop->removeBusinessDay($businessDay)

 NOTE: If a BusinessDay may *change* from one Shop to another, answer "no".

 Do you want to automatically delete orphaned App\Entity\BusinessDay objects (orphanRe
moval)? (yes/no) [no]:
 > yes

 updated: src/Entity/BusinessDay.php
 updated: src/Entity/Shop.php

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I have the same issue. Can provide info if necessary.