comparison vendor/composer/semver/src/VersionParser.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
320 'Invalid operator "~>", you probably meant to use the "~" operator' 320 'Invalid operator "~>", you probably meant to use the "~" operator'
321 ); 321 );
322 } 322 }
323 323
324 // Work out which position in the version we are operating at 324 // Work out which position in the version we are operating at
325 if (isset($matches[4]) && '' !== $matches[4]) { 325 if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
326 $position = 4; 326 $position = 4;
327 } elseif (isset($matches[3]) && '' !== $matches[3]) { 327 } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
328 $position = 3; 328 $position = 3;
329 } elseif (isset($matches[2]) && '' !== $matches[2]) { 329 } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
330 $position = 2; 330 $position = 2;
331 } else { 331 } else {
332 $position = 1; 332 $position = 1;
333 } 333 }
334 334
335 // Calculate the stability suffix 335 // Calculate the stability suffix
336 $stabilitySuffix = ''; 336 $stabilitySuffix = '';
337 if (!empty($matches[5])) { 337 if (empty($matches[5]) && empty($matches[7])) {
338 $stabilitySuffix .= '-' . $this->expandStability($matches[5]) . (!empty($matches[6]) ? $matches[6] : '');
339 }
340
341 if (!empty($matches[7])) {
342 $stabilitySuffix .= '-dev'; 338 $stabilitySuffix .= '-dev';
343 } 339 }
344 340
345 if (!$stabilitySuffix) { 341 $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
346 $stabilitySuffix = '-dev';
347 }
348
349 $lowVersion = $this->manipulateVersionString($matches, $position, 0) . $stabilitySuffix;
350 $lowerBound = new Constraint('>=', $lowVersion); 342 $lowerBound = new Constraint('>=', $lowVersion);
351 343
352 // For upper bound, we increment the position of one more significance, 344 // For upper bound, we increment the position of one more significance,
353 // but highPosition = 0 would be illegal 345 // but highPosition = 0 would be illegal
354 $highPosition = max(1, $position - 1); 346 $highPosition = max(1, $position - 1);
366 // Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple. 358 // Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple.
367 // In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for 359 // In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for
368 // versions 0.X >=0.1.0, and no updates for versions 0.0.X 360 // versions 0.X >=0.1.0, and no updates for versions 0.0.X
369 if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) { 361 if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
370 // Work out which position in the version we are operating at 362 // Work out which position in the version we are operating at
371 if ('0' !== $matches[1] || '' === $matches[2]) { 363 if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
372 $position = 1; 364 $position = 1;
373 } elseif ('0' !== $matches[2] || '' === $matches[3]) { 365 } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
374 $position = 2; 366 $position = 2;
375 } else { 367 } else {
376 $position = 3; 368 $position = 3;
377 } 369 }
378 370
399 // X Range 391 // X Range
400 // 392 //
401 // Any of X, x, or * may be used to "stand in" for one of the numeric values in the [major, minor, patch] tuple. 393 // Any of X, x, or * may be used to "stand in" for one of the numeric values in the [major, minor, patch] tuple.
402 // A partial version range is treated as an X-Range, so the special character is in fact optional. 394 // A partial version range is treated as an X-Range, so the special character is in fact optional.
403 if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) { 395 if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
404 if (isset($matches[3]) && '' !== $matches[3]) { 396 if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
405 $position = 3; 397 $position = 3;
406 } elseif (isset($matches[2]) && '' !== $matches[2]) { 398 } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
407 $position = 2; 399 $position = 2;
408 } else { 400 } else {
409 $position = 1; 401 $position = 1;
410 } 402 }
411 403