From 01dc2fef84f07aef95a7bd5db84904f662d731d1 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Sun, 25 Feb 2024 12:53:13 +0100 Subject: [PATCH] Fix loading stubs from phar file on Windows Fixes vimeo/psalm#10747 --- src/Psalm/Config.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index a4d4fe35e24..a8a08366e43 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -2326,6 +2326,10 @@ public function visitPreloadedStubFiles(Codebase $codebase, ?Progress $progress foreach ($stub_files as $file_path) { $file_path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $file_path); + // fix mangled phar paths on Windows + if (strpos($file_path, 'phar:\\\\') === 0) { + $file_path = 'phar://'. substr($file_path, 7); + } $codebase->scanner->addFileToDeepScan($file_path); } @@ -2423,6 +2427,10 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null): foreach ($stub_files as $file_path) { $file_path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $file_path); + // fix mangled phar paths on Windows + if (strpos($file_path, 'phar:\\\\') === 0) { + $file_path = 'phar://' . substr($file_path, 7); + } $codebase->scanner->addFileToDeepScan($file_path); }