mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Add support for numeric types
This commit is contained in:
parent
d689996fde
commit
7d11b4b9b0
@ -603,17 +603,26 @@ abstract class FunctionLikeChecker implements StatementsSource
|
||||
$type_match_found = true;
|
||||
}
|
||||
|
||||
if ($param_type_part->isScalar() && $input_type_part->isScalarType()) {
|
||||
$type_match_found = true;
|
||||
}
|
||||
|
||||
if ($param_type_part->isCallable() && ($input_type_part->value === 'string' || $input_type_part->value === 'array')) {
|
||||
// @todo add value checks if possible here
|
||||
$type_match_found = true;
|
||||
}
|
||||
|
||||
if ($input_type_part->isNumeric()) {
|
||||
if ($param_type_part->isNumericType()) {
|
||||
$scalar_type_match_found = true;
|
||||
}
|
||||
}
|
||||
if ($input_type_part->isScalarType()) {
|
||||
if ($param_type_part->isScalarType()) {
|
||||
$scalar_type_match_found = true;
|
||||
}
|
||||
}
|
||||
else if ($param_type_part->isObject()) {
|
||||
else if ($param_type_part->isObject() && !$input_type_part->isArray() && !$input_type_part->isResource()) {
|
||||
$type_match_found = true;
|
||||
}
|
||||
|
||||
|
@ -387,6 +387,17 @@ abstract class Type
|
||||
}
|
||||
}
|
||||
|
||||
public function isScalar()
|
||||
{
|
||||
if ($this instanceof Atomic) {
|
||||
return $this->value === 'scalar';
|
||||
}
|
||||
|
||||
if ($this instanceof Union) {
|
||||
return isset($this->types['scalar']);
|
||||
}
|
||||
}
|
||||
|
||||
public function isCallable()
|
||||
{
|
||||
if ($this instanceof Atomic) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user