1 | <?php |
||
21 | class PharInvocationResolver implements Resolvable |
||
22 | { |
||
23 | const RESOLVE_REALPATH = 1; |
||
24 | const RESOLVE_ALIAS = 2; |
||
25 | const ASSERT_INTERNAL_INVOCATION = 32; |
||
26 | |||
27 | /** |
||
28 | * @var string[] |
||
29 | */ |
||
30 | private $invocationFunctionNames = [ |
||
31 | 'include', |
||
32 | 'include_once', |
||
33 | 'require', |
||
34 | 'require_once' |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Contains resolved base names in order to reduce file IO. |
||
39 | * |
||
40 | * @var string[] |
||
41 | */ |
||
42 | private $baseNames = []; |
||
43 | |||
44 | /** |
||
45 | * Resolves PharInvocation value object (baseName and optional alias). |
||
46 | * |
||
47 | * Phar aliases are intended to be used only inside Phar archives, however |
||
48 | * PharStreamWrapper needs this information exposed outside of Phar as well |
||
49 | * It is possible that same alias is used for different $baseName values. |
||
50 | * That's why PharInvocationCollection behaves like a stack when resolving |
||
51 | * base-name for a given alias. On the other hand it is not possible that |
||
52 | * one $baseName is referring to multiple aliases. |
||
53 | * @see https://secure.php.net/manual/en/phar.setalias.php |
||
54 | * @see https://secure.php.net/manual/en/phar.mapphar.php |
||
55 | * |
||
56 | * @param string $path |
||
57 | * @param int|null $flags |
||
58 | * @return null|PharInvocation |
||
59 | */ |
||
60 | public function resolve(string $path, int $flags = null) |
||
83 | |||
84 | /** |
||
85 | * Retrieves PharInvocation, either existing in collection or created on demand |
||
86 | * with resolving a potential alias name used in the according Phar archive. |
||
87 | * |
||
88 | * @param string $baseName |
||
89 | * @param int $flags |
||
90 | * @return PharInvocation |
||
91 | */ |
||
92 | private function retrieveInvocation(string $baseName, int $flags): PharInvocation |
||
109 | |||
110 | /** |
||
111 | * @param string $path |
||
112 | * @param int $flags |
||
113 | * @return null|string |
||
114 | */ |
||
115 | private function resolveBaseName(string $path, int $flags) |
||
164 | |||
165 | /** |
||
166 | * @param string $path |
||
167 | * @return null|string |
||
168 | */ |
||
169 | private function resolvePossibleAlias(string $path) |
||
174 | |||
175 | /** |
||
176 | * @param string $baseName |
||
177 | * @return null|PharInvocation |
||
178 | */ |
||
179 | private function findByBaseName(string $baseName) |
||
188 | |||
189 | /** |
||
190 | * @param string $path |
||
191 | * @return null|string |
||
192 | */ |
||
193 | private function findInBaseNames(string $path) |
||
212 | |||
213 | /** |
||
214 | * @param string $baseName |
||
215 | */ |
||
216 | private function addBaseName(string $baseName) |
||
225 | |||
226 | /** |
||
227 | * Finds confirmed(!) invocations by alias. |
||
228 | * |
||
229 | * @param string $path |
||
230 | * @return null|PharInvocation |
||
231 | * @see \TYPO3\PharStreamWrapper\PharStreamWrapper::collectInvocation() |
||
232 | */ |
||
233 | private function findByAlias(string $path) |
||
246 | } |
||
247 |