1 | <?php |
||
30 | abstract class LanguageFeatureAnalyser extends NodeVisitorAbstract implements AnalyserAwareInterface |
||
31 | { |
||
32 | const MODE_ADDITION = 0b0001, |
||
33 | MODE_DEPRECATION = 0b0010, |
||
34 | MODE_REMOVAL = 0b0100, |
||
35 | MODE_ALL = 0b0111; |
||
36 | |||
37 | /** |
||
38 | * Bitmap of operations to run. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $mode; |
||
43 | |||
44 | /** |
||
45 | * The `Analyser` representing the currently running operation. |
||
46 | * |
||
47 | * @var Analyser |
||
48 | */ |
||
49 | private $requirementAnalyser; |
||
50 | |||
51 | /** |
||
52 | * @var array |
||
53 | */ |
||
54 | private $options; |
||
55 | |||
56 | /** |
||
57 | * Create an instance of the child Analyser |
||
58 | * |
||
59 | * It is optional to set the related analyser during instance creation. |
||
60 | * When using this class in the context of an `Analyser` it will always be ensured |
||
61 | * that this `Analyser` will be known to the instance before any node is traversed. |
||
62 | * |
||
63 | * @param array $options |
||
64 | * @param \Pvra\Analyser $analyser |
||
65 | * @see setOwningAnalyser() Set the owning analyser |
||
66 | */ |
||
67 | 168 | public function __construct(array $options = [], Analyser $analyser = null) |
|
75 | |||
76 | /** |
||
77 | * @inheritdoc |
||
78 | */ |
||
79 | 160 | public function setOwningAnalyser(Analyser $requirementAnalyser) |
|
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | */ |
||
89 | 120 | public function getOwningAnalyser() |
|
93 | |||
94 | /** |
||
95 | * Get the instance of the currently used `Pvra\AnalysisResult`. |
||
96 | * |
||
97 | * @return \Pvra\AnalysisResult |
||
98 | * @see Analyser::getResult() Method used to retrieve the result |
||
99 | */ |
||
100 | 118 | protected function getResult() |
|
104 | |||
105 | /** |
||
106 | * @param string|int $name |
||
107 | * @param mixed $default |
||
108 | * @return mixed |
||
109 | */ |
||
110 | 168 | protected function getOption($name, $default = null) |
|
114 | |||
115 | /** |
||
116 | * Called when entering a source node |
||
117 | * |
||
118 | * This method is called when a source node is entered. Contained logic determines the presence of |
||
119 | * specific syntactical features. |
||
120 | * |
||
121 | * @param \PhpParser\Node $node The node to parse. |
||
122 | * @return null|Node The nodes should not be modified as other walkers might depend on it. |
||
123 | * @see getResult() ResultInstance |
||
124 | * @see AnalysisResult::addRequirement() Add new requirement |
||
125 | * @see AnalysisResult::addArbitraryRequirement() Add new arbitrary requirement |
||
126 | * @codeCoverageIgnore |
||
127 | */ |
||
128 | public function enterNode(Node $node) |
||
131 | } |
||
132 |