-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathphpstan-dba-bootstrap.php
More file actions
30 lines (23 loc) · 960 Bytes
/
Copy pathphpstan-dba-bootstrap.php
File metadata and controls
30 lines (23 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
use staabm\PHPStanDba\QueryReflection\MysqliQueryReflector;
use staabm\PHPStanDba\QueryReflection\RuntimeConfiguration;
use staabm\PHPStanDba\QueryReflection\QueryReflection;
use staabm\PHPStanDba\QueryReflection\RecordingQueryReflector;
use staabm\PHPStanDba\QueryReflection\ReflectionCache;
use Symfony\Component\Dotenv\Dotenv;
require_once __DIR__ . '/vendor/autoload.php';
$cacheFile = __DIR__.'/.phpstan-dba.cache';
(new Dotenv())->bootEnv(__DIR__ .'/.env', 'test');
$config = new RuntimeConfiguration();
$config->debugMode(true);
$config->stringifyTypes(true); // TODO remove when upgrading to PHP 8.1
$dsn = parse_url($_SERVER['DATABASE_URL']);
QueryReflection::setupReflector(
new RecordingQueryReflector(
ReflectionCache::create(
$cacheFile
),
new MysqliQueryReflector(new mysqli($dsn['host'], $dsn['user'], $dsn['pass'] ?? '', trim($dsn['path'], '/'), $dsn['port'] ?? 3306))
),
$config
);