1 | <?php |
||
12 | class MinifyVars extends AbstractPass |
||
13 | { |
||
14 | /** |
||
15 | * @var integer Number of variables processed in current function block |
||
16 | */ |
||
17 | protected $cnt; |
||
18 | |||
19 | /** |
||
20 | * @var string Regexp that matches variable names that need to be preserved |
||
21 | */ |
||
22 | public $preserveRegexp = '(^\\$(?:\\$|__|(?:this|GLOBALS|_[A-Z]+|php_errormsg|HTTP_RAW_POST_DATA|http_response_header|arg[cv]))$)S'; |
||
23 | |||
24 | /** |
||
25 | * @var array Map of [original name => minified name] |
||
26 | */ |
||
27 | protected $varNames; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 8 | protected function optimizeStream() |
|
42 | |||
43 | /** |
||
44 | * Test whether current token is a variable that can be minified |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | 8 | protected function canBeMinified() |
|
57 | |||
58 | /** |
||
59 | * Generate a minified name for given variable |
||
60 | * |
||
61 | * @param string $varName Original variable |
||
62 | * @return string Minified variable |
||
63 | */ |
||
64 | 6 | protected function getName($varName) |
|
73 | |||
74 | /** |
||
75 | * Generate a minified variable name |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 6 | protected function generateName() |
|
97 | |||
98 | /** |
||
99 | * Handle the current double colon token |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | 2 | protected function handleDoubleColon() |
|
124 | |||
125 | /** |
||
126 | * Minify variables in given function block |
||
127 | * |
||
128 | * @param integer $startOffset |
||
129 | * @param integer $endOffset |
||
130 | * @return void |
||
131 | */ |
||
132 | 8 | protected function optimizeBlock($startOffset, $endOffset) |
|
150 | |||
151 | /** |
||
152 | * Reset the map of variable names |
||
153 | * |
||
154 | * @return void |
||
155 | */ |
||
156 | 8 | protected function resetNames() |
|
161 | } |