You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 53c0b95
Browse filesBrowse the repository at this point in the historyBrowse files
Resolve a template contravariant in the return type to its upper bound
A template inferred from both kinds of position, such as the T in
@PARAM T $value and @PARAM callable(T): void $handler, has a lower and an
upper bound, and the lower one always won. That is the most precise choice
when the return type uses T covariantly, but when it uses T only in
contravariant positions, as in @return callable(T): void, a larger T is
the more precise return type. handler(1, $intOrStringHandler) returned
callable(1): void, which a callable(int|string): void parameter rejected.
Such a template now resolves to its upper bound, the rule of Pierce and
Turner's local type inference. A template the return type uses
covariantly, in both kinds of position, or not at all keeps the lower
bound. TemplateTypeMap::getUpperBoundTypes() exposes the upper bounds.
Amp-Thread-ID: https://ampcode.com/threads/T-01a21c3c-cedc-7330-a083-cc986590888f
Copy file name to clipboardExpand all lines: turbo-ext/tests/smoke.php
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1712,6 +1712,8 @@ public function traverse(\PHPStan\Type\Type $type, callable $traverse): \PHPStan
1712
1712
check(($ttmPhp->unsetType($ttmName) === $ttmPhp) === ($ttmNative->unsetType($ttmName) === $ttmNative), "TemplateTypeMap $ttmLabel unsetType($ttmName) returns \$this on both sides or neither");
1713
1713
check(($ttmPhp->unsetType($ttmName) === \PHPStan\Type\Generic\TemplateTypeMap::createEmpty()) === ($ttmNative->unsetType($ttmName) === \PHPStanTurbo\TemplateTypeMap::createEmpty()), "TemplateTypeMap $ttmLabel unsetType($ttmName) returns the empty singleton on both sides or neither");
0 commit comments