Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
clxmstaab committed Apr 28, 2022
1 parent f2be74b commit e0aafdc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Analyser/MutatingScope.php
Expand Up @@ -62,6 +62,7 @@
use PHPStan\TrinaryLogic;
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
use PHPStan\Type\Accessory\AccessoryNumericStringType;
use PHPStan\Type\Accessory\NonEmptyArrayType;
use PHPStan\Type\ArrayType;
use PHPStan\Type\BenevolentUnionType;
Expand Down Expand Up @@ -688,8 +689,21 @@ private function resolveType(Expr $node): Type
if ($type instanceof ConstantStringType) {
return new ConstantStringType(~$type->getValue());
}
if ($type instanceof StringType) {
return new StringType();
if ($type->isString()->yes()) {
$accessories = [
new StringType(),
];
if ($type->isNonEmptyString()->yes()) {
$accessories[] = new AccessoryNonEmptyStringType();
}
if ($type->isLiteralString()->yes()) {
$accessories[] = new AccessoryLiteralStringType();
}
if ($type->isNumericString()->yes()) {
$accessories[] = new AccessoryNumericStringType();
}

return TypeCombinator::intersect(...$accessories);
}
if ($type instanceof IntegerType || $type instanceof FloatType) {
return new IntegerType(); //no const types here, result depends on PHP_INT_SIZE
Expand Down

0 comments on commit e0aafdc

Please sign in to comment.