mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix get type return types
This commit is contained in:
parent
5c39fb5ab1
commit
2c0dd36035
@ -566,6 +566,10 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
|
||||
$self_fq_class_name
|
||||
);
|
||||
|
||||
if (isset($stmt->inferredType)) {
|
||||
$return_type_candidate = $stmt->inferredType;
|
||||
}
|
||||
|
||||
if ($return_type_candidate) {
|
||||
$return_type_candidate = clone $return_type_candidate;
|
||||
|
||||
@ -936,6 +940,11 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($class_storage->pseudo_property_get_types['$' . $prop_name])) {
|
||||
$stmt->inferredType = clone $class_storage->pseudo_property_get_types['$' . $prop_name];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -203,6 +203,26 @@ class MagicPropertyTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'getPropertyExplicitCall' => [
|
||||
'<?php
|
||||
class A {
|
||||
public function __get(string $name) {}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set(string $name, $value) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @property string $test
|
||||
*/
|
||||
class B extends A {
|
||||
public function test(): string {
|
||||
return $this->__get("test");
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user