Skip to content

Commit bb2b845

Browse files
hembergerstaabm
andauthored
Implement RuntimeConfig->parameterTypeValidation('strict'|'lax') and use it in DoctrineKeyValueStyleRule (#563)
Co-authored-by: Markus Staab <[email protected]>
1 parent 0d7b290 commit bb2b845

13 files changed

+828
-242
lines changed

.phpstan-dba-mysqli.cache

Lines changed: 32 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.phpstan-dba-pdo-mysql.cache

Lines changed: 32 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/configuration.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ If not configured otherwise, the following defaults are used:
99
- when analyzing a php8.1+ codebase, [`mysqli_report(\MYSQLI_REPORT_ERROR | \MYSQLI_REPORT_STRICT);` error handling](https://www.php.net/mysqli_report) is assumed.
1010
- the fetch mode defaults to `QueryReflector::FETCH_TYPE_BOTH`, but can be configured using the [`defaultFetchMode`](https://github.com/staabm/phpstan-dba/tree/main/src/QueryReflection/RuntimeConfiguration.php) option.
1111
- read and write queries are analyzed per default. you may consider disable write query analysis using the [`analyzeWriteQueries`](https://github.com/staabm/phpstan-dba/tree/main/src/QueryReflection/RuntimeConfiguration.php) option.
12+
- When validating parameter types, the type inferred from the database may be narrower than the PHP type.
13+
For example, a `SMALLINT UNSIGNED` column has type `int<0, 65535>`, but you may be passing in a value that has type `int`.
14+
If you want this case to be an error, then use the configuration function `parameterTypeValidation('strict')`.
15+
Currently, this only applies to integer types in `DoctrineKeyValueStyleRule`, but may apply to additional rules and types in the future.

0 commit comments

Comments
 (0)