Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1719,30 +1719,12 @@ parameters:
count: 5
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\BooleanType is error\-prone and deprecated\. Use Type\:\:isBoolean\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\CallableType is error\-prone and deprecated\. Use Type\:\:isCallable\(\) and Type\:\:getCallableParametersAcceptors\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\ClassStringType is error\-prone and deprecated\. Use Type\:\:isClassStringType\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\ConstantScalarType is error\-prone and deprecated\. Use Type\:\:isConstantScalarValue\(\) or Type\:\:getConstantScalarTypes\(\) or Type\:\:getConstantScalarValues\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\Constant\\ConstantArrayType is error\-prone and deprecated\. Use Type\:\:getConstantArrays\(\) instead\.$#'
identifier: phpstanApi.instanceofType
Expand All @@ -1755,24 +1737,12 @@ parameters:
count: 5
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\FloatType is error\-prone and deprecated\. Use Type\:\:isFloat\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\Generic\\GenericClassStringType is error\-prone and deprecated\. Use Type\:\:isClassStringType\(\) and Type\:\:getClassStringObjectType\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 2
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\IntegerType is error\-prone and deprecated\. Use Type\:\:isInteger\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\IntersectionType is error\-prone and deprecated\.$#'
identifier: phpstanApi.instanceofType
Expand All @@ -1797,12 +1767,6 @@ parameters:
count: 2
path: src/Type/TypeCombinator.php

-
message: '#^Doing instanceof PHPStan\\Type\\StringType is error\-prone and deprecated\. Use Type\:\:isString\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/TypeCombinator.php

-
message: '#^Instanceof between PHPStan\\Type\\Constant\\ConstantIntegerType and PHPStan\\Type\\Constant\\ConstantIntegerType will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
Expand Down
10 changes: 5 additions & 5 deletions src/Type/TypeCombinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,22 @@ public static function union(Type ...$types): Type
$enumCaseTypes = [];
$integerRangeTypes = [];
for ($i = 0; $i < $typesCount; $i++) {
if ($types[$i] instanceof ConstantScalarType) {
if ($types[$i]->isConstantScalarValue()->yes()) {
$type = $types[$i];
$scalarTypes[get_class($type)][md5($type->describe(VerbosityLevel::cache()))] = $type;
unset($types[$i]);
continue;
}
if ($types[$i] instanceof BooleanType) {
if ($types[$i]->isBoolean()->yes()) {
$hasGenericScalarTypes[ConstantBooleanType::class] = true;
}
if ($types[$i] instanceof FloatType) {
if ($types[$i]->isFloat()->yes()) {
$hasGenericScalarTypes[ConstantFloatType::class] = true;
}
if ($types[$i] instanceof IntegerType && !$types[$i] instanceof IntegerRangeType) {
if ($types[$i]->isInteger()->yes() && !$types[$i] instanceof IntegerRangeType) {
$hasGenericScalarTypes[ConstantIntegerType::class] = true;
}
if ($types[$i] instanceof StringType && !$types[$i] instanceof ClassStringType) {
if ($types[$i]->isString()->yes() && $types[$i]->isClassString()->no() && TypeUtils::getAccessoryTypes($types[$i]) === []) {
$hasGenericScalarTypes[ConstantStringType::class] = true;
}
$enumCases = $types[$i]->getEnumCases();
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ public function testBug7094(): void
$this->assertSame('Return type of call to method Bug7094\Foo::getAttribute() contains unresolvable type.', $errors[4]->getMessage());
$this->assertSame(79, $errors[4]->getLine());

$this->assertSame('Parameter #1 $attr of method Bug7094\Foo::setAttributes() expects array{foo?: string, bar?: 5|6|7, baz?: bool}, non-empty-array<K of string, 5|6|7|bool|string> given.', $errors[5]->getMessage());
$this->assertSame('Parameter #1 $attr of method Bug7094\Foo::setAttributes() expects array{foo?: string, bar?: 5|6|7, baz?: bool}, non-empty-array<\'bar\'|\'baz\'|\'foo\'|K of string, 5|6|7|bool|string> given.', $errors[5]->getMessage());
$this->assertSame(29, $errors[5]->getLine());
}

Expand Down
Loading