@@ -20,6 +20,8 @@ class ComposerCollector
2020{
2121 private string $ cwd ;
2222
23+ private string $ composerJsonPath ;
24+
2325 /** @var string[] */
2426 private array $ additionalProdPaths = [];
2527
@@ -78,6 +80,7 @@ private function runComposerDependencyAnalyser(): AnalysisResult
7880 $ composerJson = $ initializer ->initComposerJson (options: $ options );
7981 $ initializer ->initComposerAutoloader (composerJson: $ composerJson );
8082 $ configuration = $ initializer ->initConfiguration (options: $ options , composerJson: $ composerJson );
83+ $ this ->composerJsonPath = dirname ($ composerJson ->composerVendorDir ).'/composer.json ' ;
8184
8285 $ configuration ->ignoreErrors ([ErrorType::UNKNOWN_CLASS , ErrorType::UNKNOWN_FUNCTION ]);
8386
@@ -146,14 +149,14 @@ private function reformatResults(AnalysisResult $results): array
146149 ),
147150 array_map (
148151 fn ($ error ) => RuleErrorBuilder::message ("Prod dependency used only in dev paths: {$ error }" )
149- ->file (' composer.json ' )
152+ ->file ($ this -> composerJsonPath )
150153 ->tip ('This should probably be moved to "require-dev" section in composer.json ' )
151154 ->identifier ('composer.prodInDev ' )
152155 ->build (),
153156 $ results ->getProdDependencyOnlyInDevErrors ()),
154157 array_map (
155158 fn ($ error ) => RuleErrorBuilder::message ("Unused dependency detected: {$ error }" )
156- ->file (' composer.json ' )
159+ ->file ($ this -> composerJsonPath )
157160 ->tip ('This is listed in composer.json, but no usage was found in scanned paths ' )
158161 ->identifier ('composer.unused ' )
159162 ->build (),
0 commit comments