foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Make `Story::get()` static (implies `Story::load()->get()`)

Open kbond opened this issue 3 years ago • 3 comments

Instead of calling MyStory::load()->get('some-state'), can call MyStory::get('some-state'). This deprecates calling ->get() instance method.

kbond avatar Feb 10 '22 17:02 kbond

@wouterj, what do you think about this? There is now no longer a way to access story state items without loading the story. Do you think this is a problem?

kbond avatar Feb 10 '22 17:02 kbond

@wouterj, what do you think about this? There is now no longer a way to access story state items without loading the story. Do you think this is a problem?

I would ask this question the other way (and I'm sure you did already and know the answer, but I'm missing some context): What does this change solve?

Having a $story->get('countries') method with proper PHP declaration (and thus SA and auto completion) seems better than $story->countries() to me personally.

wouterj avatar Mar 04 '22 10:03 wouterj

What does this change solve?

This PR is purely a quality of life improvement:

- MyStory::load()->get('countries');
+ MyStory::get('countries');

Having a $story->get('countries') method with proper PHP declaration (and thus SA and auto completion) seems better than $story->countries() to me personally.

This PR doesn't change this ability. The idea is you'd add @method annotations to your story to help with autocompletion.

kbond avatar Mar 04 '22 13:03 kbond