[PR #880] (v2.3.4) corrected inheritance when generating (updating) existing entities #8847

Closed
opened 2026-01-22 16:01:57 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/880

State: closed
Merged: No


I have modified the EntityGenerator-class so the script to generate entities takes inheritance of existing entities into account when generating getters and setters. This will only affect existing entities, not newly created.

The command 'orm:generate-entities' (and related symfony2 command 'doctrine:generate:entities') will now generate properties and methods in existing entitities that will not clash with those higher in the inheritance-chain. This effectively fixes the errors like 'PHP Fatal error: Access level to ... must be (protected|private|public) ...' after running the generate-entities command.

Basic rules added for updating existing entities if a property|method is found higher up the hierarchy:

  • when private higher up it will be copied into the child-entity,
  • when protected or public higher up it will be skipped

I have tested this with the command 'doctrine:generate:entities' on Symfony 2.3 with doctrine/orm v2.3.4. .

**Original Pull Request:** https://github.com/doctrine/orm/pull/880 **State:** closed **Merged:** No --- I have modified the EntityGenerator-class so the script to generate entities takes inheritance of existing entities into account when generating getters and setters. This will only affect existing entities, not newly created. The command 'orm:generate-entities' (and related symfony2 command 'doctrine:generate:entities') will now generate properties and methods in existing entitities that will not clash with those higher in the inheritance-chain. This effectively fixes the errors like 'PHP Fatal error: Access level to ... must be (protected|private|public) ...' after running the generate-entities command. Basic rules added for updating existing entities if a property|method is found higher up the hierarchy: - when private higher up it will be copied into the child-entity, - when protected or public higher up it will be skipped I have tested this with the command 'doctrine:generate:entities' on Symfony 2.3 with doctrine/orm v2.3.4. .
admin added the pull-request label 2026-01-22 16:01:57 +01:00
admin closed this issue 2026-01-22 16:01:58 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#8847