Download the PHP package forrest79/phpgsql-phpstan without Composer
On this page you can find all versions of the php package forrest79/phpgsql-phpstan. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phpgsql-phpstan
PhPgSql class reflection extension for PHPStan
Introduction
This extension defines dynamic methods and other PHPStan setting for Forrest79\PhPgSql
.
Installation
To use this extension, require it in Composer:
Using
Include extension.neon
in your project's PHPStan config:
If you're using your own Forrest79\PhPgSql\Db\Row
or Forrest79\PhPgSql\Fluen\Query
, you can set it likes this:
Or you can set just one extension:
-
for
PhPgSql\Db\Result
(for fetching the correctRow
object from fetch methods - unfortunatelyRow
iteration must be typed right in your code for now): -
for
PhPgSql\Fluent\QueryExecute
(for fetching the correctRow
object from fetch methods - unfortunatelyRow
iteration must be typed right in your code for now): - for
PhPgSql\Fluent\Complex
(to return rightQuery
inquery()
method):
You can also use simple Row
type narrowing function is_dbrow($row[, $expectedProperties])
. It returns bool
but it's recommended to use this always only with the assert()
function. This package will be probably missing in your production vendor so is_dbrow
function will be missing too and a PHP script will crash on this. With correct production settings for the assert()
function is calling is_dbrow()
omitted and your production code will be correct.
In PHP this function only checks if $row
is instance of Forrest79\PhPgSql\Db\Row
and if you specify $expectedProperties
(keys are column names and values are PHP types as string) it will check, if row has defined exactly expected columns (in PHP there is no types check, it's only for PHPStan).
The real magic is hidden in PHPStan extension. This function will narrow $row
type as Forrest79\PhPgSql\Db\Row
or your custom row object. And if you specify also properties, this will be correctly typed for PHPStan - originally all properties are mixed
.
To set only this extension use:
Or you can use simple DbRow
annotation.
Use DbRow
pseudo-type whenever you want, params, returns, vars...
To set only this extension use: