|
| 1 | +## Issue |
| 2 | +<!-- |
| 3 | +Please add a short description of the current behavior (without your changes), |
| 4 | +i.e. " |
| 5 | + When setting the `phpType` column attribute to a PHP Enum, Perpl models try to instantiate the value |
| 6 | + with `new`. This leads to exceptions, since Enums have to be referenced as class constants or via `::from()`. |
| 7 | +"--> |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Changes |
| 12 | +<!-- |
| 13 | +Please add a short description of your changes, |
| 14 | +i.e. " |
| 15 | + This PR checks if `phpType` is an enum and instantiates those correctly. It affects loading from DB (hydrate()), |
| 16 | + writing to DB (getAccessValueStatement()) and applying default values. |
| 17 | +"--> |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +## Implementation Details |
| 22 | +<!-- |
| 23 | +Please add anything that helps us to reason about the changes (optional), |
| 24 | +i.e. " |
| 25 | + - I'm handling BackedEnum and UnitEnum as different cases, because of how different they are. Does that make sense? |
| 26 | + - Visibility of `FooClass::fooMethod()` was changed to public, so I can call it from `SomeOtherClass`. |
| 27 | +"--> |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +## Test strategy |
| 32 | +<!-- |
| 33 | +Your changes will have to pass static analysis, linter, and the test suite, and any added or changed behavior needs to be validated by tests, provided by your PR. |
| 34 | +
|
| 35 | +Please add a short description of the tests required to validate this PR, |
| 36 | +i.e. " |
| 37 | + - Added tests to check code output as string. |
| 38 | + - Runtime behavior is validated by creating dummy classes with QuickBuilder. |
| 39 | +
|
| 40 | + Not sure if this requires actual runtime tests against database? |
| 41 | +" |
| 42 | +
|
| 43 | + Find out more about test suite at https://perplorm.github.io/documentation/cookbook/working-with-test-suite.html |
| 44 | + |
| 45 | + You can run checks locally using the docker containers at https://github.com/perplorm/perpl-test-docker |
| 46 | +
|
| 47 | +--> |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +## Notes |
| 52 | +<!-- |
| 53 | +Remove if not needed, or add what you want to discuss. |
| 54 | +
|
| 55 | +!!! Thank you for contributing to Perpl !!! |
| 56 | +
|
| 57 | +Once submitted, we'll go through a review to get your changes merged as soon as possible. |
| 58 | +--> |
0 commit comments