Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6a5b8bd

Browse files
committedJun 4, 2024·
QueryResultTypeWalker: precise type inferring
1 parent dd71401 commit 6a5b8bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2403
-428
lines changed
 

Diff for: ‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ $query->getOneOrNullResult(Query::HYDRATE_OBJECT); // User
152152

153153
This is due to the design of the `Query` class preventing from determining the hydration mode used by these functions unless it is specified explicitly during the call.
154154

155+
### Expression types inferring
156+
157+
Whether `MAX(e.id)` is fetched as `string` or `int` highly [depends on drivers, their setup and PHP version](https://github.com/janedbal/php-database-drivers-fetch-test).
158+
This extension copies the logic from linked analysis, autodetects your setup and provides accurate results for `pdo_mysql`, `mysqli`, `pdo_sqlite`, `sqlite3`, `pdo_pgsql` and `pgsql`.
159+
Any other driver will result in union with stringified version, e.g. `numeric-string|int`.
160+
155161
### Problematic approaches
156162

157163
Not every QueryBuilder can be statically analysed, here are few advices to maximize type inferring:

Diff for: ‎phpstan.neon

+8
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ parameters:
4949
- '#^Cannot call method getWrappedResourceHandle\(\) on class\-string\|object\.$#'
5050
path: tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php
5151
reportUnmatched: false
52+
-
53+
message: '#^Call to function method_exists\(\) with Doctrine\\DBAL\\Connection and ''getNativeConnection'' will always evaluate to true\.$#' # needed for older DBAL versions
54+
path: src/Type/Doctrine/Query/QueryResultTypeWalker.php
55+
-
56+
messages: # needed for older DBAL versions (fails only on PHP 7.3)
57+
- '#^Class Doctrine\\DBAL\\Driver\\PgSQL\\Driver not found\.$#'
58+
- '#^Class Doctrine\\DBAL\\Driver\\SQLite3\\Driver not found\.$#'
59+
path: src/Type/Doctrine/Query/QueryResultTypeWalker.php

0 commit comments

Comments
 (0)
Please sign in to comment.