Open ArtemGoutsoul opened 10 months ago
I think db apis have subtle differences and therefore re-using a single extension is most of the time not possible.
but you could built your own PHPStan return type extension for your DBLayer, based on the API phpstan-dba provides you.
I use laminas-db (https://docs.laminas.dev/laminas-db/) wrapper, mostly with raw, dynamically assembled queries with different fetch modes, and it would be really cool if it was possible to infer result types for themn.
Here are some examples:
These methods could be configured similarly to the query syntax analysis: https://github.com/staabm/phpstan-dba/blob/main/docs/rules.md
Ideally the return type would be an intersection with the existing method type inferred by phpstan. That type is correct but too wide.