Skip to content

Commit c3eb114

Browse files
jakubvojacekstaabm
andauthored
Fix mysql type mapper (#583)
Co-authored-by: Markus Staab <[email protected]>
1 parent cbbedb2 commit c3eb114

13 files changed

+819
-729
lines changed

.phpstan-dba-mysqli.cache

Lines changed: 20 additions & 281 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.phpstan-dba-pdo-mysql.cache

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon.dist

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ parameters:
2323
reportUnmatchedIgnoredErrors: false
2424

2525
ignoreErrors:
26-
- '#^Method staabm\\PHPStanDba\\DbSchema\\SchemaHasherMysql\:\:hashDb\(\) should return string but returns float\|int\|string\.$#'
27-
- '#^Property staabm\\PHPStanDba\\DbSchema\\SchemaHasherMysql\:\:\$hash \(string\|null\) does not accept float\|int\|string\.$#'
28-
- '#^Instanceof between mysqli_result\<array\<string, int\|string\|null\>\> and mysqli_result will always evaluate to true\.$#'
26+
-
27+
message: '#^Method staabm\\PHPStanDba\\DbSchema\\SchemaHasherMysql\:\:hashDb\(\) should return string but returns float\|int\|string\.$#'
28+
path: src/DbSchema/SchemaHasherMysql.php
29+
-
30+
message: '#^Property staabm\\PHPStanDba\\DbSchema\\SchemaHasherMysql\:\:\$hash \(string\|null\) does not accept float\|int\|string\.$#'
31+
path: src/DbSchema/SchemaHasherMysql.php
32+
-
33+
message: '#^Instanceof between mysqli_result\<array\<string, int\|string\|null\>\> and mysqli_result will always evaluate to true\.$#'
34+
path: src/DbSchema/SchemaHasherMysql.php
35+
-
36+
message: '#^Instanceof between mysqli_result<array<string, int<-2147483648, 2147483647>\|string\|null>> and mysqli_result will always evaluate to true\.$#'
37+
path: src/DbSchema/SchemaHasherMysql.php
2938

src/TypeMapping/MysqlTypeMapper.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,44 +70,43 @@ public function mapToPHPStanType(string $mysqlType, array $mysqlFlags, int $leng
7070

7171
if ($numeric) {
7272
if ($unsigned) {
73-
switch ($length) {
74-
case 3:
75-
case 4:
73+
switch ($mysqlType) {
74+
case 'TINY':
75+
case 'CHAR':
7676
$phpstanType = $mysqlIntegerRanges->unsignedTinyInt();
7777
break;
78-
case 5:
78+
case 'SHORT':
7979
$phpstanType = $mysqlIntegerRanges->unsignedSmallInt();
8080
break;
81-
case 8:
81+
case 'INT24':
8282
$phpstanType = $mysqlIntegerRanges->unsignedMediumInt();
8383
break;
84-
case 10:
84+
case 'LONG':
8585
$phpstanType = $mysqlIntegerRanges->unsignedInt();
8686
break;
87-
case 20:
87+
case 'LONGLONG':
8888
$phpstanType = $mysqlIntegerRanges->unsignedBigInt();
8989
break;
9090
default:
9191
$phpstanType = null;
9292
break;
9393
}
9494
} else {
95-
switch ($length) {
96-
case 1:
97-
case 4:
95+
switch ($mysqlType) {
96+
case 'TINY':
97+
case 'CHAR':
9898
$phpstanType = $mysqlIntegerRanges->signedTinyInt();
9999
break;
100-
case 6:
100+
case 'SHORT':
101101
$phpstanType = $mysqlIntegerRanges->signedSmallInt();
102102
break;
103-
case 9:
103+
case 'INT24':
104104
$phpstanType = $mysqlIntegerRanges->signedMediumInt();
105105
break;
106-
case 11:
106+
case 'LONG':
107107
$phpstanType = $mysqlIntegerRanges->signedInt();
108108
break;
109-
case 20:
110-
case 22:
109+
case 'LONGLONG':
111110
$phpstanType = $mysqlIntegerRanges->signedBigInt();
112111
break;
113112
default:

tests/default/config/.phpunit-phpstan-dba-mysqli.cache

Lines changed: 59 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)