@@ -189,6 +189,17 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json)
189
189
$ this ->assertPackageVersions ($ json );
190
190
}
191
191
192
+ /**
193
+ * Checks if package vendor is Magento.
194
+ *
195
+ * @param string $packageName
196
+ * @return bool
197
+ */
198
+ private function isVendorMagento ($ packageName )
199
+ {
200
+ return strpos ($ packageName , 'magento/ ' ) === 0 ;
201
+ }
202
+
192
203
/**
193
204
* Assert that component registrar is autoloaded in composer json
194
205
*
@@ -276,12 +287,24 @@ private function assertDependsOnFramework(\StdClass $json)
276
287
private function assertPhpVersionInSync ($ name , $ phpVersion )
277
288
{
278
289
if (isset (self ::$ rootJson ['require ' ]['php ' ])) {
279
- $ this ->assertEquals (
280
- self ::$ rootJson ['require ' ]['php ' ],
281
- $ phpVersion ,
282
- "PHP version {$ phpVersion } in component {$ name } is inconsistent with version "
283
- . self ::$ rootJson ['require ' ]['php ' ] . ' in root composer.json '
284
- );
290
+ if ($ this ->isVendorMagento ($ name )) {
291
+ $ this ->assertEquals (
292
+ self ::$ rootJson ['require ' ]['php ' ],
293
+ $ phpVersion ,
294
+ "PHP version {$ phpVersion } in component {$ name } is inconsistent with version "
295
+ . self ::$ rootJson ['require ' ]['php ' ] . ' in root composer.json '
296
+ );
297
+ } else {
298
+ $ composerVersionsPattern = '{\s*\|\|?\s*} ' ;
299
+ $ rootPhpVersions = preg_split ($ composerVersionsPattern , self ::$ rootJson ['require ' ]['php ' ]);
300
+ $ modulePhpVersions = preg_split ($ composerVersionsPattern , $ phpVersion );
301
+
302
+ $ this ->assertEmpty (
303
+ array_diff ($ rootPhpVersions , $ modulePhpVersions ),
304
+ "PHP version {$ phpVersion } in component {$ name } is inconsistent with version "
305
+ . self ::$ rootJson ['require ' ]['php ' ] . ' in root composer.json '
306
+ );
307
+ }
285
308
}
286
309
}
287
310
0 commit comments