|
3 | 3 | namespace PHPStan\Type\Doctrine\Descriptors; |
4 | 4 |
|
5 | 5 | use Doctrine\DBAL\Connection; |
6 | | -use PHPStan\Doctrine\Driver\DriverType; |
| 6 | +use PHPStan\Doctrine\Driver\DriverDetector; |
7 | 7 | use PHPStan\Type\Accessory\AccessoryNumericStringType; |
8 | 8 | use PHPStan\Type\IntegerType; |
9 | 9 | use PHPStan\Type\IntersectionType; |
10 | 10 | use PHPStan\Type\StringType; |
11 | 11 | use PHPStan\Type\Type; |
12 | 12 | use PHPStan\Type\TypeCombinator; |
| 13 | +use function in_array; |
13 | 14 |
|
14 | 15 | class FloatType implements DoctrineTypeDescriptor, DoctrineTypeDriverAwareDescriptor |
15 | 16 | { |
16 | 17 |
|
17 | | - /** @var bool */ |
18 | | - private $bleedingEdge; |
| 18 | + /** @var DriverDetector */ |
| 19 | + private $driverDetector; |
19 | 20 |
|
20 | | - public function __construct(bool $bleedingEdge) |
| 21 | + public function __construct(DriverDetector $driverDetector) |
21 | 22 | { |
22 | | - $this->bleedingEdge = $bleedingEdge; |
| 23 | + $this->driverDetector = $driverDetector; |
23 | 24 | } |
24 | 25 |
|
25 | 26 | public function getType(): string |
@@ -50,22 +51,22 @@ public function getDatabaseInternalType(): Type |
50 | 51 |
|
51 | 52 | public function getDatabaseInternalTypeForDriver(Connection $connection): Type |
52 | 53 | { |
53 | | - $driverType = DriverType::detect($connection, $this->bleedingEdge); |
| 54 | + $driverType = $this->driverDetector->detect($connection); |
54 | 55 |
|
55 | | - if ($driverType === DriverType::PDO_PGSQL) { |
| 56 | + if ($driverType === DriverDetector::PDO_PGSQL) { |
56 | 57 | return new IntersectionType([ |
57 | 58 | new StringType(), |
58 | 59 | new AccessoryNumericStringType(), |
59 | 60 | ]); |
60 | 61 | } |
61 | 62 |
|
62 | | - if ( |
63 | | - $driverType === DriverType::SQLITE3 |
64 | | - || $driverType === DriverType::PDO_SQLITE |
65 | | - || $driverType === DriverType::MYSQLI |
66 | | - || $driverType === DriverType::PDO_MYSQL |
67 | | - || $driverType === DriverType::PGSQL |
68 | | - ) { |
| 63 | + if (in_array($driverType, [ |
| 64 | + DriverDetector::SQLITE3, |
| 65 | + DriverDetector::PDO_SQLITE, |
| 66 | + DriverDetector::MYSQLI, |
| 67 | + DriverDetector::PDO_MYSQL, |
| 68 | + DriverDetector::PGSQL, |
| 69 | + ], true)) { |
69 | 70 | return new \PHPStan\Type\FloatType(); |
70 | 71 | } |
71 | 72 |
|
|
0 commit comments