Skip to content

Commit a5297b0

Browse files
committed
[BCB] Remove ConstantType interface
1 parent f302c90 commit a5297b0

File tree

7 files changed

+4
-22
lines changed

7 files changed

+4
-22
lines changed

UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,4 @@ Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createRefle
274274
* Remove `TypeUtils::containsCallable()`, use [`Type::isCallable()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isCallable) instead
275275
* Removed `Scope::doNotTreatPhpDocTypesAsCertain()`, use `getNativeType()` instead
276276
* Parameter `$isList` in `ConstantArrayType` constructor can only be `TrinaryLogic`, no longer bool
277+
* Remove `ConstantType` interface, use [`Type::isConstantValue()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isConstantValue) instead

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,11 +1285,6 @@ parameters:
12851285
count: 4
12861286
path: src/Type/Php/MinMaxFunctionReturnTypeExtension.php
12871287

1288-
-
1289-
message: "#^Doing instanceof PHPStan\\\\Type\\\\ConstantType is error\\-prone and deprecated\\. Use Type\\:\\:isConstantValue\\(\\) or Type\\:\\:generalize\\(\\) instead\\.$#"
1290-
count: 1
1291-
path: src/Type/Php/MinMaxFunctionReturnTypeExtension.php
1292-
12931288
-
12941289
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantArrayType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantArrays\\(\\) instead\\.$#"
12951290
count: 2

src/Rules/Api/ApiInstanceofTypeRule.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use PHPStan\Type\Constant\ConstantBooleanType;
3030
use PHPStan\Type\Constant\ConstantStringType;
3131
use PHPStan\Type\ConstantScalarType;
32-
use PHPStan\Type\ConstantType;
3332
use PHPStan\Type\Enum\EnumCaseObjectType;
3433
use PHPStan\Type\FloatType;
3534
use PHPStan\Type\Generic\GenericClassStringType;
@@ -75,7 +74,6 @@ final class ApiInstanceofTypeRule implements Rule
7574
GenericClassStringType::class => 'Type::isClassStringType() and Type::getClassStringObjectType()',
7675
GenericObjectType::class => null,
7776
IntersectionType::class => null,
78-
ConstantType::class => 'Type::isConstantValue() or Type::generalize()',
7977
ConstantScalarType::class => 'Type::isConstantScalarValue() or Type::getConstantScalarTypes() or Type::getConstantScalarValues()',
8078
ObjectShapeType::class => 'Type::isObject() and Type::hasProperty()',
8179

src/Type/Constant/ConstantArrayType.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
use PHPStan\Type\BooleanType;
3131
use PHPStan\Type\CompoundType;
3232
use PHPStan\Type\ConstantScalarType;
33-
use PHPStan\Type\ConstantType;
3433
use PHPStan\Type\ErrorType;
3534
use PHPStan\Type\GeneralizePrecision;
3635
use PHPStan\Type\Generic\TemplateTypeMap;
@@ -71,7 +70,7 @@
7170
/**
7271
* @api
7372
*/
74-
class ConstantArrayType implements ConstantType
73+
class ConstantArrayType implements Type
7574
{
7675

7776
use ArrayTypeTrait {

src/Type/ConstantScalarType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PHPStan\Type;
44

55
/** @api */
6-
interface ConstantScalarType extends ConstantType
6+
interface ConstantScalarType extends Type
77
{
88

99
/**

src/Type/ConstantType.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Type/Php/MinMaxFunctionReturnTypeExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PHPStan\Type\Constant\ConstantArrayType;
1212
use PHPStan\Type\Constant\ConstantBooleanType;
1313
use PHPStan\Type\ConstantScalarType;
14-
use PHPStan\Type\ConstantType;
1514
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
1615
use PHPStan\Type\ErrorType;
1716
use PHPStan\Type\Type;
@@ -152,10 +151,9 @@ private function processType(
152151
{
153152
$resultType = null;
154153
foreach ($types as $type) {
155-
if (!$type instanceof ConstantType) {
154+
if (!$type->isConstantValue()->yes()) {
156155
return TypeCombinator::union(...$types);
157156
}
158-
159157
if ($resultType === null) {
160158
$resultType = $type;
161159
continue;

0 commit comments

Comments
 (0)