Skip to content

Make "Preserve" a core feature

When I want to preserve a method, I have to call ->with(preserveAnotatedMethods()) to allow such behavior. Which is weird because you need to turn something on to turn something on. This scenario happens to me from time to time:

  • write a .definition.php
    return valueObject(Something::class, [
      'field' => 'string',
    ]);
  • run it
  • annotate #[Preserve] and make changes
  • run definition again to check it survived
  • preserved methods are gone because of forgotten ->with(preserveAnotatedMethods()) call

Of course, valueObject() could contain preserveAnotatedMethods() (and it does), however I've still experienced this few times as I don't work only with valueObject().

As this would be backwards compatible change (only methods annotated with that attribute will be preserved), I can see no reason why it has to be applied explicitely.

Any opinions? @jkuchar1 @jpudil

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information