|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of PHP Mess Detector. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) Manuel Pichler <[email protected]>. |
|
6
|
|
|
* All rights reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* Licensed under BSD License |
|
9
|
|
|
* For full copyright and license information, please see the LICENSE file. |
|
10
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
11
|
|
|
* |
|
12
|
|
|
* @author Manuel Pichler <[email protected]> |
|
13
|
|
|
* @copyright Manuel Pichler. All rights reserved. |
|
14
|
|
|
* @license https://opensource.org/licenses/bsd-license.php BSD License |
|
15
|
|
|
* @link http://phpmd.org/ |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace PHPMD\Node; |
|
19
|
|
|
|
|
20
|
|
|
use PHPMD\Rule; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Wrapper around a PHP_Depend ast node. |
|
24
|
|
|
*/ |
|
25
|
|
|
class ASTNode extends \PHPMD\AbstractNode |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* The source file of this node. |
|
29
|
|
|
* |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $fileName = null; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Constructs a new ast node instance. |
|
36
|
|
|
* |
|
37
|
|
|
* @param \PDepend\Source\AST\ASTNode $node |
|
38
|
|
|
* @param string $fileName |
|
39
|
|
|
*/ |
|
40
|
50 |
|
public function __construct(\PDepend\Source\AST\ASTNode $node, $fileName) |
|
41
|
|
|
{ |
|
42
|
50 |
|
parent::__construct($node); |
|
43
|
|
|
|
|
44
|
50 |
|
$this->fileName = $fileName; |
|
45
|
50 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Checks if this node has a suppressed annotation for the given rule |
|
49
|
|
|
* instance. |
|
50
|
|
|
* |
|
51
|
|
|
* @param \PHPMD\Rule $rule |
|
52
|
|
|
* @return boolean |
|
53
|
|
|
* @SuppressWarnings("PMD.UnusedFormalParameter") |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function hasSuppressWarningsAnnotationFor(Rule $rule) |
|
56
|
|
|
{ |
|
57
|
1 |
|
return false; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Returns the source name for this node, maybe a class or interface name, |
|
62
|
|
|
* or a package, method, function name. |
|
63
|
|
|
* |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
5 |
|
public function getName() |
|
67
|
|
|
{ |
|
68
|
5 |
|
return $this->getImage(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Returns the image of the underlying node. |
|
73
|
|
|
* |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
16 |
|
public function getImage() |
|
77
|
|
|
{ |
|
78
|
16 |
|
return $this->getNode()->getImage(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Returns the name of the declaring source file. |
|
83
|
|
|
* |
|
84
|
|
|
* @return string |
|
85
|
|
|
*/ |
|
86
|
29 |
|
public function getFileName() |
|
87
|
|
|
{ |
|
88
|
29 |
|
return $this->fileName; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Returns the name of the parent type or <b>null</b> when this node has no |
|
93
|
|
|
* parent type. |
|
94
|
|
|
* |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
1 |
|
public function getParentName() |
|
98
|
|
|
{ |
|
99
|
1 |
|
return null; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Returns the name of the parent namespace. |
|
104
|
|
|
* |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
1 |
|
public function getNamespaceName() |
|
108
|
|
|
{ |
|
109
|
1 |
|
return null; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Returns the full qualified name of a class, an interface, a method or |
|
114
|
|
|
* a function. |
|
115
|
|
|
* |
|
116
|
|
|
* @return string |
|
117
|
|
|
*/ |
|
118
|
1 |
|
public function getFullQualifiedName() |
|
119
|
|
|
{ |
|
120
|
1 |
|
return null; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|