Skip to content

Conversation

onairmarc
Copy link

This PR adds backed enum support to Inertia::render() through the ResponseFactory class.

The render method now first checks if the $component parameter is an instance of BackedEnum. If $component is not a BackedEnum, the method continues as normal. If $component is a BackedEnum, it then checks to ensure that the backing value is a string. If the backing value is a string, the method continues as normal. If the backing value is not a string, the method throws an InvalidArgumentException with a message stating the accepted argument types.

@onairmarc
Copy link
Author

@joetannenbaum can this PR please get some love? 🤓

@pascalbaljet
Copy link
Member

I like it, but it's a breaking change for people who are extending ResponseFactory and overriding the render() method. I think the only safe way is to remove the type hint altogether and rely on a docblock.

@onairmarc
Copy link
Author

@pascalbaljet I just removed the type hint in favor to the docblock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants