staabm / phpstan-dba

PHPStan based SQL static analysis and type inference for the database access layer
https://staabm.github.io/archive.html#phpstan-dba
MIT License
250 stars 17 forks source link

PDO: support more fetch modes #269

Open staabm opened 2 years ago

staabm commented 2 years ago

See

relevant in

relevant code parts: https://github.com/staabm/phpstan-dba/blob/4d442193a977424c78dc66de0ca65e50d84b40ff/src/PdoReflection/PdoStatementReflection.php#L49-L55 https://github.com/staabm/phpstan-dba/blob/4d442193a977424c78dc66de0ca65e50d84b40ff/src/PdoReflection/PdoStatementReflection.php#L96-L121

and adding corresponding tests in
https://github.com/staabm/phpstan-dba/blob/main/tests/default/data/pdo.php

Seldaek commented 2 years ago

PDO::FETCH_CLASS support would also be nice IMO

staabm commented 2 years ago

@xPaw since you are using some fetch types we do not yet support type-inference for: do you plan working on the missing fetch-modes?

I will support you in case there are questions left.

xPaw commented 2 years ago

I don't currently have plans to look into that, sorry.

xPaw commented 2 years ago

One thing worth pointing out is that some of the FETCH constants are actually flags, and not unique modes (thus they can be combined with some modes).

See here: https://github.com/php/php-src/blob/bf9b774327f139f5770ea87797b933b603f979de/ext/pdo/php_pdo_driver.h#L65-L87

staabm commented 2 years ago

One thing worth pointing out is that some of the FETCH constants are actually flags, and not unique modes (thus they can be combined with some modes).

good point.

feel free to provide failing unit tests or open issues with concrete examples of things you used/found in the wild.

I am not interessted in adding every theoretical possible combination, but just those things people actually use