Skip to content

Commit 8384520

Browse files
committed
[BCB] Removed Scope::doNotTreatPhpDocTypesAsCertain(), use getNativeType() instead
1 parent 438d2e9 commit 8384520

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,4 @@ Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createRefle
261261
* Remove `TypeUtils::getConstantScalars()`, use [`Type::isConstantScalarValue()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isConstantScalarValue) or [`Type::getConstantScalarTypes()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_getConstantScalarTypes) instead
262262
* Remove `TypeUtils::getEnumCaseObjects()`, use [`Type::getEnumCases()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_getEnumCases) instead
263263
* Remove `TypeUtils::containsCallable()`, use [`Type::isCallable()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isCallable) instead
264+
* Removed `Scope::doNotTreatPhpDocTypesAsCertain()`, use `getNativeType()` instead

src/Analyser/MutatingScope.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,10 +2587,6 @@ public function getKeepVoidType(Expr $node): Type
25872587
return $this->getType($clonedNode);
25882588
}
25892589

2590-
/**
2591-
* @api
2592-
* @deprecated Use getNativeType()
2593-
*/
25942590
public function doNotTreatPhpDocTypesAsCertain(): Scope
25952591
{
25962592
return $this->promoteNativeTypes();

src/Analyser/Scope.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ public function getNativeType(Expr $expr): Type;
9191

9292
public function getKeepVoidType(Expr $node): Type;
9393

94-
/**
95-
* @deprecated Use getNativeType()
96-
*/
97-
public function doNotTreatPhpDocTypesAsCertain(): self;
98-
9994
public function resolveName(Name $name): string;
10095

10196
public function resolveTypeByName(Name $name): TypeWithClassName;

src/Rules/Comparison/ImpossibleCheckTypeHelper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
use PhpParser\Node\Expr\FuncCall;
99
use PhpParser\Node\Expr\MethodCall;
1010
use PhpParser\Node\Expr\StaticCall;
11+
use PHPStan\Analyser\MutatingScope;
1112
use PHPStan\Analyser\Scope;
1213
use PHPStan\Analyser\TypeSpecifier;
1314
use PHPStan\Analyser\TypeSpecifierContext;
1415
use PHPStan\Reflection\ParametersAcceptorSelector;
1516
use PHPStan\Reflection\ReflectionProvider;
17+
use PHPStan\ShouldNotHappenException;
1618
use PHPStan\TrinaryLogic;
1719
use PHPStan\Type\Constant\ConstantArrayType;
1820
use PHPStan\Type\Constant\ConstantBooleanType;
@@ -234,6 +236,10 @@ public function findSpecifiedType(
234236
}
235237
}
236238

239+
if (!$scope instanceof MutatingScope) {
240+
throw new ShouldNotHappenException();
241+
}
242+
237243
$typeSpecifierScope = $this->treatPhpDocTypesAsCertain ? $scope : $scope->doNotTreatPhpDocTypesAsCertain();
238244
$specifiedTypes = $this->typeSpecifier->specifyTypesInCondition($typeSpecifierScope, $node, $this->determineContext($typeSpecifierScope, $node));
239245

0 commit comments

Comments
 (0)