1 | <?php |
||
15 | class Context |
||
16 | { |
||
17 | /** |
||
18 | * For FunctionDefinition it's null, use scopePointer |
||
19 | * |
||
20 | * @var ParentDefinition|null |
||
21 | */ |
||
22 | public $scope; |
||
23 | |||
24 | /** |
||
25 | * @var AliasManager |
||
26 | */ |
||
27 | public $aliasManager; |
||
28 | |||
29 | /** |
||
30 | * @var Application |
||
31 | */ |
||
32 | public $application; |
||
33 | |||
34 | /** |
||
35 | * @var string|integer |
||
36 | */ |
||
37 | public $currentBranch; |
||
38 | |||
39 | /** |
||
40 | * @var OutputInterface |
||
41 | */ |
||
42 | public $output; |
||
43 | |||
44 | /** |
||
45 | * @var Variable[] |
||
46 | */ |
||
47 | protected $symbols = array(); |
||
48 | |||
49 | /** |
||
50 | * @var ScopePointer|null |
||
51 | */ |
||
52 | public $scopePointer; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $filepath; |
||
58 | |||
59 | /** |
||
60 | * @var EventManager |
||
61 | */ |
||
62 | protected $eventManager; |
||
63 | |||
64 | /** |
||
65 | * Construct our Context with all needed information |
||
66 | * |
||
67 | * @param OutputInterface $output |
||
68 | * @param Application $application |
||
69 | * @param EventManager $eventManager |
||
70 | */ |
||
71 | 381 | public function __construct(OutputInterface $output, Application $application, EventManager $eventManager) |
|
79 | |||
80 | /** |
||
81 | * @return Expression |
||
82 | */ |
||
83 | 375 | public function getExpressionCompiler() |
|
87 | |||
88 | 381 | public function initGlobals() |
|
89 | { |
||
90 | /** |
||
91 | * http://php.net/manual/language.variables.superglobals.php |
||
92 | */ |
||
93 | 381 | $this->addVariable(new GlobalVariable('GLOBALS', array(), CompiledExpression::ARR)); |
|
94 | 381 | $this->addVariable(new GlobalVariable('_SERVER', array(), CompiledExpression::ARR)); |
|
95 | 381 | $this->addVariable(new GlobalVariable('_GET', array(), CompiledExpression::ARR)); |
|
96 | 381 | $this->addVariable(new GlobalVariable('_POST', array(), CompiledExpression::ARR)); |
|
97 | 381 | $this->addVariable(new GlobalVariable('_FILES', array(), CompiledExpression::ARR)); |
|
98 | 381 | $this->addVariable(new GlobalVariable('_COOKIE', array(), CompiledExpression::ARR)); |
|
99 | 381 | $this->addVariable(new GlobalVariable('_SESSION', array(), CompiledExpression::ARR)); |
|
100 | 381 | $this->addVariable(new GlobalVariable('_REQUEST', array(), CompiledExpression::ARR)); |
|
101 | 381 | $this->addVariable(new GlobalVariable('_ENV', array(), CompiledExpression::ARR)); |
|
102 | 381 | } |
|
103 | |||
104 | /** |
||
105 | * @param string $name |
||
106 | * @return Variable |
||
107 | */ |
||
108 | public function addSymbol($name) |
||
109 | { |
||
110 | $variable = new Variable($name); |
||
111 | $this->symbols[$name] = $variable; |
||
112 | |||
113 | return $variable; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param Variable $variable |
||
118 | * @return bool |
||
119 | */ |
||
120 | 381 | public function addVariable(Variable $variable) |
|
121 | { |
||
122 | 381 | $this->symbols[$variable->getName()] = $variable; |
|
123 | |||
124 | 381 | return true; |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * Clear prevent context |
||
129 | */ |
||
130 | 8 | public function clear() |
|
140 | |||
141 | 8 | public function clearSymbols() |
|
142 | { |
||
143 | 8 | unset($this->symbols); |
|
146 | |||
147 | /** |
||
148 | * @param $name |
||
149 | * @return Variable|null |
||
150 | */ |
||
151 | 13 | public function getSymbol($name) |
|
155 | |||
156 | /** |
||
157 | * @param string $type |
||
158 | * @param string $message |
||
159 | * @return bool |
||
160 | */ |
||
161 | public function warning($type, $message) |
||
170 | |||
171 | /** |
||
172 | * @param string $type |
||
173 | * @param string $message |
||
174 | * @param \PhpParser\NodeAbstract $expr |
||
175 | * @param int $status |
||
176 | * @return bool |
||
177 | */ |
||
178 | 8 | public function notice($type, $message, \PhpParser\NodeAbstract $expr, $status = Check::CHECK_SAFE) |
|
205 | |||
206 | /** |
||
207 | * @param \PhpParser\Error $exception |
||
208 | * @param string $filepath |
||
209 | * @return bool |
||
210 | */ |
||
211 | public function sytaxError(\PhpParser\Error $exception, $filepath) |
||
226 | |||
227 | /** |
||
228 | * @return Variable[] |
||
229 | */ |
||
230 | 8 | public function getSymbols() |
|
234 | |||
235 | /** |
||
236 | * @param AbstractDefinition $scope |
||
237 | */ |
||
238 | 381 | public function setScope(AbstractDefinition $scope = null) |
|
242 | |||
243 | 8 | public function debug($message, \PhpParser\Node $expr = null) |
|
256 | |||
257 | /** |
||
258 | * @return string |
||
259 | */ |
||
260 | public function getFilepath() |
||
264 | |||
265 | /** |
||
266 | * @param string $filepath |
||
267 | */ |
||
268 | 8 | public function setFilepath($filepath) |
|
272 | |||
273 | /** |
||
274 | * @return integer |
||
275 | */ |
||
276 | 5 | public function getCurrentBranch() |
|
280 | |||
281 | /** |
||
282 | * @param int|string $currentBranch |
||
283 | */ |
||
284 | public function setCurrentBranch($currentBranch) |
||
288 | |||
289 | /** |
||
290 | * @param Variable $variable |
||
291 | * @param $type |
||
292 | * @param $value |
||
293 | */ |
||
294 | 2 | public function modifyReferencedVariables(Variable $variable, $type, $value) |
|
305 | |||
306 | /** |
||
307 | * @return EventManager |
||
308 | */ |
||
309 | 8 | public function getEventManager() |
|
313 | } |
||
314 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.