From dc579c0c10c9522b9a321bd007a5309d7ab9b876 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 17 Nov 2022 13:22:50 +0100 Subject: [PATCH] Dibi type inference Co-authored-by: Jakub Vojacek Co-authored-by: Markus Staab Co-authored-by: jakubvojacek --- .phpstan-dba-mysqli.cache | 748 +--- config/extensions.neon | 6 + config/rules.neon | 16 +- src/DibiReflection/DibiReflection.php | 29 + ...nectionFetchDynamicReturnTypeExtension.php | 126 + ...ErrorInDibiPreparedStatementMethodRule.php | 205 ++ tests/default/DbaInferenceTest.php | 1 + .../.phpunit-phpstan-dba-dibi-mysql.cache | 3263 +++++++++++++++++ .../config/.phpunit-phpstan-dba-mysqli.cache | 236 +- .../.phpunit-phpstan-dba-pdo-mysql.cache | 312 +- tests/default/data/dibi.php | 34 + .../config/.phpunit-phpstan-dba-mysqli.cache | 2 +- .../config/.phpunit-phpstan-dba-mysqli.cache | 2 +- ...rInDibiPreparedStatementMethodRuleTest.php | 169 + ...ErrorInPreparedStatementMethodRuleTest.php | 70 - .../config/.phpunit-phpstan-dba-mysqli.cache | 400 +- .../.phpunit-phpstan-dba-pdo-mysql.cache | 442 ++- ...yntax-error-in-dibi-prepared-statement.php | 59 + .../syntax-error-in-prepared-statement.php | 17 - .../config/.phpunit-phpstan-dba-mysqli.cache | 2 +- 20 files changed, 5259 insertions(+), 880 deletions(-) create mode 100644 src/DibiReflection/DibiReflection.php create mode 100644 src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php create mode 100644 src/Rules/SyntaxErrorInDibiPreparedStatementMethodRule.php create mode 100644 tests/default/config/.phpunit-phpstan-dba-dibi-mysql.cache create mode 100644 tests/default/data/dibi.php create mode 100644 tests/rules/SyntaxErrorInDibiPreparedStatementMethodRuleTest.php create mode 100644 tests/rules/data/syntax-error-in-dibi-prepared-statement.php diff --git a/.phpstan-dba-mysqli.cache b/.phpstan-dba-mysqli.cache index f31c04b46..f2b0f4ddf 100644 --- a/.phpstan-dba-mysqli.cache +++ b/.phpstan-dba-mysqli.cache @@ -1,137 +1,8 @@ 'v9-put-null-when-valid', - 'schemaHash' => '436d43fc96b9dd0cfad4bbc2837886e4', + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( - 'SELECT - coalesce(COLUMN_NAME, "") as COLUMN_NAME, - coalesce(EXTRA, "") as EXTRA, - COLUMN_TYPE - FROM information_schema.columns - WHERE table_name = \'1970-01-01\' AND table_schema = DATABASE()' => - array ( - 'result' => - array ( - 5 => - PHPStan\Type\Constant\ConstantArrayType::__set_state(array( - 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 2 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 2, - )), - 3 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - 5 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'EXTRA', - 'isClassString' => false, - )), - ), - )), - 'itemType' => - PHPStan\Type\StringType::__set_state(array( - )), - 'allArrays' => NULL, - 'nextAutoIndexes' => - array ( - 0 => 3, - ), - 'keyTypes' => - array ( - 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 2 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'EXTRA', - 'isClassString' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - 5 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 2, - )), - ), - 'valueTypes' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), - 2 => - PHPStan\Type\StringType::__set_state(array( - )), - 3 => - PHPStan\Type\StringType::__set_state(array( - )), - 4 => - PHPStan\Type\StringType::__set_state(array( - )), - 5 => - PHPStan\Type\StringType::__set_state(array( - )), - ), - 'optionalKeys' => - array ( - ), - 'isList' => false, - )), - ), - ), - 'SELECT - coalesce(COLUMN_NAME, "") as COLUMN_NAME, - coalesce(EXTRA, "") as EXTRA, - COLUMN_TYPE - FROM information_schema.columns - WHERE table_name = ? AND table_schema = DATABASE()' => - array ( - 'result' => - array ( - 5 => NULL, - ), - ), 'SELECT MD5( GROUP_CONCAT( @@ -151,219 +22,153 @@ GROUP BY grouper' => array ( - 'result' => - array ( - 5 => - PHPStan\Type\Constant\ConstantArrayType::__set_state(array( - 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 2 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'dbsignature', - 'isClassString' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'grouper', - 'isClassString' => false, - )), - ), - )), - 'itemType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), - 2 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 'allArrays' => NULL, - 'nextAutoIndexes' => - array ( - 0 => 2, - ), - 'keyTypes' => - array ( - 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'dbsignature', - 'isClassString' => false, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 2 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'grouper', - 'isClassString' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - ), - 'valueTypes' => - array ( - 0 => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 1 => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 2 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - 3 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - ), - 'optionalKeys' => - array ( - ), - 'isList' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantArrayType::__set_state(array( - 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'dbsignature', - 'isClassString' => false, - )), - 1 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'grouper', - 'isClassString' => false, - )), - ), - )), - 'itemType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), - 2 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 'allArrays' => NULL, - 'nextAutoIndexes' => - array ( - 0 => 0, - ), - 'keyTypes' => - array ( - 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'dbsignature', - 'isClassString' => false, - )), - 1 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'grouper', - 'isClassString' => false, - )), - ), - 'valueTypes' => - array ( - 0 => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 1 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - ), - 'optionalKeys' => - array ( - ), - 'isList' => false, - )), - ), + 'error' => NULL, + ), + 'SELECT * FROM `ada` WHERE adaid = 1' => + array ( + 'error' => NULL, + ), + 'SELECT * FROM `ada` WHERE email = \'test@example.com\';' => + array ( + 'error' => NULL, + ), + 'SELECT * FROM typemix' => + array ( + 'error' => NULL, ), - 'SELECT * FROM ada WHERE 1=111' => + 'SELECT MAX(adaid), MIN(adaid), COUNT(adaid), AVG(adaid) FROM ada WHERE adaid = 1' => + array ( + 'error' => NULL, + ), + 'SELECT a.email, b.adaid FROM ada a LEFT JOIN ada b ON a.adaid=b.adaid' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 FOR SHARE' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 FOR SHARE NOWAIT' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 FOR SHARE SKIP LOCKED' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 FOR UPDATE NOWAIT' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 FOR UPDATE SKIP LOCKED' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 OFFSET 1' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada LIMIT 1 OFFSET 1 FOR UPDATE' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada WHERE email LIKE ":gesperrt%"' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada WHERE email LIKE \'%questions ?%\'' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada WHERE email LIKE \':gesperrt%\'' => + array ( + 'error' => NULL, + ), + 'SELECT adaid FROM ada WHERE email LIKE \'hello?%\'' => + array ( + 'error' => NULL, + ), + 'SELECT akid FROM ak WHERE eadavk>1.0' => + array ( + 'error' => NULL, + ), + 'SELECT akid FROM ak WHERE eadavk>1.1' => + array ( + 'error' => NULL, + ), + 'SELECT eladaid FROM ak' => + array ( + 'error' => NULL, + ), + 'SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada' => + array ( + 'error' => + staabm\PHPStanDba\Error::__set_state(array( + 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'freigabe1u1 FROM ada LIMIT 0\' at line 1', + 'code' => 1064, + )), + ), + 'SELECT email, adaid FROM ada' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada LIMIT 1' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada LIMIT 1, 10' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE adaid = 1' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE adaid = 2' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE adaid = 3' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE adaid IN(1,3)' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE adaid=' => + array ( + 'error' => + staabm\PHPStanDba\Error::__set_state(array( + 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'LIMIT 0\' at line 1', + 'code' => 1064, + )), + ), + 'SELECT email, adaid FROM ada WHERE adaid=1' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE email = \'test@example.org\'' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE email = \'webmaster@example.org\'' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE email=\'foo\'' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada WHERE gesperrt = \'1\'' => + array ( + 'error' => NULL, + ), + 'SELECT email, adaid FROM ada where email = "1"' => array ( 'result' => array ( - 5 => + 3 => PHPStan\Type\Constant\ConstantArrayType::__set_state(array( 'keyType' => PHPStan\Type\UnionType::__set_state(array( @@ -371,45 +176,17 @@ 'types' => array ( 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 2 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 2, - )), - 3 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 3, - )), - 4 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, 'value' => 'adaid', 'isClassString' => false, )), - 5 => + 1 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, 'value' => 'email', 'isClassString' => false, )), - 6 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'freigabe1u1', - 'isClassString' => false, - )), - 7 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'gesperrt', - 'isClassString' => false, - )), ), )), 'itemType' => @@ -418,245 +195,45 @@ 'types' => array ( 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => PHPStan\Type\IntegerRangeType::__set_state(array( 'min' => -32768, 'max' => 32767, )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), ), )), 'allArrays' => NULL, 'nextAutoIndexes' => array ( - 0 => 4, + 0 => 0, ), 'keyTypes' => array ( 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'adaid', - 'isClassString' => false, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 2 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'gesperrt', - 'isClassString' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 4 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, 'value' => 'email', 'isClassString' => false, )), - 5 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 2, - )), - 6 => + 1 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'value' => 'freigabe1u1', + 'value' => 'adaid', 'isClassString' => false, )), - 7 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 3, - )), ), 'valueTypes' => array ( 0 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -32768, - 'max' => 32767, + PHPStan\Type\StringType::__set_state(array( )), 1 => PHPStan\Type\IntegerRangeType::__set_state(array( 'min' => -32768, 'max' => 32767, )), - 2 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - 3 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - 4 => - PHPStan\Type\StringType::__set_state(array( - )), - 5 => - PHPStan\Type\StringType::__set_state(array( - )), - 6 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - 7 => - PHPStan\Type\IntegerRangeType::__set_state(array( - 'min' => -128, - 'max' => 127, - )), - ), - 'optionalKeys' => - array ( - ), - 'isList' => false, - )), - ), - ), - 'SELECT column_name, column_default, is_nullable -FROM information_schema.columns -WHERE table_name = \'1970-01-01\'' => - array ( - 'result' => - array ( - 5 => - PHPStan\Type\Constant\ConstantArrayType::__set_state(array( - 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 2 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 2, - )), - 3 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'column_default', - 'isClassString' => false, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'column_name', - 'isClassString' => false, - )), - 5 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'is_nullable', - 'isClassString' => false, - )), - ), - )), - 'itemType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 'allArrays' => NULL, - 'nextAutoIndexes' => - array ( - 0 => 3, - ), - 'keyTypes' => - array ( - 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'column_name', - 'isClassString' => false, - )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 2 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'column_default', - 'isClassString' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'is_nullable', - 'isClassString' => false, - )), - 5 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 2, - )), - ), - 'valueTypes' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), - 2 => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 3 => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - )), - 4 => - PHPStan\Type\StringType::__set_state(array( - )), - 5 => - PHPStan\Type\StringType::__set_state(array( - )), ), 'optionalKeys' => array ( @@ -665,27 +242,6 @@ WHERE table_name = \'1970-01-01\'' => )), ), ), - 'SELECT column_name, column_default, is_nullable -FROM information_schema.columns -WHERE table_name = ?' => - array ( - 'result' => - array ( - 5 => NULL, - ), - ), - 'SELECT email adaid WHERE gesperrt FROM ada' => - array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'FROM ada LIMIT 0\' at line 1', - 'code' => 1064, - )), - ), - 'SELECT email, adaid FROM ada' => - array ( - 'error' => NULL, - ), ), 'runtimeConfig' => array ( diff --git a/config/extensions.neon b/config/extensions.neon index c7e301aac..9c6c1f8e6 100644 --- a/config/extensions.neon +++ b/config/extensions.neon @@ -90,3 +90,9 @@ services: class: staabm\PHPStanDba\Ast\PreviousConnectingVisitor tags: - phpstan.parser.richParserNodeVisitor + + - + class: staabm\PHPStanDba\Extensions\DibiConnectionFetchDynamicReturnTypeExtension + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + diff --git a/config/rules.neon b/config/rules.neon index f2cfb9eb0..b60cf87fe 100644 --- a/config/rules.neon +++ b/config/rules.neon @@ -1,4 +1,15 @@ services: + - + class: staabm\PHPStanDba\Rules\SyntaxErrorInDibiPreparedStatementMethodRule + tags: [phpstan.rules.rule] + arguments: + classMethods: + - 'Dibi\Connection::fetch' + - 'Dibi\Connection::fetchSingle' + - 'Dibi\Connection::query' + - 'Dibi\Connection::fetchAll' + - 'Dibi\Connection::fetchPairs' + - class: staabm\PHPStanDba\Rules\SyntaxErrorInPreparedStatementMethodRule tags: [phpstan.rules.rule] @@ -24,11 +35,6 @@ services: - 'Doctrine\DBAL\Connection::iterateAssociativeIndexed' - 'Doctrine\DBAL\Connection::iterateColumn' - 'Doctrine\DBAL\Connection::executeUpdate' # deprecated in doctrine - - 'Dibi\Connection::fetch' - - 'Dibi\Connection::fetchSingle' - - 'Dibi\Connection::query' - - 'Dibi\Connection::fetchAll' - - 'Dibi\Connection::fetchPairs' - class: staabm\PHPStanDba\Rules\PdoStatementExecuteMethodRule diff --git a/src/DibiReflection/DibiReflection.php b/src/DibiReflection/DibiReflection.php new file mode 100644 index 000000000..05fb4a896 --- /dev/null +++ b/src/DibiReflection/DibiReflection.php @@ -0,0 +1,29 @@ + 0) { + $queryString = null; + } elseif (strpos($queryString, '%ex') > 0) { + $queryString = null; + } elseif (0 !== preg_match('#^\s*(START|ROLLBACK|SET|SAVEPOINT|SHOW)#i', $queryString)) { + $queryString = null; + } + + return $queryString; + } +} diff --git a/src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php b/src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php new file mode 100644 index 000000000..d77e5be9c --- /dev/null +++ b/src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php @@ -0,0 +1,126 @@ +getName(), [ + 'fetch', + 'fetchAll', + 'fetchPairs', + 'fetchSingle', + ], true); + } + + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type + { + $args = $methodCall->getArgs(); + + if (\count($args) < 1) { + return null; + } + + if ($scope->getType($args[0]->value) instanceof MixedType) { + return null; + } + + try { + return $this->inferType($methodReflection, $args[0]->value, $scope); + } catch (UnresolvableQueryException $exception) { + // simulation not possible.. use default value + } + + return null; + } + + private function inferType(MethodReflection $methodReflection, Expr $queryExpr, Scope $scope): ?Type + { + $queryReflection = new QueryReflection(); + $queryStrings = $queryReflection->resolveQueryStrings($queryExpr, $scope); + + return $this->createFetchType($queryStrings, $methodReflection); + } + + /** + * @param iterable $queryStrings + */ + private function createFetchType(iterable $queryStrings, MethodReflection $methodReflection): ?Type + { + $queryReflection = new QueryReflection(); + $dibiReflection = new DibiReflection(); + + $fetchTypes = []; + foreach ($queryStrings as $queryString) { + $queryString = $dibiReflection->rewriteQuery($queryString); + if (null === $queryString) { + continue; + } + + $resultType = $queryReflection->getResultType($queryString, QueryReflector::FETCH_TYPE_ASSOC); + + if (null === $resultType) { + return null; + } + + $fetchResultType = $this->reduceResultType($methodReflection, $resultType); + if (null === $fetchResultType) { + return null; + } + + $fetchTypes[] = $fetchResultType; + } + + if (\count($fetchTypes) > 1) { + return TypeCombinator::union(...$fetchTypes); + } + if (1 === \count($fetchTypes)) { + return $fetchTypes[0]; + } + + return null; + } + + private function reduceResultType(MethodReflection $methodReflection, Type $resultType): ?Type + { + $methodName = $methodReflection->getName(); + + if ('fetch' === $methodName) { + return new UnionType([new NullType(), $resultType]); + } elseif ('fetchAll' === $methodName) { + return new ArrayType(new IntegerType(), $resultType); + } elseif ('fetchPairs' === $methodName && $resultType instanceof ConstantArrayType && 2 === \count($resultType->getValueTypes())) { + return new ArrayType($resultType->getValueTypes()[0], $resultType->getValueTypes()[1]); + } elseif ('fetchSingle' === $methodName && $resultType instanceof ConstantArrayType && 1 === \count($resultType->getValueTypes())) { + return new UnionType([new NullType(), $resultType->getValueTypes()[0]]); + } + + return null; + } +} diff --git a/src/Rules/SyntaxErrorInDibiPreparedStatementMethodRule.php b/src/Rules/SyntaxErrorInDibiPreparedStatementMethodRule.php new file mode 100644 index 000000000..9f5c84a67 --- /dev/null +++ b/src/Rules/SyntaxErrorInDibiPreparedStatementMethodRule.php @@ -0,0 +1,205 @@ + + * + * @see SyntaxErrorInDibiPreparedStatementMethodRuleTest + */ +final class SyntaxErrorInDibiPreparedStatementMethodRule implements Rule +{ + /** + * @var list + */ + private $classMethods; + + /** + * @param list $classMethods + */ + public function __construct(array $classMethods) + { + $this->classMethods = $classMethods; + } + + public function getNodeType(): string + { + return CallLike::class; + } + + public function processNode(Node $callLike, Scope $scope): array + { + if ($callLike instanceof MethodCall) { + if (!$callLike->name instanceof Node\Identifier) { + return []; + } + + $methodReflection = $scope->getMethodReflection($scope->getType($callLike->var), $callLike->name->toString()); + } elseif ($callLike instanceof New_) { + if (!$callLike->class instanceof FullyQualified) { + return []; + } + $methodReflection = $scope->getMethodReflection(new ObjectType($callLike->class->toCodeString()), '__construct'); + } else { + return []; + } + + if (null === $methodReflection) { + return []; + } + + $unsupportedMethod = true; + foreach ($this->classMethods as $classMethod) { + sscanf($classMethod, '%[^::]::%s', $className, $methodName); + if (!\is_string($className) || !\is_string($methodName)) { + throw new ShouldNotHappenException('Invalid classMethod definition'); + } + + if ($methodName === $methodReflection->getName() && + ($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))) { + $unsupportedMethod = false; + break; + } + } + + if ($unsupportedMethod) { + return []; + } + + return $this->checkErrors($callLike, $scope, $methodReflection); + } + + /** + * @param MethodCall|New_ $callLike + * + * @return RuleError[] + */ + private function checkErrors(CallLike $callLike, Scope $scope, MethodReflection $methodReflection): array + { + $args = $callLike->getArgs(); + + if (\count($args) < 1) { + return []; + } + + $queryReflection = new QueryReflection(); + $queryParameters = []; + $errors = []; + + foreach ($args as $arg) { + $parameterExpr = $arg->value; + $parameterType = $scope->getType($parameterExpr); + + if ($parameterType instanceof StringType) { + $resolvedString = $queryReflection->resolveQueryString($parameterExpr, $scope); + + if (null === $resolvedString) { + $queryParameters[] = $parameterType; + } else { + $queryParameters[] = $resolvedString; + } + } elseif ($parameterType instanceof ConstantArrayType) { + $constantArray = []; + + foreach ($parameterType->getKeyTypes() as $i => $keyType) { + $constantArray[$keyType->getValue()] = $parameterType->getValueTypes()[$i]; + } + + $queryParameters[] = $constantArray; + } else { + $queryParameters[] = $parameterType; + } + } + + if (!\is_string($queryParameters[0])) { + return []; + } + + $stringParameterCount = 0; + + foreach ($queryParameters as $queryParameter) { + if (\is_string($queryParameter)) { + $stringParameterCount = $stringParameterCount + 1; + } + } + + $placeholders = []; + preg_match_all('#%(ex|in|i|and|or|s|t|d|~?like~?|n|lmt|ofs)#', $queryParameters[0], $placeholders, \PREG_SET_ORDER); + $placeholderCount = \count($placeholders); + $parameterCount = \count($queryParameters) - 1; + + if (1 === $stringParameterCount && 'INSERT' !== QueryReflection::getQueryType($queryParameters[0])) { + if ($parameterCount !== $placeholderCount) { + $placeholderExpectation = sprintf('Query expects %s placeholder', $placeholderCount); + if ($placeholderCount > 1) { + $placeholderExpectation = sprintf('Query expects %s placeholders', $placeholderCount); + } + + if (0 === $parameterCount) { + $parameterActual = 'but no values are given'; + } else { + $parameterActual = sprintf('but %s value is given', $parameterCount); + if ($parameterCount > 1) { + $parameterActual = sprintf('but %s values are given', $parameterCount); + } + } + + return [ + RuleErrorBuilder::message($placeholderExpectation.', '.$parameterActual.'.')->line($callLike->getLine())->build(), + ]; + } + } + + if ($stringParameterCount > 1) { + // means syntax like `query('update app set', [...], ' where x = %i', 1)` + return []; + } + + if ($placeholderCount !== $parameterCount) { + // means syntax like `query('insert into app', [...])` + return []; + } + + $validity = $queryReflection->validateQueryString($queryParameters[0]); + + if (null !== $validity) { + return [RuleErrorBuilder::message($validity->asRuleMessage())->line($callLike->getLine())->build()]; + } + + $result = $queryReflection->getResultType($queryParameters[0], QueryReflector::FETCH_TYPE_BOTH); + + if ($result instanceof ConstantArrayType) { + // compensate fetch both + $columnsInResult = \count($result->getValueTypes()) / 2; + + if ('fetchPairs' === $methodReflection->getName() && 2 !== $columnsInResult) { + return [RuleErrorBuilder::message('fetchPairs requires exactly 2 selected columns, got '.$columnsInResult.'.')->line($callLike->getLine())->build()]; + } + + if ('fetchSingle' === $methodReflection->getName() && 1 !== $columnsInResult) { + return [RuleErrorBuilder::message('fetchSingle requires exactly 1 selected column, got '.$columnsInResult.'.')->line($callLike->getLine())->build()]; + } + } + + return $errors; + } +} diff --git a/tests/default/DbaInferenceTest.php b/tests/default/DbaInferenceTest.php index bff723c81..5c417c9ea 100644 --- a/tests/default/DbaInferenceTest.php +++ b/tests/default/DbaInferenceTest.php @@ -22,6 +22,7 @@ public function dataFileAsserts(): iterable } else { yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-mysql.php'); } + yield from $this->gatherAssertTypes(__DIR__.'/data/dibi.php'); // make sure class constants can be resolved require_once __DIR__.'/data/pdo-quote.php'; diff --git a/tests/default/config/.phpunit-phpstan-dba-dibi-mysql.cache b/tests/default/config/.phpunit-phpstan-dba-dibi-mysql.cache new file mode 100644 index 000000000..bff8d3fed --- /dev/null +++ b/tests/default/config/.phpunit-phpstan-dba-dibi-mysql.cache @@ -0,0 +1,3263 @@ + 'v9-put-null-when-valid', + 'schemaHash' => NULL, + 'records' => + array ( + 'SELECT + adaid + FROM + ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT a.email, b.adaid FROM ada a LEFT JOIN ada b ON a.adaid=b.adaid' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 2 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid +FROM ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 FOR SHARE' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 FOR SHARE NOWAIT' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 FOR SHARE SKIP LOCKED' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 FOR UPDATE NOWAIT' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 FOR UPDATE SKIP LOCKED' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 OFFSET 1' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada LIMIT 1 OFFSET 1 FOR UPDATE' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada WHERE adaid IN (\'1\')' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada WHERE adaid IN (\'1\') AND email LIKE \'1970-01-01\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada WHERE adaid IN (:adaids)' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT adaid FROM ada WHERE adaid IN (:ids)' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT adaid FROM ada WHERE adaid IN (:ids) AND email LIKE :time' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT adaid FROM ada WHERE adaid IN (NULL) AND email LIKE \'1970-01-01\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada WHERE email LIKE \'%questions ?%\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada WHERE email LIKE \':gesperrt%\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid FROM ada WHERE email LIKE \'hello?%\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT adaid, email FROM ada' => + array ( + 'result' => + array ( + 7 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT akid FROM ak WHERE eadavk>1.0' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'akid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -2147483648, + 'max' => 2147483647, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'akid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -2147483648, + 'max' => 2147483647, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT akid FROM ak WHERE eadavk>1.1' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'akid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -2147483648, + 'max' => 2147483647, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'akid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -2147483648, + 'max' => 2147483647, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT count(*) AS c FROM typemix WHERE c_datetime=:last_dt' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT count(*) FROM typemix WHERE c_date = \'1970-01-01\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'count(*)', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'count(*)', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT count(*) FROM typemix WHERE c_datetime = \'1970-01-01\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'count(*)', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\IntegerType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'count(*)', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT eladaid FROM ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'eladaid', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -2147483648, + 'max' => 2147483647, + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'eladaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -2147483648, + 'max' => 2147483647, + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email +FROM ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email FROM ada' => + array ( + 'result' => + array ( + 7 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada' => + array ( + 'error' => + staabm\PHPStanDba\Error::__set_state(array( + 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'freigabe1u1 FROM ada\' at line 1', + 'code' => 1064, + )), + ), + 'SELECT email, adaid FROM ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 7 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada LIMIT 1' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada LIMIT 1, 10' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = \'1\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = \'1\' and email = \'email@example.org\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = 1' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = 2' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = 3' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = :adaid' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = ?' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid = ? and email = ?' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid IN(1,3)' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid=' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE adaid=1' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email <=> \'\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email <=> :email' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE email = \'1970-01-01\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email = \'1970-01-01\' AND 1=1' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email = \'email@example.org\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email = \'test@example.org\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email = \'webmaster@example.org\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email = :email' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE email = :test1 AND email = :test2' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE email = ?' => + array ( + 'result' => + array ( + 5 => NULL, + ), + ), + 'SELECT email, adaid FROM ada WHERE email=\'foo\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE email=\'test@example.org\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada WHERE gesperrt = \'1\'' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 2 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'freigabe1u1', + 'isClassString' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'gesperrt', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 2 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'gesperrt', + 'isClassString' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'freigabe1u1', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 2 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -128, + 'max' => 127, + )), + 3 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -128, + 'max' => 127, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + ), + 'runtimeConfig' => + array ( + 'errorMode' => 'exception', + 'debugMode' => false, + 'stringifyTypes' => false, + ), +); \ No newline at end of file diff --git a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache index 25759eb09..322c7dee9 100644 --- a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache @@ -1,6 +1,6 @@ 'v9-put-null-when-valid', - 'schemaHash' => NULL, + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( 'SELECT @@ -2996,6 +2996,84 @@ FROM ada' => )), ), ), + 'SELECT adaid, email FROM ada' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT akid FROM ak WHERE eadavk>1.0' => array ( 'result' => @@ -3416,24 +3494,13 @@ FROM ada' => array ( 'result' => array ( - 5 => + 3 => PHPStan\Type\Constant\ConstantArrayType::__set_state(array( 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'email', - 'isClassString' => false, - )), - ), + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, )), 'itemType' => PHPStan\Type\StringType::__set_state(array( @@ -3441,7 +3508,7 @@ FROM ada' => 'allArrays' => NULL, 'nextAutoIndexes' => array ( - 0 => 1, + 0 => 0, ), 'keyTypes' => array ( @@ -3451,32 +3518,36 @@ FROM ada' => 'value' => 'email', 'isClassString' => false, )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), ), 'valueTypes' => array ( 0 => PHPStan\Type\StringType::__set_state(array( )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), ), 'optionalKeys' => array ( ), 'isList' => false, )), - 3 => + 5 => PHPStan\Type\Constant\ConstantArrayType::__set_state(array( 'keyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'email', - 'isClassString' => false, + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), )), 'itemType' => PHPStan\Type\StringType::__set_state(array( @@ -3484,7 +3555,7 @@ FROM ada' => 'allArrays' => NULL, 'nextAutoIndexes' => array ( - 0 => 0, + 0 => 1, ), 'keyTypes' => array ( @@ -3494,12 +3565,19 @@ FROM ada' => 'value' => 'email', 'isClassString' => false, )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), ), 'valueTypes' => array ( 0 => PHPStan\Type\StringType::__set_state(array( )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), ), 'optionalKeys' => array ( @@ -3515,10 +3593,6 @@ FROM ada' => 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'freigabe1u1 FROM ada LIMIT 0\' at line 1', 'code' => 1064, )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT email, adaid FROM ada' => array ( @@ -3898,18 +3972,6 @@ FROM ada' => )), ), ), - 'SELECT email, adaid FROM ada WHERE' => - array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'LIMIT 0\' at line 1', - 'code' => 1064, - )), - 'result' => - array ( - 5 => NULL, - ), - ), 'SELECT email, adaid FROM ada WHERE adaid = \'1\'' => array ( 'result' => @@ -5670,16 +5732,82 @@ FROM ada' => )), ), ), - 'SELECT email, adaid FROM ada article_slice WHERE' => + 'SELECT email, adaid FROM ada where adaid = \'1\'' => array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'LIMIT 0\' at line 1', - 'code' => 1064, - )), 'result' => array ( - 5 => NULL, + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), ), ), 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada' => diff --git a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache index 019674ec4..2e9d8a978 100644 --- a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache +++ b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache @@ -1,6 +1,6 @@ 'v9-put-null-when-valid', - 'schemaHash' => NULL, + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( 'SELECT @@ -2871,6 +2871,84 @@ FROM ada' => )), ), ), + 'SELECT adaid, email FROM ada' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT akid FROM ak WHERE eadavk>1.0' => array ( 'result' => @@ -3291,24 +3369,13 @@ FROM ada' => array ( 'result' => array ( - 5 => + 3 => PHPStan\Type\Constant\ConstantArrayType::__set_state(array( 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'email', - 'isClassString' => false, - )), - ), + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, )), 'itemType' => PHPStan\Type\StringType::__set_state(array( @@ -3316,7 +3383,7 @@ FROM ada' => 'allArrays' => NULL, 'nextAutoIndexes' => array ( - 0 => 1, + 0 => 0, ), 'keyTypes' => array ( @@ -3326,32 +3393,36 @@ FROM ada' => 'value' => 'email', 'isClassString' => false, )), - 1 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), ), 'valueTypes' => array ( 0 => PHPStan\Type\StringType::__set_state(array( )), - 1 => - PHPStan\Type\StringType::__set_state(array( - )), ), 'optionalKeys' => array ( ), 'isList' => false, )), - 3 => + 5 => PHPStan\Type\Constant\ConstantArrayType::__set_state(array( 'keyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'value' => 'email', - 'isClassString' => false, + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), )), 'itemType' => PHPStan\Type\StringType::__set_state(array( @@ -3359,7 +3430,7 @@ FROM ada' => 'allArrays' => NULL, 'nextAutoIndexes' => array ( - 0 => 0, + 0 => 1, ), 'keyTypes' => array ( @@ -3369,12 +3440,19 @@ FROM ada' => 'value' => 'email', 'isClassString' => false, )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), ), 'valueTypes' => array ( 0 => PHPStan\Type\StringType::__set_state(array( )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), ), 'optionalKeys' => array ( @@ -3390,10 +3468,6 @@ FROM ada' => 'message' => 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'freigabe1u1 FROM ada LIMIT 0\' at line 1', 'code' => '42000', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT email, adaid FROM ada' => array ( @@ -3773,18 +3847,6 @@ FROM ada' => )), ), ), - 'SELECT email, adaid FROM ada WHERE' => - array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'LIMIT 0\' at line 1', - 'code' => '42000', - )), - 'result' => - array ( - 5 => NULL, - ), - ), 'SELECT email, adaid FROM ada WHERE adaid = \'1\'' => array ( 'result' => @@ -5545,6 +5607,162 @@ FROM ada' => )), ), ), + 'SELECT email, adaid FROM ada where adaid = \'1\'' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email, adaid FROM ada where email = \'1\'' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada' => array ( 'result' => diff --git a/tests/default/data/dibi.php b/tests/default/data/dibi.php new file mode 100644 index 000000000..869758e7d --- /dev/null +++ b/tests/default/data/dibi.php @@ -0,0 +1,34 @@ +fetch('SELECT email, adaid FROM ada where adaid = %i', 1); + assertType('array{email: string, adaid: int<-32768, 32767>}|null', $row); + } + + public function fetchAll(\Dibi\Connection $connection) + { + $row = $connection->fetchAll('SELECT email, adaid FROM ada'); + assertType('array}>', $row); + } + + public function fetchPairs(\Dibi\Connection $connection) + { + $row = $connection->fetchPairs('SELECT adaid, email FROM ada'); + assertType('array, string>', $row); + } + + public function fetchSingle(\Dibi\Connection $connection) + { + $row = $connection->fetchSingle('SELECT email FROM ada'); + assertType('string|null', $row); + } + +} diff --git a/tests/defaultFetchAssoc/config/.phpunit-phpstan-dba-mysqli.cache b/tests/defaultFetchAssoc/config/.phpunit-phpstan-dba-mysqli.cache index 4b5be0233..7a37cd3f4 100644 --- a/tests/defaultFetchAssoc/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/defaultFetchAssoc/config/.phpunit-phpstan-dba-mysqli.cache @@ -1,6 +1,6 @@ 'v9-put-null-when-valid', - 'schemaHash' => NULL, + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( 'SELECT email, adaid FROM ada' => diff --git a/tests/defaultFetchNumeric/config/.phpunit-phpstan-dba-mysqli.cache b/tests/defaultFetchNumeric/config/.phpunit-phpstan-dba-mysqli.cache index 4b5be0233..7a37cd3f4 100644 --- a/tests/defaultFetchNumeric/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/defaultFetchNumeric/config/.phpunit-phpstan-dba-mysqli.cache @@ -1,6 +1,6 @@ 'v9-put-null-when-valid', - 'schemaHash' => NULL, + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( 'SELECT email, adaid FROM ada' => diff --git a/tests/rules/SyntaxErrorInDibiPreparedStatementMethodRuleTest.php b/tests/rules/SyntaxErrorInDibiPreparedStatementMethodRuleTest.php new file mode 100644 index 000000000..eafedbc3c --- /dev/null +++ b/tests/rules/SyntaxErrorInDibiPreparedStatementMethodRuleTest.php @@ -0,0 +1,169 @@ + + */ +class SyntaxErrorInDibiPreparedStatementMethodRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return self::getContainer()->getByType(SyntaxErrorInDibiPreparedStatementMethodRule::class); + } + + public static function getAdditionalConfigFiles(): array + { + return [ + __DIR__.'/../../config/dba.neon', + ]; + } + + public function testSyntaxErrorInQueryRule(): void + { + if (\PHP_VERSION_ID < 70400) { + self::markTestSkipped('Test requires PHP 7.4.'); + } + + if (MysqliQueryReflector::NAME === getenv('DBA_REFLECTOR')) { + $expectedErrors = [ + [ + "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", + 13, + ], + [ + "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", + 19, + ], + [ + "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", + 25, + ], + [ + 'fetchSingle requires exactly 1 selected column, got 2.', + 26, + ], + [ + "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", + 32, + ], + [ + 'fetchPairs requires exactly 2 selected columns, got 1.', + 33, + ], + [ + 'Query expects 1 placeholder, but no values are given.', + 39, + ], + [ + 'Query expects 0 placeholder, but 1 value is given.', + 40, + ], + /* + phpstan-dba does not yet support writable queries + [ + "Query error: Table 'phpstan_dba.adasfd' doesn't exist (1146).", + 46, + ], + */ + ]; + } elseif (PdoPgSqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) { + $expectedErrors = [ + [ + 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" +LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 + ^ (42601).', + 13, + ], + [ + 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" +LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 + ^ (42601).', + 19, + ], + [ + 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" +LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 + ^ (42601).', + 25, + ], + [ + 'fetchSingle requires exactly 1 selected column, got 2.', + 26, + ], + [ + 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" +LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 + ^ (42601).', + 32, + ], + [ + 'fetchPairs requires exactly 2 selected columns, got 1.', + 33, + ], + [ + 'Query expects 1 placeholder, but no values are given.', + 39, + ], + [ + 'Query expects 0 placeholder, but 1 value is given.', + 40, + ], + ]; + } elseif (PdoMysqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) { + $expectedErrors = [ + [ + "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", + 13, + ], + [ + "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", + 19, + ], + [ + "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", + 25, + ], + [ + 'fetchSingle requires exactly 1 selected column, got 2.', + 26, + ], + [ + "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", + 32, + ], + [ + 'fetchPairs requires exactly 2 selected columns, got 1.', + 33, + ], + [ + 'Query expects 1 placeholder, but no values are given.', + 39, + ], + [ + 'Query expects 0 placeholder, but 1 value is given.', + 40, + ], + /* + phpstan-dba does not yet support writable queries + [ + "Query error: Table 'phpstan_dba.adasfd' doesn't exist (1146).", + 46, + ], + */ + ]; + } else { + throw new \RuntimeException('Unsupported DBA_REFLECTOR '.getenv('DBA_REFLECTOR')); + } + + require_once __DIR__.'/data/syntax-error-in-dibi-prepared-statement.php'; + $this->analyse([__DIR__.'/data/syntax-error-in-dibi-prepared-statement.php'], $expectedErrors); + } +} diff --git a/tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php b/tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php index 4bd75f090..88f32b8b4 100644 --- a/tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php +++ b/tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php @@ -78,26 +78,6 @@ public function testSyntaxErrorInQueryRule(): void "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'gesperrt freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).", 319, ], - [ - "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", - 335, - ], - [ - "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", - 336, - ], - [ - "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", - 337, - ], - [ - "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", - 338, - ], - [ - "Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (1064).", - 339, - ], ]; } elseif (PdoPgSqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) { $expectedErrors = [ @@ -167,36 +147,6 @@ public function testSyntaxErrorInQueryRule(): void ^ (42601).', 319, ], - [ - 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" -LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 - ^ (42601).', - 335, - ], - [ - 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" -LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 - ^ (42601).', - 336, - ], - [ - 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" -LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 - ^ (42601).', - 337, - ], - [ - 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" -LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 - ^ (42601).', - 338, - ], - [ - 'Query error: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "FROM" -LINE 1: SELECT email adaid WHERE gesperrt FROM ada LIMIT 0 - ^ (42601).', - 339, - ], ]; } elseif (PdoMysqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) { $expectedErrors = [ @@ -244,26 +194,6 @@ public function testSyntaxErrorInQueryRule(): void "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'gesperrt freigabe1u1 FROM ada LIMIT 0' at line 1 (42000).", 319, ], - [ - "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", - 335, - ], - [ - "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", - 336, - ], - [ - "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", - 337, - ], - [ - "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", - 338, - ], - [ - "Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'FROM ada LIMIT 0' at line 1 (42000).", - 339, - ], ]; } else { throw new \RuntimeException('Unsupported DBA_REFLECTOR '.getenv('DBA_REFLECTOR')); diff --git a/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache b/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache index 839a34da3..a8952f411 100644 --- a/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/rules/config/.phpunit-phpstan-dba-mysqli.cache @@ -1,6 +1,6 @@ 'v9-put-null-when-valid', - 'schemaHash' => NULL, + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( 'SELECT @@ -39,21 +39,8 @@ 5 => NULL, ), ), - 'SELECT * FROM ``' => - array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'Incorrect table name \'\'', - 'code' => 1103, - )), - 'result' => - array ( - 5 => NULL, - ), - ), 'SELECT * FROM `ada` WHERE adaid = 1' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -398,7 +385,6 @@ ), 'SELECT * FROM ada WHERE adaid = \'1\'' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -569,7 +555,6 @@ ), 'SELECT * FROM ada WHERE email = \'1970-01-01\'' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -1250,10 +1235,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'code' => 1064, )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT adaid FROM ada WHERE email = \'1970-01-01\'' => array ( @@ -1364,6 +1345,102 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'code' => 1054, )), ), + 'SELECT email FROM ada' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT email FROM ada WHERE adaid IN (\'1\')' => array ( 'error' => NULL, @@ -1379,6 +1456,90 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 5 => NULL, ), ), + 'SELECT email FROM ada where email = ""' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email FROM ada where email = \'1\'' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT email adaid WHERE gesperrt = \'1\' AND email LIKE \'%@example.com\' FROM ada @@ -1607,21 +1768,8 @@ Simulated query: SELECT FROM WHERE LIMIT 0', )), ), ), - 'SELECT email, adaid FROM `` WHERE adaid = \'1\'' => - array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'Incorrect table name \'\'', - 'code' => 1103, - )), - 'result' => - array ( - 5 => NULL, - ), - ), 'SELECT email, adaid FROM ada' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -1934,18 +2082,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'code' => 1054, )), ), - 'SELECT email, adaid FROM ada WHERE' => - array ( - 'error' => - staabm\PHPStanDba\Error::__set_state(array( - 'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'LIMIT 0\' at line 1', - 'code' => 1064, - )), - 'result' => - array ( - 5 => NULL, - ), - ), 'SELECT email, adaid FROM ada WHERE adaid = \'1\'' => array ( 'result' => @@ -3193,6 +3329,180 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'code' => 1054, )), ), + 'SELECT email,adaid FROM ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 1, + )), + 2 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 2, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 2 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 1, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + 2 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 3 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT with syntax error GROUPY by x' => array ( 'error' => diff --git a/tests/rules/config/.phpunit-phpstan-dba-pdo-mysql.cache b/tests/rules/config/.phpunit-phpstan-dba-pdo-mysql.cache index af19bf4fb..f5419db5a 100644 --- a/tests/rules/config/.phpunit-phpstan-dba-pdo-mysql.cache +++ b/tests/rules/config/.phpunit-phpstan-dba-pdo-mysql.cache @@ -375,10 +375,6 @@ 'message' => 'SQLSTATE[42S22]: Column not found: 1054 Unknown column \'doesNotExist\' in \'group statement\'', 'code' => '42S22', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT * FROM ada ORDER BY doesNotExist' => array ( @@ -387,10 +383,6 @@ 'message' => 'SQLSTATE[42S22]: Column not found: 1054 Unknown column \'doesNotExist\' in \'order clause\'', 'code' => '42S22', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT * FROM ada WHERE adaid = \'1\'' => array ( @@ -562,10 +554,6 @@ 'message' => 'SQLSTATE[42S22]: Column not found: 1054 Unknown column \'doesNotExist\' in \'where clause\'', 'code' => '42S22', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT * FROM ada WHERE email = \'1970-01-01\'' => array ( @@ -1061,10 +1049,6 @@ 'message' => 'SQLSTATE[42S02]: Base table or view not found: 1146 Table \'phpstan_dba.unknown_table\' doesn\'t exist', 'code' => '42S02', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT *,adaid FROM `ada` WHERE email = \'test@example.com\'' => array ( @@ -1367,9 +1351,102 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42S22]: Column not found: 1054 Unknown column \'doesNotExist\' in \'field list\'', 'code' => '42S22', )), + ), + 'SELECT email FROM ada' => + array ( + 'error' => NULL, 'result' => array ( - 5 => NULL, + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), ), ), 'SELECT email FROM ada WHERE adaid IN (\'1\')' => @@ -1387,6 +1464,132 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 5 => NULL, ), ), + 'SELECT email FROM ada where email = ""' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email FROM ada where email = "1"' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT email FROM ada where email = \'1\'' => + array ( + 'result' => + array ( + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 'itemType' => + PHPStan\Type\StringType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT email adaid WHERE gesperrt = \'1\' AND email LIKE \'%@example.com\' FROM ada @@ -1405,6 +1608,10 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'FROM ada LIMIT 0\' at line 1', 'code' => '42000', )), + 'result' => + array ( + 3 => NULL, + ), ), 'SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada' => array ( @@ -1413,11 +1620,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'freigabe1u1 FROM ada LIMIT 0\' at line 1', 'code' => '42000', )), - 'result' => - array ( - 5 => NULL, - 3 => NULL, - ), ), 'SELECT email adaid gesperrt freigabe1u1 FROM ada' => array ( @@ -1426,10 +1628,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'gesperrt freigabe1u1 FROM ada LIMIT 0\' at line 1', 'code' => '42000', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT email, adaid FROM ada @@ -1937,10 +2135,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42S22]: Column not found: 1054 Unknown column \'xy\' in \'group statement\'', 'code' => '42S22', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT email, adaid FROM ada WHERE' => array ( @@ -2100,7 +2294,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', ), 'SELECT email, adaid FROM ada WHERE email=\'my_other_table\' LIMIT 1' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -2212,10 +2405,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near \'FROM ada LIMIT 0\' at line 1', 'code' => '42000', )), - 'result' => - array ( - 5 => NULL, - ), ), 'SELECT email, adaid GROUP BY xy FROM ada WHERE email=\'my_other_table\' LIMIT 1' => array ( @@ -2226,7 +2415,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', ), 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada' => array ( - 'error' => NULL, 'result' => array ( 3 => @@ -2500,7 +2688,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', ), 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada LIMIT 1' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -2663,7 +2850,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', ), 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada WHERE email=\'my_other_table\' LIMIT 1' => array ( - 'error' => NULL, 'result' => array ( 5 => @@ -3022,11 +3208,6 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'message' => 'SQLSTATE[42S22]: Column not found: 1054 Unknown column \'asdsa\' in \'where clause\'', 'code' => '42S22', )), - 'result' => - array ( - 3 => NULL, - 5 => NULL, - ), ), 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada WHERE gesperrt=\'1\'' => array ( @@ -3214,6 +3395,181 @@ Simulated query: SELECT FROM WHERE LIMIT 0', 'code' => '42S22', )), ), + 'SELECT email,adaid FROM ada' => + array ( + 'error' => NULL, + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 1, + )), + 2 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 2, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 2 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 1, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\StringType::__set_state(array( + )), + 2 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + 3 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + 3 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + ), + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 0, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerRangeType::__set_state(array( + 'min' => -32768, + 'max' => 32767, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT with syntax error GROUPY by x' => array ( 'error' => diff --git a/tests/rules/data/syntax-error-in-dibi-prepared-statement.php b/tests/rules/data/syntax-error-in-dibi-prepared-statement.php new file mode 100644 index 000000000..1fa1db190 --- /dev/null +++ b/tests/rules/data/syntax-error-in-dibi-prepared-statement.php @@ -0,0 +1,59 @@ +query('SELECT email adaid WHERE gesperrt FROM ada'); + $conn->query('SELECT email,adaid FROM ada'); + } + + public function testFetch(\Dibi\Connection $conn) + { + $conn->fetch('SELECT email adaid WHERE gesperrt FROM ada'); + $conn->fetch('SELECT email,adaid FROM ada'); + } + + public function testFetchSingle(\Dibi\Connection $conn) + { + $conn->fetchSingle('SELECT email adaid WHERE gesperrt FROM ada'); + $conn->fetchSingle('SELECT email,adaid FROM ada'); + $conn->fetchSingle('SELECT email FROM ada'); + } + + public function testFetchPairs(\Dibi\Connection $conn) + { + $conn->fetchPairs('SELECT email adaid WHERE gesperrt FROM ada'); + $conn->fetchPairs('SELECT email FROM ada'); + $conn->fetchPairs('SELECT email,adaid FROM ada'); + } + + public function testPlaceholders(\Dibi\Connection $conn) + { + $conn->fetchPairs('SELECT email FROM ada where email = %s'); + $conn->fetchPairs('SELECT email FROM ada where email = ""', 1); + $conn->fetchPairs('SELECT email FROM ada where email = %s', 'email@github.com'); + } + + /* phpstan-dba does not yet support writable queries + public function testDeleteUpdateInsert(\Dibi\Connection $conn) + { + $conn->query('DELETE from adasfd'); + $conn->query('DELETE from ada'); + $conn->query('UPDATE ada set email = ""'); + $conn->query('INSERT into ada', [ + 'email' => 'sdf', + ]); + $conn->query('INSERT into %n', 'ada', [ + 'email' => 'sdf', + ]); + } + */ + +} diff --git a/tests/rules/data/syntax-error-in-prepared-statement.php b/tests/rules/data/syntax-error-in-prepared-statement.php index 21dfdc61e..3b1d119f6 100644 --- a/tests/rules/data/syntax-error-in-prepared-statement.php +++ b/tests/rules/data/syntax-error-in-prepared-statement.php @@ -329,21 +329,4 @@ public function bug442(Connection $conn, string $table) $conn->executeQuery("SELECT * FROM `$table`"); } - public function dibiTest(\Dibi\Connection $conn) - { - // syntax error, should expect a error in the test - $conn->fetch('SELECT email adaid WHERE gesperrt FROM ada'); - $conn->fetchSingle('SELECT email adaid WHERE gesperrt FROM ada'); - $conn->query('SELECT email adaid WHERE gesperrt FROM ada'); - $conn->fetchPairs('SELECT email adaid WHERE gesperrt FROM ada'); - $conn->fetchAll('SELECT email adaid WHERE gesperrt FROM ada'); - // all good, no error expected - $conn->fetch('SELECT email, adaid FROM ada'); - $conn->fetchSingle('SELECT email, adaid FROM ada'); - $conn->query('SELECT email, adaid FROM ada'); - $conn->fetchPairs('SELECT email, adaid FROM ada'); - $conn->fetchAll('SELECT email, adaid FROM ada'); - $conn->query('UPDATE ada set', ['email' => 'test@github.com'], ' where adaid = 1'); - } - } diff --git a/tests/stringify/config/.phpunit-phpstan-dba-mysqli.cache b/tests/stringify/config/.phpunit-phpstan-dba-mysqli.cache index 8652bf2b7..452568e16 100644 --- a/tests/stringify/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/stringify/config/.phpunit-phpstan-dba-mysqli.cache @@ -1,6 +1,6 @@ 'v9-put-null-when-valid', - 'schemaHash' => NULL, + 'schemaHash' => '978ac93a0dacd29d0a93b7827aa3319c', 'records' => array ( 'SELECT email, adaid, gesperrt, freigabe1u1 FROM ada' =>