1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\PhpDoc\Tag; |
4: | |
5: | use PHPStan\Type\Type; |
6: | |
7: | /** |
8: | * @api |
9: | * @final |
10: | */ |
11: | class PropertyTag |
12: | { |
13: | |
14: | public function __construct( |
15: | private Type $type, |
16: | private ?Type $readableType, |
17: | private ?Type $writableType, |
18: | ) |
19: | { |
20: | } |
21: | |
22: | /** |
23: | * @deprecated Use getReadableType() / getWritableType() |
24: | */ |
25: | public function getType(): Type |
26: | { |
27: | return $this->type; |
28: | } |
29: | |
30: | public function getReadableType(): ?Type |
31: | { |
32: | return $this->readableType; |
33: | } |
34: | |
35: | public function getWritableType(): ?Type |
36: | { |
37: | return $this->writableType; |
38: | } |
39: | |
40: | /** |
41: | * @phpstan-assert-if-true !null $this->getReadableType() |
42: | */ |
43: | public function isReadable(): bool |
44: | { |
45: | return $this->readableType !== null; |
46: | } |
47: | |
48: | /** |
49: | * @phpstan-assert-if-true !null $this->getWritableType() |
50: | */ |
51: | public function isWritable(): bool |
52: | { |
53: | return $this->writableType !== null; |
54: | } |
55: | |
56: | } |
57: |