@@ -210,6 +210,17 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json)
210
210
}
211
211
}
212
212
213
+ /**
214
+ * Checks if package vendor is Magento.
215
+ *
216
+ * @param string $packageName
217
+ * @return bool
218
+ */
219
+ private function isVendorMagento (string $ packageName )
220
+ {
221
+ return strpos ($ packageName , 'magento/ ' ) === 0 ;
222
+ }
223
+
213
224
/**
214
225
* Assert that component registrar is autoloaded in composer json
215
226
*
@@ -313,12 +324,24 @@ private function assertDependsOnFramework(\StdClass $json)
313
324
private function assertPhpVersionInSync ($ name , $ phpVersion )
314
325
{
315
326
if (isset (self ::$ rootJson ['require ' ]['php ' ])) {
316
- $ this ->assertEquals (
317
- self ::$ rootJson ['require ' ]['php ' ],
318
- $ phpVersion ,
319
- "PHP version {$ phpVersion } in component {$ name } is inconsistent with version "
320
- . self ::$ rootJson ['require ' ]['php ' ] . ' in root composer.json '
321
- );
327
+ if ($ this ->isVendorMagento ($ name )) {
328
+ $ this ->assertEquals (
329
+ self ::$ rootJson ['require ' ]['php ' ],
330
+ $ phpVersion ,
331
+ "PHP version {$ phpVersion } in component {$ name } is inconsistent with version "
332
+ . self ::$ rootJson ['require ' ]['php ' ] . ' in root composer.json '
333
+ );
334
+ } else {
335
+ $ composerVersionsPattern = '{\s*\|\|?\s*} ' ;
336
+ $ rootPhpVersions = preg_split ($ composerVersionsPattern , self ::$ rootJson ['require ' ]['php ' ]);
337
+ $ modulePhpVersions = preg_split ($ composerVersionsPattern , $ phpVersion );
338
+
339
+ $ this ->assertEmpty (
340
+ array_diff ($ rootPhpVersions , $ modulePhpVersions ),
341
+ "PHP version {$ phpVersion } in component {$ name } is inconsistent with version "
342
+ . self ::$ rootJson ['require ' ]['php ' ] . ' in root composer.json '
343
+ );
344
+ }
322
345
}
323
346
}
324
347
0 commit comments