We know that curl_init() (for example) returns resource|false:

But when we returns/throws from the code by conditions, that checks for some types in such type unions, we need to exclude these types in the code after the conditions:

On my screenshot above $ch will not be false or boolean after the condition - it will be only resource. Some instruments for static code analysis, like phpstan, see it too. It would be nice to have such analysis in intelephense.
Following works even now, so I guess false and throw need to be correctly recognized.
if(is_bool($ch)){
return;
}
$this->ch = $ch
Also extension is generalizing false keyword [:link:phpdoc] into bool, but true and false is correct type in phpdoc.
@KapitanOczywisty In my environment (VSC 1.38.1, Intelephense 1.2.3) it doesn't work even with is_bool() and return:

@yura3d same version:

@KapitanOczywisty Thanks for your reply, it prompted me to dive deeper in the problem. And right now I've found the reason that breaks this example in my code. It is a namespace. When it is declared for the file, the type of $ch is not recognized as expected after return:

It seems this is a bug.
Summarazing the discussion above, what was discovered and needs to be improved/fixed:
false and true types are subtypes of bool in PHPDoc and should not be generalized to it;return, but with other language constructions that interrupt code execution (throw, exit, die, ...); it would be nice that it will work even if throw (for example) occured in called external method.namespace declaration in file should not break type exclusion.Different behavior depending on condition form:

Thanks for the analysis @yura3d and @KapitanOczywisty . Fixed in 1.3.