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

Breadcrumb

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

function InstalledVersions::satisfies

Same name in this branch
  1. 11.1.x vendor/composer/composer/src/Composer/InstalledVersions.php \Composer\InstalledVersions::satisfies()

Checks whether the given package satisfies a version constraint

e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:

Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')

Parameters

VersionParser $parser Install composer/semver to have access to this class and functionality:

string $packageName:

string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package:

Return value

bool

1 call to InstalledVersions::satisfies()
PackageDependency::isSatisfied in vendor/tbachert/spi/src/ServiceProviderDependency/PackageDependency.php
Returns whether this requirement is satisfied.

File

vendor/composer/InstalledVersions.php, line 125

Class

InstalledVersions
This class is copied in every Composer installed project and available to all

Namespace

Composer

Code

public static function satisfies(VersionParser $parser, $packageName, $constraint) {
    $constraint = $parser->parseConstraints((string) $constraint);
    $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
    return $provided->matches($constraint);
}

API Navigation

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