Skip to content
Permalink
Browse files

Reduce with / before converting back

  • Loading branch information...
muglug committed Jul 21, 2019
1 parent 76508e6 commit 3d4adee6b332aa3408a934e4c2c7871364e20fcd
Showing with 1 addition and 5 deletions.
  1. +1 −5 src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php
@@ -330,16 +330,12 @@ public static function normalizeFilePath(string $path_to_file) : string
// first remove unnecessary / duplicates
$path_to_file = preg_replace('/\/[\/]+/', '/', $path_to_file);
$path_to_file = preg_replace('/\/[\/]+/', '/', $path_to_file);
$reduce_pattern = '/\/[^\/]+\/\.\.\//';
while (preg_match($reduce_pattern, $path_to_file)) {
$path_to_file = preg_replace($reduce_pattern, DIRECTORY_SEPARATOR, $path_to_file, 1);
$path_to_file = preg_replace($reduce_pattern, '/', $path_to_file, 1);
}
$path_to_file = str_replace('/./', '/', $path_to_file);
if (DIRECTORY_SEPARATOR !== '/') {
$path_to_file = str_replace('/', DIRECTORY_SEPARATOR, $path_to_file);
}

0 comments on commit 3d4adee

Please sign in to comment.
You can’t perform that action at this time.