diff --git a/.phpstan-dba-mysqli.cache b/.phpstan-dba-mysqli.cache index 84f8ebcc1..853efb155 100644 --- a/.phpstan-dba-mysqli.cache +++ b/.phpstan-dba-mysqli.cache @@ -150,7 +150,7 @@ Simulated query: SELECT akid FROM table WHERE id IN (\'1\') LIMIT 0', array ( 5 => array ( - 'type-description' => 'array{COLUMN_NAME: string, 0: string, COLUMN_DEFAULT: string|null, 1: string|null, IS_NULLABLE: string, 2: string}', + 'type-description' => 'array{COLUMN_NAME: string|null, 0: string|null, COLUMN_DEFAULT: string|null, 1: string|null, IS_NULLABLE: string, 2: string}', ), ), ), diff --git a/.phpstan-dba-pdo-mysql.cache b/.phpstan-dba-pdo-mysql.cache index 75fe396a7..7c82ddc1d 100644 --- a/.phpstan-dba-pdo-mysql.cache +++ b/.phpstan-dba-pdo-mysql.cache @@ -62,7 +62,7 @@ array ( 5 => array ( - 'type-description' => 'array{COLUMN_NAME: string, 0: string, COLUMN_DEFAULT: string|null, 1: string|null, IS_NULLABLE: string, 2: string}', + 'type-description' => 'array{COLUMN_NAME: string|null, 0: string|null, COLUMN_DEFAULT: string|null, 1: string|null, IS_NULLABLE: string, 2: string}', ), ), ), diff --git a/composer.json b/composer.json index b7f228388..f9fab56f4 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ "tests/defaultFetchAssoc/data/", "tests/defaultFetchNumeric/data/", "tests/rules/data/", - "tests/stringify/data/" + "tests/stringify/data/", + "tests/sqlAst/data" ] }, "scripts": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b7b2dfad2..e07441b1e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -27,6 +27,12 @@ parameters: count: 1 path: src/QueryReflection/DbaApi.php + - + message: '#^Cannot access offset int\<0, max\> on array\, precision\: int\<0, max\>, pdo_type\: 0\|1\|2\|3\|4\|5\|6\|536870912\|1073741824\|2147483648\}\>\|PDOException\|null\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: src/QueryReflection/PdoMysqlQueryReflector.php + - message: ''' #^Call to deprecated method resolvePreparedQueryString\(\) of class staabm\\PHPStanDba\\QueryReflection\\QueryReflection\: diff --git a/tests/default/data/pdo-mysql.php b/tests/default/data/pdo-mysql.php index 0d6170410..2cbf7f4a4 100644 --- a/tests/default/data/pdo-mysql.php +++ b/tests/default/data/pdo-mysql.php @@ -21,7 +21,7 @@ public function aggregateFunctions(PDO $pdo) $query = 'SELECT MAX(adaid), MIN(adaid), COUNT(adaid), AVG(adaid) FROM ada WHERE adaid = 1'; $stmt = $pdo->query($query, PDO::FETCH_ASSOC); foreach ($stmt as $row) { - assertType('array{MAX(adaid): int<-32768, 32767>|null, MIN(adaid): int<-32768, 32767>|null, COUNT(adaid): int, AVG(adaid): numeric-string|null}', $row); + assertType("array{'MAX(adaid)': int<-32768, 32767>|null, 'MIN(adaid)': int<-32768, 32767>|null, 'COUNT(adaid)': int, 'AVG(adaid)': numeric-string|null}", $row); } } diff --git a/tests/sqlAst/config/.phpunit-phpstan-dba-mysqli.cache b/tests/sqlAst/config/.phpunit-phpstan-dba-mysqli.cache index 2aec38e32..2541ea5e9 100644 --- a/tests/sqlAst/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/sqlAst/config/.phpunit-phpstan-dba-mysqli.cache @@ -164,7 +164,7 @@ array ( 5 => array ( - 'type-description' => 'array{str: string, 0: string}', + 'type-description' => 'array{str: string|null, 0: string|null}', ), ), ), @@ -204,7 +204,7 @@ array ( 5 => array ( - 'type-description' => 'array{str: string, 0: string}', + 'type-description' => 'array{str: string|null, 0: string|null}', ), ), ), @@ -744,7 +744,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -754,7 +754,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -794,7 +794,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -804,7 +804,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -954,7 +954,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: mixed, 0: mixed}', ), ), ), @@ -1104,7 +1104,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1154,7 +1154,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1164,7 +1164,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1184,7 +1184,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1194,7 +1194,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -1214,7 +1214,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1554,7 +1554,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1564,7 +1564,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), diff --git a/tests/sqlAst/config/.phpunit-phpstan-dba-pdo-mysql.cache b/tests/sqlAst/config/.phpunit-phpstan-dba-pdo-mysql.cache index 2aec38e32..2541ea5e9 100644 --- a/tests/sqlAst/config/.phpunit-phpstan-dba-pdo-mysql.cache +++ b/tests/sqlAst/config/.phpunit-phpstan-dba-pdo-mysql.cache @@ -164,7 +164,7 @@ array ( 5 => array ( - 'type-description' => 'array{str: string, 0: string}', + 'type-description' => 'array{str: string|null, 0: string|null}', ), ), ), @@ -204,7 +204,7 @@ array ( 5 => array ( - 'type-description' => 'array{str: string, 0: string}', + 'type-description' => 'array{str: string|null, 0: string|null}', ), ), ), @@ -744,7 +744,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -754,7 +754,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -794,7 +794,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -804,7 +804,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -954,7 +954,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: mixed, 0: mixed}', ), ), ), @@ -1104,7 +1104,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1154,7 +1154,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1164,7 +1164,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1184,7 +1184,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1194,7 +1194,7 @@ array ( 5 => array ( - 'type-description' => 'array{col: string, 0: string}', + 'type-description' => 'array{col: string|null, 0: string|null}', ), ), ), @@ -1214,7 +1214,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1554,7 +1554,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), @@ -1564,7 +1564,7 @@ array ( 5 => array ( - 'type-description' => 'array{field: string, 0: string}', + 'type-description' => 'array{field: string|null, 0: string|null}', ), ), ), diff --git a/tests/sqlAst/data/sql-ast-narrowing.php b/tests/sqlAst/data/sql-ast-narrowing.php index 35bf764b7..75cfa2034 100644 --- a/tests/sqlAst/data/sql-ast-narrowing.php +++ b/tests/sqlAst/data/sql-ast-narrowing.php @@ -141,7 +141,7 @@ public function count(PDO $pdo): void $stmt = $pdo->query('SELECT count(email) as myemail, count(email) from ada'); foreach ($stmt as $row) { - assertType('array{myemail: int<0, max>, 0: int<0, max>, count(email): int<0, max>, 1: int<0, max>}', $row); + assertType("array{myemail: int<0, max>, 0: int<0, max>, 'count(email)': int<0, max>, 1: int<0, max>}", $row); } } diff --git a/tests/stringify/data/ast-narrowed-stringify.php b/tests/stringify/data/ast-narrowed-stringify.php index 93c566355..72f45aae7 100644 --- a/tests/stringify/data/ast-narrowed-stringify.php +++ b/tests/stringify/data/ast-narrowed-stringify.php @@ -16,7 +16,7 @@ public function count(PDO $pdo): void $stmt = $pdo->query('SELECT count(email) as myemail, count(email) from ada'); foreach ($stmt as $row) { - assertType("array{myemail: numeric-string, 0: numeric-string, count(email): numeric-string, 1: numeric-string}", $row); + assertType("array{myemail: numeric-string, 0: numeric-string, 'count(email)': numeric-string, 1: numeric-string}", $row); } } }