Closed miljenko1 closed 6 years ago
For quick fix I changed the code to check for "/./" after ".." loop.
$path_to_file = preg_replace('/\/[\/]+/', '/', $path_to_file);
$path_to_file = str_replace('/./', '/', $path_to_file);
$slash = preg_quote(DIRECTORY_SEPARATOR, '/');
$reduce_pattern = '/' . $slash . '[^' . $slash . ']+' . $slash . '\.\.' . $slash . '/';
while (preg_match($reduce_pattern, $path_to_file)) {
$path_to_file = preg_replace($reduce_pattern, DIRECTORY_SEPARATOR, $path_to_file);
}
$path_to_file = str_replace('/./', '/', $path_to_file); // ADD THIS LINE FOR QUICK FIX
I occasionally get this after, usually it gets fixed by clearing the psalm cache.
Thanks all!
Issue is similar to one reported in https://github.com/vimeo/psalm/issues/1005
$ ./components/bin/psalm --version Psalm dev-master@3fc67782a9723c4f21c06e611e4c864bd735695e
$ ./components/bin/psalm index.php Scanning files... Analyzing files... PHP Fatal error: Uncaught InvalidArgumentException: Could not get file storage for /mnt/g/temp/ciklama/./controller/controller.php in /mnt/g/temp/ciklama/components/vimeo/psalm/src/Psalm/Provider/FileStorageProvider.php:44 Stack trace:
0 /mnt/g/temp/ciklama/components/vimeo/psalm/src/Psalm/Checker/FileChecker.php(104): Psalm\Provider\FileStorageProvider->get('/mnt/g/temp/cik...')
1 /mnt/g/temp/ciklama/components/vimeo/psalm/src/Psalm/Checker/Statements/Expression/IncludeChecker.php(129): Psalm\Checker\FileChecker->analyze(Object(Psalm\Context), false, NULL)
2 /mnt/g/temp/ciklama/components/vimeo/psalm/src/Psalm/Checker/Statements/ExpressionChecker.php(496): Psalm\Checker\Statements\Expression\IncludeChecker::analyze(Object(Psalm\Checker\StatementsChecker), Object(PhpParser\Node\Expr\Include_), Object(Psalm\Context), NULL)
3 /mnt/g/temp/ciklama/components/vimeo/psalm/src/Psalm/Checker/StatementsChecker.php(508): Psalm\Checker\Statements\ExpressionChecker::analyze(Object(Psalm\Checker\StatementsChecker), Object(PhpParser\No in /mnt/g/temp/ciklama/components/vimeo/psalm/src/Psalm/Provider/FileStorageProvider.php on line 44