Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SemanticVersion.php

function SemanticVersion::majorMinorConstraint

Given a version, generate a loose ^major.minor constraint.

Parameters

string $version: Semantic version string. Example: 9.5.0-beta23.

Return value

string Constraint string for major and minor. Example: ^9.5

1 call to SemanticVersion::majorMinorConstraint()
ComponentGenerator::getPackage in composer/Generator/ComponentGenerator.php
Reconcile component dependencies with core.

File

composer/Util/SemanticVersion.php, line 19

Class

SemanticVersion
Utility methods for manipulating semantic versions.

Namespace

Drupal\Composer\Util

Code

public static function majorMinorConstraint(string $version) : string {
    preg_match('/^(\\d+)\\.(\\d+)\\.\\d+/', $version, $matches);
    return '^' . $matches[1] . '.' . $matches[2];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal