Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 1.93 KB

configuration.md

File metadata and controls

15 lines (13 loc) · 1.93 KB

Runtime configuration

Within your phpstan-dba-bootstrap.php file you can configure phpstan-dba so it knows about global runtime configuration state, which cannot be detect automatically. Use the RuntimeConfiguration builder-object and pass it as a second argument to QueryReflection::setupReflector().

If not configured otherwise, the following defaults are used:

  • type-inference works as precise as possible. In case your database access layer returns strings instead of integers and floats, use the stringifyTypes option.
  • when analyzing a php8+ codebase, PDO::ERRMODE_EXCEPTION error handling is assumed.
  • when analyzing a php8.1+ codebase, mysqli_report(\MYSQLI_REPORT_ERROR | \MYSQLI_REPORT_STRICT); error handling is assumed.
  • the fetch mode defaults to QueryReflector::FETCH_TYPE_BOTH, but can be configured using the defaultFetchMode option.
  • read and write queries are analyzed per default. you may consider disable write query analysis using the analyzeWriteQueries option.
  • When validating parameter types, the type inferred from the database may be narrower than the PHP type. For example, a SMALLINT UNSIGNED column has type int<0, 65535>, but you may be passing in a value that has type int. If you want this case to be an error, then use the configuration function parameterTypeValidation('strict'). Currently, this only applies to integer types in DoctrineKeyValueStyleRule, but may apply to additional rules and types in the future.