1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PHPSemVerChecker\Operation; |
4
|
|
|
|
5
|
|
|
use PhpParser\Node\Stmt; |
6
|
|
|
use PhpParser\Node\Stmt\Property; |
7
|
|
|
use PHPSemVerChecker\Node\Statement\Property as PProperty; |
8
|
|
|
|
9
|
|
|
class PropertyAdded extends PropertyOperation { |
10
|
|
|
/** |
11
|
|
|
* @var array |
12
|
|
|
*/ |
13
|
|
|
protected $code = [ |
14
|
|
|
'class' => ['V019', 'V020', 'V026'], |
15
|
|
|
'trait' => ['V049', 'V050', 'V055'], |
16
|
|
|
]; |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $reason = 'Property has been added.'; |
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $fileAfter; |
25
|
|
|
/** |
26
|
|
|
* @var \PhpParser\Node\Stmt |
27
|
|
|
*/ |
28
|
|
|
protected $contextAfter; |
29
|
|
|
/** |
30
|
|
|
* @var \PhpParser\Node\Stmt\Property |
31
|
|
|
*/ |
32
|
|
|
protected $propertyAfter; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $context |
36
|
|
|
* @param string $fileAfter |
37
|
|
|
* @param \PhpParser\Node\Stmt $contextAfter |
38
|
|
|
* @param \PhpParser\Node\Stmt\Property $propertyAfter |
39
|
|
|
*/ |
40
|
2 |
|
public function __construct($context, $fileAfter, Stmt $contextAfter, Property $propertyAfter) |
41
|
|
|
{ |
42
|
2 |
|
$this->context = $context; |
43
|
2 |
|
$this->visibility = $this->getVisibility($propertyAfter); |
44
|
2 |
|
$this->fileAfter = $fileAfter; |
45
|
2 |
|
$this->contextAfter = $contextAfter; |
46
|
2 |
|
$this->propertyAfter = $propertyAfter; |
47
|
2 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
public function getLocation() |
53
|
|
|
{ |
54
|
|
|
return $this->fileAfter; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return int |
59
|
|
|
*/ |
60
|
|
|
public function getLine() |
61
|
|
|
{ |
62
|
|
|
return $this->propertyAfter->getLine(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
2 |
|
public function getTarget() |
69
|
|
|
{ |
70
|
2 |
|
return PProperty::getFullyQualifiedName($this->contextAfter, $this->propertyAfter); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|