Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Story::get() static (implies Story::load()->get()) #253

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

kbond
Copy link
Member

@kbond kbond commented Feb 10, 2022

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

@kbond kbond added the enhancement New feature or request label Feb 10, 2022
@kbond
Copy link
Member Author

kbond commented Feb 10, 2022

@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 kbond changed the title Make Story::get() static (implies Story::load()->get()`) Make Story::get() static (implies Story::load()->get()) Feb 10, 2022
@wouterj
Copy link
Contributor

wouterj commented Mar 4, 2022

@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.

@kbond
Copy link
Member Author

kbond commented Mar 4, 2022

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 kbond force-pushed the story-static-get branch 2 times, most recently from 245fe48 to 0eca1e9 Compare November 15, 2022 13:36
@kbond kbond requested a review from nikophil November 15, 2022 13:57
src/Story.php Show resolved Hide resolved
@kbond kbond merged commit 8332956 into zenstruck:1.x Nov 17, 2022
@kbond kbond deleted the story-static-get branch November 17, 2022 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants