mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Be better about inherited core method arg types
This commit is contained in:
parent
db7abc2b90
commit
6e7bab58c4
@ -7637,7 +7637,7 @@ return [
|
||||
'ReflectionClass::newInstanceArgs' => ['object', 'args='=>'array'],
|
||||
'ReflectionClass::newInstance' => ['object', 'args='=>'', '...='=>''],
|
||||
'ReflectionClass::newInstanceWithoutConstructor' => ['object'],
|
||||
'ReflectionClass::setStaticPropertyValue' => ['', 'name'=>'string', 'value'=>''],
|
||||
'ReflectionClass::setStaticPropertyValue' => ['void', 'name'=>'string', 'value'=>''],
|
||||
'ReflectionClass::__toString' => ['string'],
|
||||
'Reflection::export' => ['string', 'r'=>'reflector', 'return='=>'bool'],
|
||||
'ReflectionExtension::__clone' => ['ReflectionExtension'],
|
||||
|
@ -298,7 +298,7 @@ class FunctionChecker extends FunctionLikeChecker
|
||||
? Type::parseString($arg_type)
|
||||
: Type::getMixed();
|
||||
|
||||
if ($param_type->hasScalarType()) {
|
||||
if ($param_type->hasScalarType() || $param_type->hasObject()) {
|
||||
$param_type->from_docblock = true;
|
||||
}
|
||||
|
||||
|
@ -787,10 +787,15 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
|
||||
|
||||
$implemeneter_param_type = $implementer_method_storage->params[$i]->type;
|
||||
|
||||
if (!$guide_classlike_storage->user_defined &&
|
||||
$guide_param->type &&
|
||||
!$guide_param->type->isMixed() &&
|
||||
(!$implemeneter_param_type || $implemeneter_param_type->getId() !== $guide_param->type->getId())
|
||||
if (!$guide_classlike_storage->user_defined
|
||||
&& $guide_param->type
|
||||
&& !$guide_param->type->isMixed()
|
||||
&& !$guide_param->type->from_docblock
|
||||
&& (!$implemeneter_param_type
|
||||
|| ($implemeneter_param_type->getId() !== $guide_param->type->getId()
|
||||
&& $implemeneter_param_type->getId() !== $or_null_guide_type->getId()
|
||||
)
|
||||
)
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
new MethodSignatureMismatch(
|
||||
@ -809,8 +814,9 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
|
||||
}
|
||||
}
|
||||
|
||||
if ($implementer_method_storage->cased_name !== '__construct' &&
|
||||
$implementer_method_storage->required_param_count > $guide_method_storage->required_param_count
|
||||
if ($guide_classlike_storage->user_defined
|
||||
&& $implementer_method_storage->cased_name !== '__construct'
|
||||
&& $implementer_method_storage->required_param_count > $guide_method_storage->required_param_count
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
new MethodSignatureMismatch(
|
||||
@ -1061,7 +1067,8 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidReturnType(
|
||||
'Not all code paths of ' . $cased_method_id . ' end in a return statement',
|
||||
'Not all code paths of ' . $cased_method_id . ' end in a return statement, return type '
|
||||
. $return_type . ' expected',
|
||||
$return_type_location
|
||||
)
|
||||
)) {
|
||||
|
@ -179,6 +179,20 @@ class Union
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasObject()
|
||||
{
|
||||
foreach ($this->types as $type) {
|
||||
if ($type instanceof Type\Atomic\TObject) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user