Skip to content

Conversation

ollieread
Copy link
Contributor

This PR changes the typing of ColumnDefinition::storedAs() and ColumnDefinition::virtualAs() to include \Illuminate\Database\Query\Expression and not just string.

This has been done because ColumnDefinition::generatedAs() accepts the type string|\Illuminate\Database\Query\Expression, and after digging through the code that creates the columns, all three types are capable of handling expressions.

This is QOL PR that just makes Laravels typing a bit nicer to work with.

@crynobone
Copy link
Member

crynobone commented Mar 31, 2024

Any specific reason we type-hinting to implementation Illuminate\Database\Query\Expression instead of the interface Illuminate\Contracts\Database\Query\Expression?

@ollieread
Copy link
Contributor Author

Any specific reason we type-hinting to implementation Illuminate\Database\Query\Expression instead of the interface Illuminate\Contracts\Database\Query\Expression?

That's the value used by generatedAs(), which I suspect is a layover from when we didn't have the contract. I'll update.

@taylorotwell taylorotwell merged commit 175b0bb into laravel:11.x Apr 1, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants