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

Breadcrumb

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

function PhpVersion::fromString

Parse the version from a string like "8.1".

File

vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php, line 59

Class

PhpVersion
A PHP version, representing only the major and minor version components.

Namespace

PhpParser

Code

public static function fromString(string $version) : self {
    if (!preg_match('/^(\\d+)\\.(\\d+)/', $version, $matches)) {
        throw new \LogicException("Invalid PHP version \"{$version}\"");
    }
    return self::fromComponents((int) $matches[1], (int) $matches[2]);
}

API Navigation

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