Skip to content

Commit 9c3f7ae

Browse files
Simplify
1 parent 42c4b04 commit 9c3f7ae

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Diff for: src/Type/Doctrine/Query/QueryResultTypeWalker.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -944,11 +944,8 @@ public function walkAggregateExpression($aggExpression): string
944944
$this->walkSimpleArithmeticExpression($aggExpression->pathExpression)
945945
);
946946

947-
if (count($type->getConstantScalarValues()) !== 1) {
948-
$type = TypeUtils::generalizeType($type, GeneralizePrecision::lessSpecific());
949-
}
950-
951-
$type = TypeCombinator::union($type, $type->toFloat(), $type->toFloat()->toString());
947+
$type = TypeCombinator::union($type, $type->toFloat());
948+
$type = TypeUtils::generalizeType($type, GeneralizePrecision::lessSpecific());
952949

953950
return $this->marshalType(TypeCombinator::addNull($type));
954951

Diff for: tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPStan\Testing\PHPStanTestCase;
1515
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1616
use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
17-
use PHPStan\Type\Constant\ConstantFloatType;
1817
use PHPStan\Type\Constant\ConstantIntegerType;
1918
use PHPStan\Type\Constant\ConstantStringType;
2019
use PHPStan\Type\ConstantTypeHelper;
@@ -723,10 +722,8 @@ public function getTestData(): iterable
723722
[
724723
new ConstantIntegerType(5),
725724
TypeCombinator::union(
726-
new ConstantStringType('1'),
727-
new ConstantIntegerType(1),
728-
new ConstantStringType('1.0'),
729-
new ConstantFloatType(1.0),
725+
$this->intStringified(),
726+
new FloatType(),
730727
new NullType()
731728
),
732729
],

0 commit comments

Comments
 (0)