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

Simplify blog example TypeRegistry #1287

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spawnia
Copy link
Collaborator

@spawnia spawnia commented Jan 24, 2023

No description provided.

'author' => [
'type' => Types::user(),
'type' => TypeRegistry::type(UserType::class),
Copy link
Contributor

@shmax shmax Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask what the motivation was to get rid of the Types helper? Personally, I kind of like the old pattern; I could right-click something like user and choose "Find usages" in my IDE to quickly see where it's being used (and possibly more importantly, you would get intellisense action when filling out a type field) . I suppose you can technically do the same thing with the class name, but you will get cross-pollution from the class itself, static usages, and so on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so you lose about a hundred lines of code, but you also lose some handy tooling. If your goal is just to drop lines of code, you could always tighten up Types.php. I use a similar pattern in my own code, and my Types.php looks like this:

    public static function action() : callable { return static::get(ActionType::class);}
    public static function actionSort() : callable { return static::get(ActionSortType::class);}
    public static function actions() : callable { return static::get(ActionsType::class);}
    public static function appraisal() : callable { return static::get(AppraisalType::class);}
    public static function appraisalSet() : callable { return static::get(AppraisalSetType::class);}

@spawnia spawnia added the docs label Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants