Repository navigation
Expand file tree
/
Copy pathVariableWrite.php
More file actions
97 lines (83 loc) · 1.84 KB
/
Copy pathVariableWrite.php
File metadata and controls
97 lines (83 loc) · 1.84 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php declare(strict_types = 1);
namespace PHPStan\Node\Variable;
use PhpParser\Node;
/**
* A write site of a local variable inside a function-like body.
*
* Immutable. Whether the written value was read afterwards is not a property
* of the write - it is answered by VariableWritesNode::isRead().
*
* @api
*/
final class VariableWrite
{
public const KIND_ASSIGN = 1;
public const KIND_READ_MODIFY_WRITE = 2;
public const KIND_PRE_INC = 3;
public const KIND_POST_INC = 4;
public const KIND_PRE_DEC = 5;
public const KIND_POST_DEC = 6;
public const KIND_ARRAY_DIM_WRITE = 7;
public const KIND_LIST_ITEM = 8;
public const KIND_FOREACH_VALUE = 9;
public const KIND_FOREACH_KEY = 10;
public const KIND_CATCH = 11;
public const KIND_PARAMETER = 12;
public const KIND_CLOSURE_USE = 13;
public const KIND_ARRAY_LITERAL_ITEM = 14;
/**
* @param self::KIND_* $kind
* @param int|string|null $offset
*/
public function __construct(
private string $variableName,
private Node $node,
private int $id,
private int $kind,
private bool $offsetWrite = false,
private $offset = null,
private ?int $parentId = null,
private bool $replacesOffset = true,
)
{
}
public function getVariableName(): string
{
return $this->variableName;
}
/**
* The target node of the write - the source of the reported line.
*/
public function getNode(): Node
{
return $this->node;
}
public function getId(): int
{
return $this->id;
}
/**
* @return self::KIND_*
*/
public function getKind(): int
{
return $this->kind;
}
public function isOffsetWrite(): bool
{
return $this->offsetWrite;
}
/** @return int|string|null */
public function getOffset()
{
return $this->offset;
}
public function getParentId(): ?int
{
return $this->parentId;
}
public function replacesOffset(): bool
{
return $this->replacesOffset;
}
}