1 | <?php |
||
22 | class Helper |
||
23 | { |
||
24 | /* |
||
25 | * Resets PHP's OPcache if enabled as work-around for issues in `include()` |
||
26 | * or `require()` calls and OPcache delivering wrong results. |
||
27 | * |
||
28 | * @see https://bugs.php.net/bug.php?id=66569 |
||
29 | */ |
||
30 | public static function resetOpCache() |
||
39 | |||
40 | /** |
||
41 | * Determines base file that can be accessed using the regular file system. |
||
42 | * For e.g. "phar:///home/user/bundle.phar/content.txt" that would result |
||
43 | * into "/home/user/bundle.phar". |
||
44 | * |
||
45 | * @param string $path |
||
46 | * @return string|null |
||
47 | */ |
||
48 | public static function determineBaseFile(string $path) |
||
62 | |||
63 | /** |
||
64 | * @param string $path |
||
65 | * @return bool |
||
66 | */ |
||
67 | public static function hasPharPrefix(string $path): bool |
||
71 | |||
72 | /** |
||
73 | * @param string $path |
||
74 | * @return string |
||
75 | */ |
||
76 | public static function removePharPrefix(string $path): string |
||
84 | |||
85 | /** |
||
86 | * Normalizes a path, removes phar:// prefix, fixes Windows directory |
||
87 | * separators. Result is without trailing slash. |
||
88 | * |
||
89 | * @param string $path |
||
90 | * @return string |
||
91 | */ |
||
92 | public static function normalizePath(string $path): string |
||
101 | |||
102 | /** |
||
103 | * Fixes a path for windows-backslashes and reduces double-slashes to single slashes |
||
104 | * |
||
105 | * @param string $path File path to process |
||
106 | * @return string |
||
107 | */ |
||
108 | public static function normalizeWindowsPath(string $path): string |
||
112 | |||
113 | /** |
||
114 | * Resolves all dots, slashes and removes spaces after or before a path... |
||
115 | * |
||
116 | * @param string $path Input string |
||
117 | * @return string Canonical path, always without trailing slash |
||
118 | */ |
||
119 | private static function getCanonicalPath($path): string |
||
172 | |||
173 | /** |
||
174 | * Checks if the $path is absolute or relative (detecting either '/' or |
||
175 | * 'x:/' as first part of string) and returns TRUE if so. |
||
176 | * |
||
177 | * @param string $path File path to evaluate |
||
178 | * @return bool |
||
179 | */ |
||
180 | private static function isAbsolutePath($path): bool |
||
190 | |||
191 | /** |
||
192 | * @return bool |
||
193 | */ |
||
194 | private static function isWindows(): bool |
||
198 | } |
||
199 |
If you suppress an error, we recommend checking for the error condition explicitly: