Commit d6d0391
committed
feature #104 make:entity improved: interactive field created & entity update support (weaverryan)
This PR was squashed before being merged into the 1.0-dev branch (closes #104).
Discussion
----------
make:entity improved: interactive field created & entity update support
Hi guys!
The PR we (or at least me) have been waiting for :). This makes `make:entity` behave similar to `doctrine:generate:entity` from SensioGeneratorBundle: it interactively asks you for the field names and generates the getters/setters... but with some improved UX.
## Features:
* Ability to create new entities & fields
* Ability to update *existing* entities 🎆
* Support for adding *relations* (double 🎆)
* A `--regenerate` flag to add getters/setters for existing properties (replaces `doctrine:generate:entities`)
* Generates code that passes phpcs
Please help test! It's easy: [composer require details to for testing](https://gist.github.com/weaverryan/a20fc281ccd1faea2ea04a5da7fdaa55)
## Blocker 😢
We're using the newest version of `nikic/php-parser` heavily... but it only has a *beta* release so far :(. We need to wait until this is stable. OR, we need to remove it as a dependency temporarily, then throw an error to tell people to install it manually (at the beta version). :/ nikic/PHP-Parser#474
## Important notes:
* I bumped the min php version to 7.1 (from 7.0). This was so that we could consistently generated code using nullable types.
* Some of the code generated for relationships is opinionated. For example, I automatically synchronize (i.e. by calling the setter) the *owning* side if you set data on the inverse side of the relation. I also make all relation return types nullable (even if the relation is required in the db), to be friendly in case they're not set yet.
* The setters are not fluent. We *could* make them fluent, or make that an option on the bundle (i.e. one in a config file, not asked interactively)

If you want to see the available type list (relations are now in this list, but not shown):
<img width="535" alt="screen shot 2018-01-08 at 3 09 32 pm" src="https://user-images.githubusercontent.com/121003/34690183-21f7498e-f486-11e7-9fcf-a5fe56d2a321.png">
I would love feedback! I added many little "features" to make the user experience as excellent as possible. But, I need users to help validate that!
Cheers!
Commits
-------
16596b1 updating tests for removed comment
01f6a3c Fixing a bug where a repository would not be generated under certain conditions
2f0e0f3 adding support for associative arrays in annotations
7d3042c Fixing bug where the name was always interactive
2a72ee3 Fixing cs
3b65fb6 Merge branch 'master' into make-entity-improved
e54988c Fixing issue where sometimes nullable is not defined on a join column
259141d removing comment - it does not add much value & is hard to keep in the right place
b0fed52 updating to stable nickic/php-parser 4.0 release!
7bcc966 Disabling replaceNodes to avoid possible AST accidental changes
613abef Adding an option (true by default) for fluent setter methods
8634a91 cs
9261cd1 Adding the "length" question for the string type
9c5a786 phpcs
328e486 fixing windows bug
92aeff5 playing with appveyor
b3647d7 attempting to split tests to combat windows testing issue
f022f5f Fixed window path bug while looking for the vendor/ dir
89d5708 trying to fix windows tests with long paths that cause errors :/
fd088ac temporarily debugging Windows errors
35ef3ae removing duplicate sqlite extension for appveyor
8c37893 Making appveyor use sqlite for simplicity
abbe8d9 Fixing windows bug where C:/ slash may already be normalized
20df636 Fixing a few Windows bugs
f9fa0db adding missing success message
38e6a0e Fixing missing return on --regenerate
1650301 Fixing missing method
fb74302 Fixing typo for class name
9c40654 added missing service
866e534 Extracting logic into AutoloaderUtil
05480da Fixing bug where new classes were never actually written in regenerator
e535f0d Adding an error if you try to generate a class that does not use annotation metadata
656c199 Fixing 2 merge bugs: entities could not be updated & mix up of entity vs repo class name
8d400e7 Fixing bug with getting property of classes just created
e8e5689 fix arg name
b8856c0 Code changes to sync with upstream updates
4afbc0e removing dup functions after merge
a34a1a2 Fixing "composer require orm orm" bug
5bc34bd removing unused use
d34ff45 also run phpcs on updated files
f370b52 fixing tests
5395788 Not setting the owning side (from inverse) on OneToOne
922563a clarifying note
ab03675 fixing missing return type
cf9e08a making decimal/scale more clear
0f2d52d Removing unnecessary service locator: just let the registry be null
1f57317 minor tweaks
d65d772 Fixing some tests
a822400 adding missing headers
dc7973d Fixing tests + one missing return
c3ccf5f Ask the user if they want the inverse side of a relation
2fd2e0c Making the user message a little nicer
663afee test needs database
c79b73c Fixes thanks to Stof!
6c914fa Removing debugging code, committing missing file to fix tests
4bde1dc With --overwrite, put updated methods in same location as original
ed15a2b temp debugging code for failing test on CI
dbe11a5 hack to fix tests temporarily
cd4f517 Fixing possible non-existent directory in tests
e52e33e Adding an enhanced make:entity commandFile tree
128 files changed
+7502
-214
lines changed- src
- Doctrine
- Maker
- Resources
- config
- doc
- help
- skeleton
- doctrine
- Test
- Util
- tests
- Doctrine
- fixtures
- expected_no_overwrite/src/Entity
- expected_overwrite/src/Entity
- expected_xml/src
- Entity
- Repository
- source_project/src/Entity
- xml_source_project
- config/doctrine
- src/Entity
- Maker
- Util
- fixtures
- add_entity_field
- add_getter
- add_many_to_many_relation
- add_many_to_one_relation
- add_one_to_many_relation
- add_one_to_one_relation
- add_property
- add_setter
- source
- fixtures
- MakeEntityManyToMany
- src/Entity
- tests
- MakeEntityManyToOneNoInverse
- src/Entity
- tests
- MakeEntityManyToOne
- src/Entity
- tests
- MakeEntityOneToMany
- src/Entity
- tests
- MakeEntityOneToOne
- src/Entity
- tests
- MakeEntityOverwrite
- src/Entity
- tests
- MakeEntityRegenerateOverwrite
- src/Entity
- tests
- MakeEntityRegenerateXml
- config/doctrine
- src/Entity
- tests
- MakeEntityRegenerate
- src/Entity
- tests
- MakeEntityRelationVendorTarget
- src/Entity
- vendor/some-vendor/src
- MakeEntityUpdate
- src/Entity
- tests
- MakeEntityXmlMappingError
- config/doctrine
- src/Entity
- MakeEntity/tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
128 files changed
+7502
-214
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 61 | + | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
| |||
74 | 72 | | |
75 | 73 | | |
76 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
77 | 99 | | |
78 | 100 | | |
79 | 101 | | |
| |||
0 commit comments