Skip to content

Commit 9db564b

Browse files
committed
[BE] Fix invariance composition
1 parent 5834cf5 commit 9db564b

File tree

7 files changed

+20
-315
lines changed

7 files changed

+20
-315
lines changed

changelog-2.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Bleeding edge (TODO move to other sections)
3737
* Stub files validation - detect duplicate classes and functions (https://github.com/phpstan/phpstan-src/commit/ddf8d5c3859c2c75c20f525a0e2ca8b99032373a, https://github.com/phpstan/phpstan-src/commit/17e4b74335e5235d7cd6708eb687a774a0eeead4)
3838
* Change `curl_setopt` function signature based on 2nd arg ([#1719](https://github.com/phpstan/phpstan-src/pull/1719)), thanks @staabm!
3939
* Empty `skipCheckGenericClasses` (https://github.com/phpstan/phpstan-src/commit/28c2c79b16cac6ba6b01f1b4d211541dd49d8a77)
40-
* Fix invariance composition ([#2054](https://github.com/phpstan/phpstan-src/pull/2054)), thanks @jiripudil!
4140
* Validate inline PHPDoc `@var` tag type against native type (https://github.com/phpstan/phpstan-src/commit/a69e3bc2f1e87f6da1e65d7935f1cc36bd5c42fe)
4241
* Set [`reportWrongPhpDocTypeInVarTag`](https://phpstan.org/config-reference#reportwrongphpdoctypeinvartag) to `true` to have all types validated, not just native ones
4342
* Always report always true conditions, except for last elseif and match arm ([#2105](https://github.com/phpstan/phpstan-src/pull/2105)), thanks @staabm!
@@ -144,6 +143,8 @@ Improvements 🔧
144143
Bugfixes 🐛
145144
=====================
146145

146+
* Fix invariance composition ([#2054](https://github.com/phpstan/phpstan-src/pull/2054)), thanks @jiripudil!
147+
147148
Function signature fixes 🤖
148149
=======================
149150

conf/bleedingEdge.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ parameters:
2626
duplicateStubs: true
2727
logicalXor: true
2828
betterNoop: true
29-
invarianceComposition: true
3029
alwaysTrueAlwaysReported: true
3130
disableUnreachableBranchesRules: true
3231
varTagType: true

conf/config.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ parameters:
6161
duplicateStubs: false
6262
logicalXor: false
6363
betterNoop: false
64-
invarianceComposition: false
6564
alwaysTrueAlwaysReported: false
6665
disableUnreachableBranchesRules: false
6766
varTagType: false

conf/parametersSchema.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ parametersSchema:
5656
duplicateStubs: bool()
5757
logicalXor: bool()
5858
betterNoop: bool()
59-
invarianceComposition: bool()
6059
alwaysTrueAlwaysReported: bool()
6160
disableUnreachableBranchesRules: bool()
6261
varTagType: bool()

src/DependencyInjection/ContainerFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use PHPStan\Reflection\ReflectionProvider;
3232
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
3333
use PHPStan\ShouldNotHappenException;
34-
use PHPStan\Type\Generic\TemplateTypeVariance;
3534
use PHPStan\Type\ObjectType;
3635
use Symfony\Component\Finder\Finder;
3736
use function array_diff_key;
@@ -191,7 +190,6 @@ public static function postInitializeContainer(Container $container): void
191190
$container->getService('typeSpecifier');
192191

193192
BleedingEdgeToggle::setBleedingEdge($container->getParameter('featureToggles')['bleedingEdge']);
194-
TemplateTypeVariance::setInvarianceCompositionEnabled($container->getParameter('featureToggles')['invarianceComposition']);
195193
}
196194

197195
public function clearOldContainers(string $tempDirectory): void

src/Type/Generic/TemplateTypeVariance.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class TemplateTypeVariance
2828
/** @var self[] */
2929
private static array $registry;
3030

31-
private static bool $invarianceCompositionEnabled = false;
32-
3331
private function __construct(private int $value)
3432
{
3533
}
@@ -118,7 +116,7 @@ public function compose(self $other): self
118116
return self::createInvariant();
119117
}
120118

121-
if (self::$invarianceCompositionEnabled && $this->invariant()) {
119+
if ($this->invariant()) {
122120
return self::createInvariant();
123121
}
124122

@@ -253,9 +251,4 @@ public static function __set_state(array $properties): self
253251
return new self($properties['value']);
254252
}
255253

256-
public static function setInvarianceCompositionEnabled(bool $enabled): void
257-
{
258-
self::$invarianceCompositionEnabled = $enabled;
259-
}
260-
261254
}

0 commit comments

Comments
 (0)