mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix bugs in refactor
This commit is contained in:
parent
f68280488c
commit
a30c82e5d7
@ -8,6 +8,11 @@ use Psalm\Context;
|
||||
|
||||
class ClassChecker extends ClassLikeChecker
|
||||
{
|
||||
/**
|
||||
* @var PhpParser\Node\Stmt\Class_
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* A lookup table of existing classes
|
||||
* @var array
|
||||
|
@ -325,7 +325,7 @@ class FunctionChecker extends FunctionLikeChecker
|
||||
new Type\Generic('array',
|
||||
[
|
||||
Type::getInt(),
|
||||
clone $call_args[0]->value->inferredType->type_paams[1]
|
||||
clone $call_args[0]->value->inferredType->types['array']->type_params[1]
|
||||
]
|
||||
)
|
||||
]);
|
||||
|
@ -535,8 +535,8 @@ abstract class FunctionLikeChecker implements StatementsSource
|
||||
$param_name,
|
||||
$param->isPassedByReference(),
|
||||
$param_type,
|
||||
$is_nullable,
|
||||
$is_optional
|
||||
$is_optional,
|
||||
$is_nullable
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1546,7 @@ class StatementsChecker
|
||||
}
|
||||
|
||||
if ($var_id) {
|
||||
$context->vars_in_scope[$var_id] = $stmt->inferredType;
|
||||
$context->vars_in_scope[$var_id] = isset($stmt->inferredType) ? $stmt->inferredType : Type::getMixed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1722,6 +1722,19 @@ class StatementsChecker
|
||||
);
|
||||
|
||||
if (!isset($class_properties[$prop_name])) {
|
||||
if ($stmt->var->name === 'this') {
|
||||
if (IssueBuffer::accepts(
|
||||
new UndefinedThisProperty(
|
||||
'Instance property ' . $lhs_type_part->value . '::' . $prop_name . ' is not defined',
|
||||
$this->checked_file_name,
|
||||
$stmt->getLine()
|
||||
),
|
||||
$this->suppressed_issues
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (IssueBuffer::accepts(
|
||||
new UndefinedProperty(
|
||||
'Instance property ' . $lhs_type_part->value . '::' . $prop_name . ' is not defined',
|
||||
@ -1732,6 +1745,7 @@ class StatementsChecker
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -3204,7 +3218,7 @@ class StatementsChecker
|
||||
foreach ($args as $i => $arg) {
|
||||
$method_param = $method_params[$i];
|
||||
|
||||
if ($return_type->value === '$' . $method_param['name']) {
|
||||
if ($return_type->value === '$' . $method_param->name) {
|
||||
$arg_value = $arg->value;
|
||||
if ($arg_value instanceof PhpParser\Node\Scalar\String_) {
|
||||
$return_type->value = preg_replace('/^\\\/', '', $arg_value->value);
|
||||
|
@ -19,7 +19,7 @@ class FunctionLikeParameter
|
||||
/** @var bool */
|
||||
public $is_nullable;
|
||||
|
||||
public function __construct($name, $by_ref, $type, $is_optional = false, $is_nullable = false)
|
||||
public function __construct($name, $by_ref, $type, $is_optional = true, $is_nullable = false)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->by_ref = $by_ref;
|
||||
|
Loading…
x
Reference in New Issue
Block a user