-
Notifications
You must be signed in to change notification settings - Fork 659
/
TypeSource.php
44 lines (34 loc) · 1003 Bytes
/
TypeSource.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Psalm\Internal\Taint;
use Psalm\CodeLocation;
class TypeSource
{
/** @var string */
public $id;
/** @var ?CodeLocation */
public $code_location;
/** @var int */
public $taint;
public function __construct(string $id, ?CodeLocation $code_location, int $taint = 0)
{
$this->id = $id;
$this->code_location = $code_location;
$this->taint = $taint;
}
public static function getForMethodArgument(
string $method_id,
int $argument_offset,
?CodeLocation $code_location,
?CodeLocation $function_location = null
) : self {
$function_id = $method_id . '#' . ($argument_offset + 1);
if ($function_location) {
$function_id .= '-' . $function_location->file_name . ':' . $function_location->raw_file_start;
}
return new self(\strtolower($function_id), $code_location);
}
public function __toString()
{
return $this->id;
}
}