phpstan-dba static analysis
PHPStan based SQL static analysis and type inference for the database access layer.
phpstan-dba
makes your phpstan static code analysis jobs aware of datatypes within your database.
With this information at hand we are able to detect type inconsistencies between your domain model and database-schema.
Additionally errors in code handling the results of sql queries can be detected.
This extension provides the following features, as long as you stick to the rules:
- result set type-inference
- detect errors in sql queries
- detect placeholder/bound value mismatches
- query plan analysis to detect performance issues
- builtin support for
doctrine/dbal
,mysqli
, andPDO
- API to configure the same features for your custom sql based database access layer
Note: At the moment only MySQL/MariaDB and PGSQL databases are supported. Technically it’s not a big problem to support other databases though.
DEMO
see the ‘Files Changed’ tab of the DEMO-PR for a quick glance.
Installation
see the phpstan-dba GitHub Repository for usage instructions and setup.
💌 Support phpstan-dba
Consider supporting the project, so we can make this tool even better even faster for everyone.
Found a bug? Please help improve this article.