mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Make sure we’re not flipping the wrong constraint
This commit is contained in:
parent
ee004a91ac
commit
496bd97714
@ -520,7 +520,8 @@ abstract class Atomic
|
||||
array &$template_types,
|
||||
array &$generic_params,
|
||||
Codebase $codebase = null,
|
||||
Type\Atomic $input_type = null
|
||||
Type\Atomic $input_type = null,
|
||||
bool $add_upper_bound = false
|
||||
) {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -169,7 +169,8 @@ trait CallableTrait
|
||||
array &$template_types,
|
||||
array &$generic_params,
|
||||
Codebase $codebase = null,
|
||||
Atomic $input_type = null
|
||||
Atomic $input_type = null,
|
||||
bool $add_upper_bound = false
|
||||
) {
|
||||
if ($this->params) {
|
||||
foreach ($this->params as $offset => $param) {
|
||||
@ -190,7 +191,7 @@ trait CallableTrait
|
||||
$generic_params,
|
||||
$codebase,
|
||||
$input_param_type,
|
||||
true
|
||||
!$add_upper_bound
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -204,7 +205,7 @@ trait CallableTrait
|
||||
$generic_params,
|
||||
$codebase,
|
||||
$input_type->return_type,
|
||||
true
|
||||
$add_upper_bound
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -149,7 +149,8 @@ trait GenericTrait
|
||||
array &$template_types,
|
||||
array &$generic_params,
|
||||
Codebase $codebase = null,
|
||||
Atomic $input_type = null
|
||||
Atomic $input_type = null,
|
||||
bool $add_upper_bound = false
|
||||
) {
|
||||
foreach ($this->type_params as $offset => $type_param) {
|
||||
$input_type_param = null;
|
||||
@ -175,7 +176,8 @@ trait GenericTrait
|
||||
$template_types,
|
||||
$generic_params,
|
||||
$codebase,
|
||||
$input_type_param
|
||||
$input_type_param,
|
||||
$add_upper_bound
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -912,7 +912,8 @@ class Union
|
||||
$template_types,
|
||||
$generic_params,
|
||||
$codebase,
|
||||
$matching_atomic_type
|
||||
$matching_atomic_type,
|
||||
$add_upper_bound
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1817,6 +1817,22 @@ class TemplateTest extends TestCase
|
||||
|
||||
takesReturnTCallable($a);'
|
||||
],
|
||||
'nonBindingParamReturn' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param Closure():T $t1
|
||||
* @param T $t2
|
||||
*/
|
||||
function foo(Closure $t1, $t2) : void {}
|
||||
foo(
|
||||
function () : int {
|
||||
return 5;
|
||||
},
|
||||
"hello"
|
||||
);'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user