diff --git a/.phpstan-dba-mysqli.cache b/.phpstan-dba-mysqli.cache index e36d9741e..ea4c79acc 100644 --- a/.phpstan-dba-mysqli.cache +++ b/.phpstan-dba-mysqli.cache @@ -926,6 +926,78 @@ )), ), ), + '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 * FROM ada' => array ( 'result' => @@ -10230,6 +10302,758 @@ )), ), ), + 'SELECT sum(akid) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(c_double) as sum from typemix' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(eladaid) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(freigabe1u1) as sum 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|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(freigabe1u1) as sum from ak' => + array ( + 'error' => + staabm\PHPStanDba\Error::__set_state(array( + 'message' => 'Unknown column \'freigabe1u1\' in \'field list\'', + 'code' => 1054, + )), + ), + 'SELECT sum(null) as sum 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|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(null) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT ucase(c_varbinary25) as field from typemix' => array ( 'result' => diff --git a/src/SqlAst/QueryScope.php b/src/SqlAst/QueryScope.php index 62de1c29a..9a9ea7ce4 100644 --- a/src/SqlAst/QueryScope.php +++ b/src/SqlAst/QueryScope.php @@ -59,6 +59,7 @@ public function __construct(Table $fromTable, array $joinedTables) new InstrReturnTypeExtension(), new StrCaseReturnTypeExtension(), new AvgReturnTypeExtension(), + new SumReturnTypeExtension(), new IsNullReturnTypeExtension(), new AbsReturnTypeExtension(), new RoundReturnTypeExtension(), diff --git a/src/SqlAst/SumReturnTypeExtension.php b/src/SqlAst/SumReturnTypeExtension.php new file mode 100644 index 000000000..596f68d2b --- /dev/null +++ b/src/SqlAst/SumReturnTypeExtension.php @@ -0,0 +1,52 @@ +getFunction()->getName(), [BuiltInFunction::SUM], true); + } + + public function getReturnType(FunctionCall $expression, QueryScope $scope): ?Type + { + $args = $expression->getArguments(); + + if (1 !== \count($args)) { + return null; + } + + $argType = $scope->getType($args[0]); + if ($argType->isNull()->yes()) { + return new NullType(); + } + + $containsNull = TypeCombinator::containsNull($argType); + $argType = TypeCombinator::removeNull($argType); + if ($argType->isInteger()->yes()) { + // sum(IntegerRange) is a unbound integer + $result = new IntegerType(); + } elseif ($argType->isFloat()->yes()) { + $result = new FloatType(); + } else { + $result = $argType; + } + + if ($containsNull) { + $result = TypeCombinator::addNull($result); + } + + return $result; + } +} diff --git a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache index e90705429..8e6d1199b 100644 --- a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache @@ -239,6 +239,78 @@ )), ), ), + '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 * FROM ada' => array ( 'result' => @@ -16350,6 +16422,641 @@ FROM ada' => )), ), ), + 'SELECT sum(akid) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(c_double) as sum from typemix' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(eladaid) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(freigabe1u1) as sum 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|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(null) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT ucase(c_varbinary25) as field from typemix' => 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 c4dd815dd..6f39545d9 100644 --- a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache +++ b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache @@ -239,6 +239,78 @@ )), ), ), + '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 * FROM ada' => array ( 'result' => @@ -15351,6 +15423,502 @@ FROM ada' => )), ), ), + 'SELECT sum(akid) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(c_double) as sum from typemix' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(eladaid) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\IntersectionType::__set_state(array( + 'sortedTypes' => false, + 'types' => + array ( + 0 => + PHPStan\Type\StringType::__set_state(array( + )), + 1 => + PHPStan\Type\Accessory\AccessoryNumericStringType::__set_state(array( + )), + ), + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), + 'SELECT sum(null) as sum from ak' => + array ( + 'result' => + array ( + 5 => + PHPStan\Type\Constant\ConstantArrayType::__set_state(array( + 'keyType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => true, + 'cachedDescriptions' => + array ( + 2 => '0|\'sum\'', + ), + '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' => 'sum', + 'isClassString' => false, + )), + ), + 'normalized' => false, + )), + 'itemType' => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 'allArrays' => NULL, + 'nextAutoIndexes' => + array ( + 0 => 1, + ), + 'keyTypes' => + array ( + 0 => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'sum', + 'isClassString' => false, + )), + 1 => + PHPStan\Type\Constant\ConstantIntegerType::__set_state(array( + 'value' => 0, + )), + ), + 'valueTypes' => + array ( + 0 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + 1 => + PHPStan\Type\UnionType::__set_state(array( + 'sortedTypes' => false, + 'cachedDescriptions' => + array ( + ), + 'types' => + array ( + 0 => + PHPStan\Type\FloatType::__set_state(array( + )), + 1 => + PHPStan\Type\NullType::__set_state(array( + )), + ), + 'normalized' => true, + )), + ), + 'optionalKeys' => + array ( + ), + 'isList' => false, + )), + ), + ), 'SELECT ucase(c_varbinary25) as field from typemix' => array ( 'result' => diff --git a/tests/default/data/sql-ast-narrowing.php b/tests/default/data/sql-ast-narrowing.php index 0f4ef4151..daeea4ada 100644 --- a/tests/default/data/sql-ast-narrowing.php +++ b/tests/default/data/sql-ast-narrowing.php @@ -264,4 +264,19 @@ public function round(PDO $pdo): void $stmt = $pdo->query('SELECT round(1.12, 1) as abs from ak'); assertType('PDOStatement', $stmt); } + + public function sum(PDO $pdo): void + { + $stmt = $pdo->query('SELECT sum(null) as sum from ak'); + assertType('PDOStatement', $stmt); + + $stmt = $pdo->query('SELECT sum(akid) as sum from ak'); + assertType('PDOStatement', $stmt); + + $stmt = $pdo->query('SELECT sum(eladaid) as sum from ak'); + assertType('PDOStatement', $stmt); + + $stmt = $pdo->query('SELECT sum(c_double) as sum from typemix'); + assertType('PDOStatement', $stmt); + } }