function SemanticVersion::majorMinorConstraint
Same name in other branches
- 10 composer/Util/SemanticVersion.php \Drupal\Composer\Util\SemanticVersion::majorMinorConstraint()
- 11.x composer/Util/SemanticVersion.php \Drupal\Composer\Util\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\UtilCode
public static function majorMinorConstraint(string $version) : string {
preg_match('/^(\\d+)\\.(\\d+)\\.\\d+/', $version, $matches);
return '^' . $matches[1] . '.' . $matches[2];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.