1818use function strtoupper ;
1919
2020/**
21- * @phpstan-type ColumnMeta array{name: string, table: string, native_type: string, len: int, flags: list< string>}
21+ * @phpstan-type ColumnMeta array{name: string, table: string, native_type: string, len: int, flags: array<int, string>, precision: int<0, max>, pdo_type: PDO::PARAM_* }
2222 */
2323final class PdoQueryReflector implements QueryReflector
2424{
@@ -47,7 +47,7 @@ final class PdoQueryReflector implements QueryReflector
4747 private const MAX_CACHE_SIZE = 50 ;
4848
4949 /**
50- * @var array<string, PDOException|list< ColumnMeta>|null>
50+ * @var array<string, PDOException|array<int<0, max>, ColumnMeta>|null>
5151 */
5252 private array $ cache = [];
5353
@@ -165,22 +165,13 @@ private function simulateQuery(string $queryString)
165165 $ columnIndex = 0 ;
166166 while ($ columnIndex < $ columnCount ) {
167167 // see https://github.com/php/php-src/blob/master/ext/pdo_mysql/mysql_statement.c
168+ /** @var ColumnMeta|false */
168169 $ columnMeta = $ stmt ->getColumnMeta ($ columnIndex );
169170
170171 if (false === $ columnMeta ) {
171172 throw new ShouldNotHappenException ('Failed to get column meta for column index ' .$ columnIndex );
172173 }
173174
174- if (
175- !\array_key_exists ('name ' , $ columnMeta )
176- || !\array_key_exists ('table ' , $ columnMeta )
177- || !\array_key_exists ('native_type ' , $ columnMeta )
178- || !\array_key_exists ('flags ' , $ columnMeta )
179- || !\array_key_exists ('len ' , $ columnMeta )
180- ) {
181- throw new ShouldNotHappenException ();
182- }
183-
184175 $ flags = $ this ->emulateMysqlFlags ($ columnMeta ['native_type ' ], $ columnMeta ['table ' ], $ columnMeta ['name ' ]);
185176 foreach ($ flags as $ flag ) {
186177 $ columnMeta ['flags ' ][] = $ flag ;
@@ -191,7 +182,6 @@ private function simulateQuery(string $queryString)
191182 ++$ columnIndex ;
192183 }
193184
194- // @phpstan-ignore-next-line
195185 return $ this ->cache [$ queryString ];
196186 }
197187
0 commit comments