Skip to content

Conversation

shmax
Copy link
Contributor

@shmax shmax commented Sep 3, 2023

In this PR I get static checking for Model::find_all... and Model::find_by... magic methods sort of working, in that they return array or singular results, respectively:

$book = Book::find_by_name("Walden"); // Book

$books = Book::find_all_by_name("Walden"); // array<Book>

There's a lot more to do, namely exception reporting, arguments, and so on, but this stuff isn't really documented very well on the phpstan side of things, and I don't really know what I'm doing, so I guess we'll see how much energy I have.

edit: I think I have the arguments static checking working as well as is possible, meaning I validate the number of arguments, but not the exact type (as that would require knowledge of the database schema).

@shmax shmax merged commit 68a1008 into master Sep 3, 2023
@shmax shmax deleted the dynamic-find-all branch September 3, 2023 16:17
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.

1 participant