Skip to content

Commit 64f82bb

Browse files
committed
MinMaxFunctionReturnTypeExtension: Cleanup instanceof ConstantScalarType
1 parent 2132cc0 commit 64f82bb

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ parameters:
14251425

14261426
-
14271427
message: "#^Doing instanceof PHPStan\\\\Type\\\\ConstantScalarType is error\\-prone and deprecated\\. Use Type\\:\\:isConstantScalarValue\\(\\) or Type\\:\\:getConstantScalarTypes\\(\\) or Type\\:\\:getConstantScalarValues\\(\\) instead\\.$#"
1428-
count: 4
1428+
count: 2
14291429
path: src/Type/Php/MinMaxFunctionReturnTypeExtension.php
14301430

14311431
-

src/Type/Php/MinMaxFunctionReturnTypeExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ private function compareTypes(
187187
{
188188
if (
189189
$firstType->isConstantArray()->yes()
190-
&& $secondType instanceof ConstantScalarType
190+
&& $secondType->isConstantScalarValue()->yes()
191191
) {
192192
return $secondType;
193193
}
194194

195195
if (
196-
$firstType instanceof ConstantScalarType
196+
$firstType->isConstantScalarValue()->yes()
197197
&& $secondType->isConstantArray()->yes()
198198
) {
199199
return $firstType;

tests/PHPStan/Analyser/LegacyNodeScopeResolverTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,14 +2363,18 @@ public function dataBinaryOperations(): array
23632363
'array<int>',
23642364
'max($arrayOfUnknownIntegers, $arrayOfUnknownIntegers)',
23652365
],
2366-
/*[
2367-
'array(1, 1, 1, 1)',
2366+
[
2367+
'array{1, 1, 1, 1}',
23682368
'max(array(2, 2, 2), 5, array(1, 1, 1, 1))',
23692369
],
2370-
[
2370+
/*[
23712371
'array<int>',
23722372
'max($arrayOfUnknownIntegers, $integer, $arrayOfUnknownIntegers)',
23732373
],*/
2374+
[
2375+
'5',
2376+
'min(array(2, 2, 2), 5, array(1, 1, 1, 1))',
2377+
],
23742378
[
23752379
'1.1',
23762380
'min(...[1.1, 2.2, 3.3])',

0 commit comments

Comments
 (0)