mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Allow assertions on mixed vars
This commit is contained in:
parent
8e4f8fabe3
commit
8ababf1537
@ -28,15 +28,10 @@ class FunctionChecker extends FunctionLikeChecker
|
||||
public static $stubbed_functions = [];
|
||||
|
||||
/**
|
||||
* @param mixed $function
|
||||
* @param StatementsSource $source
|
||||
*/
|
||||
public function __construct($function, StatementsSource $source)
|
||||
public function __construct(PhpParser\Node\Stmt\Function_ $function, StatementsSource $source)
|
||||
{
|
||||
if (!$function instanceof PhpParser\Node\Stmt\Function_) {
|
||||
throw new \InvalidArgumentException('Bad');
|
||||
}
|
||||
|
||||
parent::__construct($function, $source);
|
||||
}
|
||||
|
||||
@ -370,7 +365,7 @@ class FunctionChecker extends FunctionLikeChecker
|
||||
return new Type\Union([new Type\Atomic\TString, new Type\Atomic\TFalse]);
|
||||
}
|
||||
|
||||
return new Type\Union([new Type\Atomic\TArray([new Type\Atomic\TMixed, new Type\Atomic\TString])]);
|
||||
return new Type\Union([new Type\Atomic\TArray([Type::getMixed(), Type::getString()])]);
|
||||
}
|
||||
|
||||
if ($call_args) {
|
||||
|
@ -162,7 +162,7 @@ class IfChecker
|
||||
|
||||
foreach ($keys as $key) {
|
||||
foreach ($mixed_var_ids as $mixed_var_id) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id) . '(\[|-|$)/', $key)) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id) . '(\[|-)/', $key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -702,7 +702,7 @@ class IfChecker
|
||||
|
||||
foreach ($keys as $key) {
|
||||
foreach ($mixed_var_ids as $mixed_var_id) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id) . '(\[|-|$)/', $key)) {
|
||||
if (preg_match('/^' . preg_quote($mixed_var_id) . '(\[|-)/', $key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user