19 declare(strict_types=1);
30 protected function isPathIgnored(
string $path, Options $options): bool
32 $regex =
'(' . implode(
'|', $options->getIgnoredPathSnippets()) .
')';
33 return preg_match($regex, $path) > 0;
36 protected function ensureDirectorySeperator(
string $path): string
38 return rtrim($path,
"/") .
"/";
44 private function realpath(
string $path): string
46 $path = array_reduce(explode(
'/', $path),
function (
$a,
$b) {
50 if (
$b ===
"" ||
$b ===
".") {
57 return preg_replace(
"/\/+/",
"/",
"$a/$b");
59 return trim((
string) $path,
"/");
62 protected function normalizePath($path, $separator =
'\\/'): string
66 if (str_starts_with((
string) $path,
'..')) {
67 throw new \InvalidArgumentException(
'The ZIP name must not start with ../. Please provide a real path for the output file.');
71 if (!str_starts_with((
string) $path,
'./')) {
75 if (str_starts_with((
string) $path,
'./') && ($realpath = realpath($path)) !==
false) {
79 $normalized = preg_replace(
'#\p{C}+|^\./#u',
'', (
string) $path);
80 $normalized = preg_replace(
'#/\.(?=/)|^\./|\./$#',
'', (
string) $normalized);
81 $regex =
'#\/*[^/\.]+/\.\.#Uu';
83 while (preg_match($regex, (
string) $normalized)) {
84 $normalized = preg_replace($regex,
'', (
string) $normalized);
87 if (preg_match(
'#/\.{2}|\.{2}/#', (
string) $normalized)) {
88 throw new \LogicException(
89 'Path is outside of the defined root, path: [' . $path .
'], resolved: [' . $normalized .
']' 94 if (!str_starts_with((
string) $normalized,
'./') && !str_starts_with((
string) $normalized,
'/')) {
95 $normalized =
'./' . $normalized;
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static deriveLocationFrom(string $absolute_path)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples