Fix phpstan/phpstan#8031: Union of constant string type lost when used with generics. #26547
Annotations
1 error and 3 warnings
|
|
|
src/Type/Generic/TemplateTypeHelper.php#L147
Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator":
@@ @@
$isArrayKey = $templateType->getBound()->describe(VerbosityLevel::precise()) === '(int|string)';
if ($type->isInteger()->yes() && $isArrayKey) {
$type = $type->generalize(GeneralizePrecision::templateArgument());
- } elseif ($type->isConstantValue()->yes() && !$templateType->getBound()->isScalar()->yes()) {
+ } elseif ($type->isConstantValue()->yes() && $templateType->getBound()->isScalar()->no()) {
$type = $type->generalize(GeneralizePrecision::templateArgument());
}
}
|
|
src/Type/Generic/TemplateTypeHelper.php#L147
Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator":
@@ @@
$isArrayKey = $templateType->getBound()->describe(VerbosityLevel::precise()) === '(int|string)';
if ($type->isInteger()->yes() && $isArrayKey) {
$type = $type->generalize(GeneralizePrecision::templateArgument());
- } elseif ($type->isConstantValue()->yes() && !$templateType->getBound()->isScalar()->yes()) {
+ } elseif (!$type->isConstantValue()->no() && !$templateType->getBound()->isScalar()->yes()) {
$type = $type->generalize(GeneralizePrecision::templateArgument());
}
}
|
|
src/Type/Generic/TemplateTypeHelper.php#L145
Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator":
@@ @@
{
if (!$templateType->getVariance()->covariant()) {
$isArrayKey = $templateType->getBound()->describe(VerbosityLevel::precise()) === '(int|string)';
- if ($type->isInteger()->yes() && $isArrayKey) {
+ if (!$type->isInteger()->no() && $isArrayKey) {
$type = $type->generalize(GeneralizePrecision::templateArgument());
} elseif ($type->isConstantValue()->yes() && !$templateType->getBound()->isScalar()->yes()) {
$type = $type->generalize(GeneralizePrecision::templateArgument());
|
The logs for this run have expired and are no longer available.
Loading