|
1 | 1 | <?php |
2 | 2 |
|
3 | | -use staabm\PHPStanDba\QueryReflection\MysqliQueryReflector; |
4 | 3 | use staabm\PHPStanDba\QueryReflection\QueryReflection; |
5 | 4 | use staabm\PHPStanDba\QueryReflection\QueryReflector; |
6 | | -use staabm\PHPStanDba\QueryReflection\RecordingQueryReflector; |
7 | | -use staabm\PHPStanDba\QueryReflection\ReflectionCache; |
8 | | -use staabm\PHPStanDba\QueryReflection\ReplayQueryReflector; |
9 | 5 | use staabm\PHPStanDba\QueryReflection\RuntimeConfiguration; |
| 6 | +use staabm\PHPStanDba\Tests\ReflectorFactory; |
10 | 7 |
|
11 | 8 | require_once __DIR__.'/../../../vendor/autoload.php'; |
12 | 9 |
|
|
23 | 20 | $config->defaultFetchMode(QueryReflector::FETCH_TYPE_NUMERIC); |
24 | 21 | // $config->debugMode(true); |
25 | 22 |
|
26 | | -try { |
27 | | - if (false !== getenv('GITHUB_ACTION')) { |
28 | | - $mysqli = @new mysqli('127.0.0.1', 'root', 'root', 'phpstan_dba'); |
29 | | - } else { |
30 | | - $mysqli = new mysqli('mysql80.ab', 'testuser', 'test', 'phpstan_dba'); |
31 | | - } |
32 | | - |
33 | | - $reflector = new MysqliQueryReflector($mysqli); |
34 | | - $reflector = new RecordingQueryReflector( |
35 | | - ReflectionCache::create( |
36 | | - $cacheFile |
37 | | - ), |
38 | | - $reflector |
39 | | - ); |
40 | | -} catch (mysqli_sql_exception $e) { |
41 | | - if (MysqliQueryReflector::MYSQL_HOST_NOT_FOUND !== $e->getCode()) { |
42 | | - throw $e; |
43 | | - } |
44 | | - |
45 | | - echo "\nWARN: Could not connect to MySQL.\nUsing cached reflection.\n"; |
46 | | - |
47 | | - // when we can't connect to the database, we rely on replaying pre-recorded db-reflection information |
48 | | - $reflector = new ReplayQueryReflector( |
49 | | - ReflectionCache::create( |
50 | | - $cacheFile |
51 | | - ) |
52 | | - ); |
53 | | -} |
| 23 | +$reflector = ReflectorFactory::create($cacheFile); |
54 | 24 |
|
55 | 25 | QueryReflection::setupReflector( |
56 | 26 | $reflector, |
|
0 commit comments