You are here

public function PeclExtension::getPackageInfo in Markdown 8.2

Retrieves the package information for the PECL package.

Parameters

string|null $version: A specific version of package information to retrieve. If not specified, it will default to the currently installed version or the latest version available if not installed.

Return value

array An associative array of PECL package information.

1 call to PeclExtension::getPackageInfo()
PeclExtension::__construct in src/Annotation/PeclExtension.php
AnnotationObject constructor.

File

src/Annotation/PeclExtension.php, line 108

Class

PeclExtension
PeclExtension Annotation.

Namespace

Drupal\markdown\Annotation

Code

public function getPackageInfo($version = NULL) {

  // Attempt to use installed version if none was explicitly specified.
  if (!$version && $this->version) {
    $version = $this->version;
  }
  elseif (!$version && ($latestVersion = $this
    ->getLatestVersion())) {
    $version = $latestVersion;
  }

  // Immediately return if version couldn't be determined.
  if (!$version) {
    return [];
  }
  if (!isset($this->packageInfo[$version])) {
    $this->packageInfo[$version] = [];

    // @see https://github.com/php/web-pecl/blob/e98cb34ebcb26b75b4001d1b3458afdad6ba6f83/src/Rest.php#L519-L520
    if (($name = $this
      ->getName()) && ($data = $this
      ->requestXml(sprintf('https://pecl.php.net/rest/r/%s/package.%s.xml', $name, $version), TRUE))) {
      $this->packageInfo[$version] = $data;
    }
  }
  return $this->packageInfo[$version];
}