From e981778383aa1048c1f0a641517cfda746d4d696 Mon Sep 17 00:00:00 2001 From: Floris Luiten Date: Wed, 13 Dec 2023 13:27:35 +0100 Subject: [PATCH] Fix "Cannot locate enable" with Symfony project Fixes the "Cannot locate enable" error when using psalm-plugin enable with a Symfony project --- src/Psalm/Config.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index 0cd65f165f4..82c696c0bcd 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -1302,7 +1302,17 @@ private static function fromXmlAndPaths( // any paths passed via CLI should be added to the projectFiles // as they're getting analyzed like if they are part of the project // ProjectAnalyzer::getInstance()->check_paths_files is not populated at this point in time - $paths_to_check = CliUtils::getPathsToCheck(null); + + $paths_to_check = null; + + global $argv; + + // Hack for Symfonys own argv resolution. + // @see https://github.com/vimeo/psalm/issues/10465 + if (!isset($argv[0]) || basename($argv[0]) !== 'psalm-plugin') { + $paths_to_check = CliUtils::getPathsToCheck(null); + } + if ($paths_to_check !== null) { $paths_to_add_to_project_files = array(); foreach ($paths_to_check as $path) {