1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add preliminary call map

This commit is contained in:
Matthew Brown 2016-08-10 19:37:40 -04:00
parent 53b94f339e
commit 300375c4bd
2 changed files with 10564 additions and 1 deletions

10530
src/Psalm/CallMap.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -73,6 +73,8 @@ class StatementsChecker
protected static $mock_interfaces = [];
protected static $class_consts = [];
protected static $call_map = null;
public function __construct(StatementsSource $source, $enforce_variable_checks = false, $check_methods = true)
{
$this->source = $source;
@ -3206,7 +3208,16 @@ class StatementsChecker
return false;
}
$stmt->inferredType = Type::getMixed();
$call_map = self::getCallMap();
$call_map_key = strtolower($method_id);
if (isset($call_map[$call_map_key]) && $call_map[$call_map_key][0]) {
$stmt->inferredType = Type::parseString($call_map[$call_map_key][0]);
}
else {
$stmt->inferredType = Type::getMixed();
}
}
foreach ($stmt->args as $i => $arg) {
@ -3732,4 +3743,26 @@ class StatementsChecker
return $this_assignments;
}
/**
* Gets the method/function call map
*
* @return array<array<string>>
*/
protected static function getCallMap()
{
if (self::$call_map !== null) {
return self::$call_map;
}
$call_map = require_once(__DIR__.'/CallMap.php');
self::$call_map = [];
foreach ($call_map as $key => $value) {
self::$call_map[strtolower($key)] = $value;
}
return self::$call_map;
}
}