@@ -309,37 +309,46 @@ private function assertPhpVersionInSync($name, $phpVersion)
309
309
* Make sure requirements of components are reflected in root composer.json
310
310
*
311
311
* @param \StdClass $json
312
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
313
312
*/
314
313
private function assertRequireInSync (\StdClass $ json )
315
314
{
316
315
if (preg_match ('/magento\/project-*/ ' , self ::$ rootJson ['name ' ]) == 1 ) {
317
316
return ;
318
317
}
318
+ if (!in_array ($ json ->name , self ::$ rootComposerModuleBlacklist ) && isset ($ json ->require )) {
319
+ $ this ->checkPackageInRootComposer ($ json );
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Check if package is reflected in root composer.json
325
+ *
326
+ * @param \StdClass $json
327
+ */
328
+ private function checkPackageInRootComposer (\StdClass $ json ): void
329
+ {
319
330
$ name = $ json ->name ;
320
- if (!in_array ($ name , self ::$ rootComposerModuleBlacklist ) && isset ($ json ->require )) {
321
- $ errors = [];
322
- foreach (array_keys ((array )$ json ->require ) as $ depName ) {
323
- if ($ depName == 'magento/magento-composer-installer ' ) {
324
- // Magento Composer Installer is not needed for already existing components
325
- continue ;
326
- }
327
- if (!isset (self ::$ rootJson ['require-dev ' ][$ depName ]) && !isset (self ::$ rootJson ['require ' ][$ depName ])
328
- && !isset (self ::$ rootJson ['replace ' ][$ depName ])) {
329
- $ errors [] = "' $ name' depends on ' $ depName' " ;
330
- }
331
+ $ errors = [];
332
+ foreach (array_keys ((array )$ json ->require ) as $ depName ) {
333
+ if ($ depName == 'magento/magento-composer-installer ' ) {
334
+ // Magento Composer Installer is not needed for already existing components
335
+ continue ;
331
336
}
332
- if (!empty ($ errors )) {
333
- $ this ->fail (
334
- "The following dependencies are missing in root 'composer.json', "
335
- . " while declared in child components. \n"
336
- . "Consider adding them to 'require-dev' section (if needed for child components only), "
337
- . " to 'replace' section (if they are present in the project), "
338
- . " to 'require' section (if needed for the skeleton). \n"
339
- . join ("\n" , $ errors )
340
- );
337
+ if (!isset (self ::$ rootJson ['require-dev ' ][$ depName ]) && !isset (self ::$ rootJson ['require ' ][$ depName ])
338
+ && !isset (self ::$ rootJson ['replace ' ][$ depName ])) {
339
+ $ errors [] = "' $ name' depends on ' $ depName' " ;
341
340
}
342
341
}
342
+ if (!empty ($ errors )) {
343
+ $ this ->fail (
344
+ "The following dependencies are missing in root 'composer.json', "
345
+ . " while declared in child components. \n"
346
+ . "Consider adding them to 'require-dev' section (if needed for child components only), "
347
+ . " to 'replace' section (if they are present in the project), "
348
+ . " to 'require' section (if needed for the skeleton). \n"
349
+ . join ("\n" , $ errors )
350
+ );
351
+ }
343
352
}
344
353
345
354
/**
0 commit comments