PHP code example of forrest79 / phpgsql-phpstan

1. Go to this page and download the library: Download forrest79/phpgsql-phpstan library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

forrest79 / phpgsql-phpstan example snippets


foreach ($someQuery as $row) {
    // here is $row as Forrest79\PhPgSql\Db\Row for PHPStan
    assert(is_dbrow($row));
    // here is as your custom row object
}

$row = $someQuery->select(['columnInt', 'columnString', 'columnFloat', 'columnDatetime'])->...->fetch();
$row->columnInt; // mixed for PHPStan
$row->columnString; // mixed for PHPStan
$row->columnFloat; // mixed for PHPStan
$row->columnDatetime; // mixed for PHPStan

assert(is_dbrow($row, ['columnInt' => '?int', 'columnString' => 'string', 'columnFloat' => 'float', 'columnDatetime' => \DateTime::class]));
$row->columnInt; // int or NULL for PHPStan
$row->columnString; // string for PHPStan
$row->columnFloat; // float for PHPStan
$row->columnDatetime; // \DateTime for PHPStan

foreach ($someQuery as $row) {
    // here is $row as Forrest79\PhPgSql\Db\Row for PHPStan
    /** @var DbRow $row */
    // here is as your custom row object
}