Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9aee02f

Browse files
Don't generalize template types
1 parent f06a53c commit 9aee02f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+226
-168
lines changed

‎src/Type/Generic/TemplateArrayType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateBooleanType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateConstantArrayType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateConstantIntegerType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateConstantStringType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateFloatType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateIntegerType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateKeyOfType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,4 @@ protected function getResult(): Type
4343
);
4444
}
4545

46-
protected function shouldGeneralizeInferredType(): bool
47-
{
48-
return false;
49-
}
50-
5146
}

‎src/Type/Generic/TemplateStringType.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public function __construct(
2929
$this->bound = $bound;
3030
}
3131

32-
protected function shouldGeneralizeInferredType(): bool
33-
{
34-
return false;
35-
}
36-
3732
}

‎src/Type/Generic/TemplateTypeTrait.php‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PHPStan\Type\Generic;
44

55
use PHPStan\TrinaryLogic;
6-
use PHPStan\Type\GeneralizePrecision;
76
use PHPStan\Type\IntersectionType;
87
use PHPStan\Type\MixedType;
98
use PHPStan\Type\NeverType;
@@ -242,12 +241,6 @@ public function inferTemplateTypes(Type $receivedType): TemplateTypeMap
242241
$map = $this->getBound()->inferTemplateTypes($receivedType);
243242
$resolvedBound = TypeUtils::resolveLateResolvableTypes(TemplateTypeHelper::resolveTemplateTypes($this->getBound(), $map));
244243
if ($resolvedBound->isSuperTypeOf($receivedType)->yes()) {
245-
if ($this->shouldGeneralizeInferredType()) {
246-
$generalizedType = $receivedType->generalize(GeneralizePrecision::templateArgument());
247-
if ($resolvedBound->isSuperTypeOf($generalizedType)->yes()) {
248-
$receivedType = $generalizedType;
249-
}
250-
}
251244
return (new TemplateTypeMap([
252245
$this->name => $receivedType,
253246
]))->union($map);
@@ -271,11 +264,6 @@ public function getStrategy(): TemplateTypeStrategy
271264
return $this->strategy;
272265
}
273266

274-
protected function shouldGeneralizeInferredType(): bool
275-
{
276-
return true;
277-
}
278-
279267
public function traverse(callable $cb): Type
280268
{
281269
$bound = $cb($this->getBound());

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /