diff --git a/.phpstan-dba-mysqli.cache b/.phpstan-dba-mysqli.cache index ea4c79acc..d8aaabbad 100644 --- a/.phpstan-dba-mysqli.cache +++ b/.phpstan-dba-mysqli.cache @@ -3,207 +3,6 @@ '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, - 'cachedDescriptions' => - array ( - 2 => '0|1|2|\'COLUMN_NAME\'|\'COLUMN_TYPE\'|\'EXTRA\'', - 1 => 'int|string', - ), - '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, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - 5 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'EXTRA', - 'isClassString' => false, - )), - 'value' => 'EXTRA', - 'isClassString' => false, - )), - 'value' => 'EXTRA', - 'isClassString' => false, - )), - ), - 'normalized' => 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, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - '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, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'EXTRA', - 'isClassString' => false, - )), - 'value' => 'EXTRA', - 'isClassString' => false, - )), - 'value' => 'EXTRA', - 'isClassString' => false, - )), - 3 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 1, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - 'value' => 'COLUMN_TYPE', - 'isClassString' => false, - )), - '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 MD5( GROUP_CONCAT( @@ -471,78 +270,6 @@ )), ), ), - 'SELECT - CASE - WHEN freigabe1u1 > 50 THEN \'big-one\' - WHEN freigabe1u1 = 50 THEN \'normal\' - ELSE freigabe1u1 - END as val from ada' => - array ( - 'result' => - array ( - 5 => - PHPStan\Type\Constant\ConstantArrayType::__set_state(array( - 'keyType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'cachedDescriptions' => - array ( - 2 => '0|\'val\'', - ), - 'types' => - array ( - 0 => - PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( - 'value' => 0, - )), - 1 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'val', - 'isClassString' => false, - )), - ), - 'normalized' => 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, - 'arrayKeyType' => NULL, - 'value' => 'val', - '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 coalesce(COLUMN_NAME, "") as COLUMN_NAME, coalesce(EXTRA, "") as EXTRA, @@ -4719,213 +4446,6 @@ )), ), ), - '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, - 'cachedDescriptions' => - array ( - 2 => '0|1|2|\'COLUMN_DEFAULT\'|\'COLUMN_NAME\'|\'IS_NULLABLE\'', - 1 => 'int|string', - ), - '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, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_DEFAULT', - 'isClassString' => false, - )), - 'value' => 'COLUMN_DEFAULT', - 'isClassString' => false, - )), - 4 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - 5 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'IS_NULLABLE', - 'isClassString' => false, - )), - 'value' => 'IS_NULLABLE', - 'isClassString' => false, - )), - ), - 'normalized' => false, - )), - 'itemType' => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'cachedDescriptions' => - array ( - 1 => 'string|null', - ), - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - 'normalized' => true, - )), - 'allArrays' => NULL, - 'nextAutoIndexes' => - array ( - 0 => 3, - ), - 'keyTypes' => - array ( - 0 => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_NAME', - 'isClassString' => false, - )), - '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, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'COLUMN_DEFAULT', - 'isClassString' => false, - )), - '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, - 'arrayKeyType' => - PHPStan\Type\Constant\ConstantStringType::__set_state(array( - 'objectType' => NULL, - 'arrayKeyType' => NULL, - 'value' => 'IS_NULLABLE', - 'isClassString' => false, - )), - '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, - 'cachedDescriptions' => - array ( - 4 => 'string|null', - ), - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - 'normalized' => true, - )), - 3 => - PHPStan\Type\UnionType::__set_state(array( - 'sortedTypes' => true, - 'cachedDescriptions' => - array ( - 4 => 'string|null', - ), - 'types' => - array ( - 0 => - PHPStan\Type\StringType::__set_state(array( - )), - 1 => - PHPStan\Type\NullType::__set_state(array( - )), - ), - 'normalized' => true, - )), - 4 => - PHPStan\Type\StringType::__set_state(array( - )), - 5 => - PHPStan\Type\StringType::__set_state(array( - )), - ), - 'optionalKeys' => - array ( - ), - 'isList' => false, - )), - ), - ), 'SELECT column_name, column_default, is_nullable FROM information_schema.columns WHERE table_name = \'1970-01-01\'' => @@ -6015,6 +5535,73 @@ )), ), ), + 'SELECT count(*) as myemail from ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'myemail\'', + ), + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'myemail', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\IntegerType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'myemail', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT count(email) as myemail from ada' => array ( 'result' => diff --git a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache index 8e6d1199b..19d2e0704 100644 --- a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache @@ -9101,6 +9101,73 @@ FROM ada' => )), ), ), + 'SELECT count(*) as myemail from ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'myemail\'', + ), + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'myemail', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\IntegerType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'myemail', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT count(email) as myemail from ada' => array ( 'result' => diff --git a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache index 6f39545d9..0ff658557 100644 --- a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache +++ b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache @@ -8399,6 +8399,73 @@ FROM ada' => )), ), ), + 'SELECT count(*) as myemail from ada' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'myemail\'', + ), + 'types' => + array ( + 0 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + 1 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'myemail', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\IntegerType::__set_state(array( + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'myemail', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\IntegerType::__set_state(array( + )), + 1 => + PHPStan\Type\IntegerType::__set_state(array( + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT count(email) as myemail from ada' => array ( 'result' => diff --git a/tests/default/data/sql-ast-narrowing.php b/tests/default/data/sql-ast-narrowing.php index daeea4ada..fd14482b2 100644 --- a/tests/default/data/sql-ast-narrowing.php +++ b/tests/default/data/sql-ast-narrowing.php @@ -9,6 +9,9 @@ class Foo { public function count(PDO $pdo): void { + $stmt = $pdo->query('SELECT count(*) as myemail from ada'); + assertType('PDOStatement, 0: int<0, max>}>', $stmt); + $stmt = $pdo->query('SELECT count(email) as myemail from ada'); assertType('PDOStatement, 0: int<0, max>}>', $stmt);