symfony / symfony/maker-bundle

Maker Bundle fails to create ManyToOne relation

Open
#535 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.4k
Forks
427
Avg merge
2d 22h
Merged PRs (30d)
20

Description

Originally posted by @Aracon in https://github.com/symfony/maker-bundle/issues/329#issuecomment-580379873
(Creating new issue because can't reopen existing one.)

Here is the console log:

>php bin/console make:entity

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

 Your entity already exists! So let's add some new fields!

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

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

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

What type of relationship is this?
 ------------ --------------------------------------------------------------------------------
  Type         Description

 ------------ --------------------------------------------------------------------------------
  ManyToOne    Each TransportCostRule relates to (has) one Setting.

               Each Setting can relate to (can have) many TransportCostRule objects


  OneToMany    Each TransportCostRule can relate to (can have) many Setting objects.
               Each Setting relates to (has) one TransportCostRule



  ManyToMany   Each TransportCostRule can relate to (can have) many Setting objects.
               Each Setting can also relate to (can also have) many TransportCostRule objects


  OneToOne     Each TransportCostRule relates to (has) exactly one Setting.

               Each Setting also relates to (has) exactly one TransportCostRule.

 ------------ --------------------------------------------------------------------------------

 Relation type? [ManyToOne, OneToMany, ManyToMany, OneToOne]:
 > ManyToOne

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

 Do you want to add a new property to Setting so that you can access/update TransportCostRule objects from it - e.g. $setting->getTransportCostRules()? (yes/no) [yes]:
 >

 A new property will also be added to the Setting class so that you can access the related TransportCostRule objects from it.

 New field name inside Setting [transportCostRules]:
 >

 Do you want to activate orphanRemoval on your relationship?
 A TransportCostRule is "orphaned" when it is removed from its related Setting.
 e.g. $setting->removeTransportCostRule($transportCostRule)

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

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


In ParserAbstract.php line 315:

  Syntax error, unexpected T_VARIABLE, expecting '(' on line 61


make:entity [-a|--api-resource] [--regenerate] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<name>]

Entity: https://gist.github.com/Aracon/418af4c405bee420cb6aafaf5fcd87ff
Related entity: https://gist.github.com/Aracon/9c1d15391041fc4e6010a88af6b8b727
composer.lock: https://gist.github.com/Aracon/31c77c7ffce6fb6928e48952f6afd4ef

PHP 7.2.10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported make:entity ManyToOne workflow with the linked entity examples and inspect the failure reported at ParserAbstract.php line 315. Compare the generated entity output with the PHP 7.2.10 syntax error, then verify that creating the relation with orphanRemoval completes without a parse error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, cli, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.