1 | <?php |
||
15 | class FileEditor |
||
16 | { |
||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private static $constants = []; |
||
21 | /** |
||
22 | * @var \Zend\Code\Generator\FileGenerator |
||
23 | */ |
||
24 | private $fileGenerator; |
||
25 | /** |
||
26 | * @var FunctionRepository |
||
27 | */ |
||
28 | private $functions; |
||
29 | /** |
||
30 | * @var Interfaces\FileSystem |
||
31 | */ |
||
32 | private $fileSystem; |
||
33 | |||
34 | /** |
||
35 | * FileEditor constructor. |
||
36 | * @param FileGenerator $fileGenerator |
||
37 | * @param FunctionRepository $functionRepository |
||
38 | * @param FileSystemInterface $fileSystem |
||
39 | */ |
||
40 | public function __construct( |
||
49 | |||
50 | /** |
||
51 | * @param $path |
||
52 | * @return void |
||
53 | */ |
||
54 | public function addBackslashes($path) |
||
85 | |||
86 | |||
87 | public function removeBackslashes($path) |
||
94 | |||
95 | /** |
||
96 | * If a method exists under a namespace and has been aliased, or has been imported, don't replace. |
||
97 | * |
||
98 | * @param FileGenerator $generator |
||
99 | * @param array $functions |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | private function removeUseFunctionsFromBackslashing(FileGenerator $generator, array $functions) |
||
120 | |||
121 | /** |
||
122 | * @return array |
||
123 | */ |
||
124 | private function getDefinedConstants() |
||
134 | |||
135 | /** |
||
136 | * @param $generator |
||
137 | * @return array |
||
138 | */ |
||
139 | protected function getReplaceableFunctions($generator) |
||
146 | |||
147 | /** |
||
148 | * @param string $source |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | private function applyFinalFixes($source) |
||
161 | |||
162 | /** |
||
163 | * @param $constants |
||
164 | * @param $token |
||
165 | * @param $previousToken |
||
166 | * |
||
167 | * @return bool |
||
168 | */ |
||
169 | private function isConstant(array &$constants, array &$token, array &$previousToken) |
||
173 | |||
174 | /** |
||
175 | * @param array $functions |
||
176 | * @param array $token |
||
177 | * @param array $previousToken |
||
178 | * |
||
179 | * @return bool |
||
180 | */ |
||
181 | private function isFunction(array &$functions, array &$token, array &$previousToken) |
||
187 | |||
188 | /** |
||
189 | * @param array $functions |
||
190 | * @param array $token |
||
191 | * @param array $previousToken |
||
192 | * @param array $constants |
||
193 | * |
||
194 | * @return bool |
||
195 | */ |
||
196 | private function isBackslashable(array &$functions, array &$token, array &$previousToken, array &$constants) |
||
201 | } |
||
202 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.