version_compare example

return false;
    }

    /** * @throws RuntimeException */
    private function checkVersion(PDO $conn)
    {
        $sql = 'SELECT VERSION()';
        $result = $conn->query($sql)->fetchColumn(0);
        if (version_compare($result, '5.5.0', '<')) {
            throw new RuntimeException("Database error!: Your database server is running MySQL $result, but Shopware 5 requires at least MySQL 5.5");
        }
    }

    /** * @throws RuntimeException */
    private function checkEngineSupport(PDO $conn)
    {
        $hasEngineSupport = $this->hasStorageEngine('InnoDB', $conn);
        if (!$hasEngineSupport) {
            
    // as a parameter; empty string must be used instead.     $lowest_supported_version = $lowest_supported_version ?? (string) array_key_last(static::$phpEolDates);

    // Next, look at versions that are end-of-life after the current date.     // Find the lowest PHP version that is still supported.     foreach (static::$phpEolDates as $version => $eol_date) {
      $eol_datetime = new \DateTime($eol_date);

      if ($eol_datetime > $date) {
        // If $version is less than the previously discovered lowest supported         // version, use $version as the lowest supported version instead.         if (version_compare($version$lowest_supported_version) < 0) {
          $lowest_supported_version = $version;
        }
      }
    }

    // If PHP versions older than the Drupal minimum PHP version are still     // supported, return Drupal minimum PHP version instead.     if (version_compare($lowest_supported_versionstatic::$drupalMinimumPhp) < 0) {
      return static::$drupalMinimumPhp;
    }

    

    private function compare($name$value$requiredValue)
    {
        $m = 'compare' . str_replace(' ', '', ucwords(str_replace(['_', '.'], ' ', $name)));
        if (method_exists($this$m)) {
            return $this->$m($value$requiredValue);
        } elseif (preg_match('#^[0-9]+[A-Z]$#', $requiredValue)) {
            return $this->decodePhpSize($requiredValue) <= $this->decodePhpSize($value);
        } elseif (preg_match('#^[0-9]+ [A-Z]+$#i', $requiredValue)) {
            return $this->decodeSize($requiredValue) <= $this->decodeSize($value);
        } elseif (preg_match('#^[0-9][0-9\.]+$#', $requiredValue)) {
            return version_compare($requiredValue$value, '<=');
        }

        return $requiredValue == $value;
    }

    /** * Checks the php version * * @return bool|string */
    private function checkPhp()
    {
public function check($requirement)
    {
        if (!\is_string($requirement['value'])) {
            throw new InvalidArgumentException(__CLASS__ . ' needs a string as value for the requirement check');
        }

        $conn = Shopware()->Container()->get(Connection::class);
        $version = $conn->fetchColumn('SELECT VERSION()');

        $minMySQLVersion = $requirement['value'];

        $validVersion = version_compare($version$minMySQLVersion) >= 0;

        $successMessage = $this->namespace->get('controller/check_mysqlversion_success', 'Min MySQL Version: %s, your version %s');
        $failMessage = $this->namespace->get('controller/check_mysqlversion_failure', 'Min MySQL Version %s, your version %s');

        if ($validVersion) {
            return [
                'type' => self::CHECK_TYPE,
                'errorLevel' => Validation::REQUIREMENT_VALID,
                'message' => sprintf(
                    $successMessage,
                    $minMySQLVersion,
                    
'title' => t('Drupal'),
      'value' => \Drupal::VERSION,
      'severity' => REQUIREMENT_INFO,
    ];
  }

  // Test PHP version   $requirements['php'] = [
    'title' => t('PHP'),
    'value' => ($phase == 'runtime') ? Link::fromTextAndUrl(phpversion(), Url::fromRoute('system.php'))->toString() : phpversion(),
  ];
  if (version_compare(phpversion(), \Drupal::MINIMUM_PHP) < 0) {
    $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => \Drupal::MINIMUM_PHP]);
    $requirements['php']['severity'] = REQUIREMENT_ERROR;
  }

  // Report cron status   if ($phase == 'runtime') {
    $cron_last = \Drupal::state()->get('system.cron_last');

    if (is_numeric($cron_last)) {
      $requirements['cron']['value'] = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
    }
    

    protected $null = 'NULL';

    /** * Constructor. */
    public function __construct(BaseConnection $db)
    {
        parent::__construct($db);

        if (version_compare($this->db->getVersion(), '3.3', '<')) {
            $this->dropTableIfStr = false;
        }
    }

    /** * Create database * * @param bool $ifNotExists Whether to add IF NOT EXISTS condition */
    public function createDatabase(string $dbName, bool $ifNotExists = false): bool
    {
        

  public function checkIncompatibility($name) {
    $extension = $this->get($name);
    return $extension->info['core_incompatible'] || (isset($extension->info['php']) && version_compare(phpversion()$extension->info['php']) < 0);
  }

  /** * Array sorting callback; sorts extensions by their name. * * @param \Drupal\Core\Extension\Extension $a * The first extension to compare. * @param \Drupal\Core\Extension\Extension $b * The second extension to compare. * * @return int * Less than 0 if $a is less than $b, more than 0 if $a is greater than $b, * and 0 if they are equal. */
sprintf(
                    'There should only be one live and one deprecated version at the same time. Found Manifest schema versions: %s',
                    print_r($versions, true)
                )
            );
        }

        $highest = null;
        foreach ($versions as $version) {
            // we have to search for the lowest version here             // because this is the already deprecated but still used version of the manifest schema             if ($highest === null || version_compare($highest$version) === 1) {
                $highest = $version;
            }
        }

        return $highest;
    }
}
// RECOMMENDED_PHP can be just MAJOR.MINOR so normalize it to allow using     // version_compare().     $normalizer = function Dstring $version): string {
      // The regex below is from \Composer\Semver\VersionParser::normalize().       preg_match('{^(\d{1,5})(\.\d++)?(\.\d++)?$}i', $version$matches);
      return $matches[1]
        . (!empty($matches[2]) ? $matches[2] : '.9999999')
        . (!empty($matches[3]) ? $matches[3] : '.9999999');
    };

    $recommended_php = $normalizer(\Drupal::RECOMMENDED_PHP);
    $this->assertTrue(version_compare($recommended_php, \Drupal::MINIMUM_PHP, '>='), "\Drupal::RECOMMENDED_PHP should be greater or equal to \Drupal::MINIMUM_PHP");

    // As this test depends on the $normalizer function it is tested.     $this->assertSame('10.9999999.9999999', $normalizer('10'));
    $this->assertSame('10.1.9999999', $normalizer('10.1'));
    $this->assertSame('10.1.2', $normalizer('10.1.2'));
  }

  /** * Sets up a mock expectation for the container get() method. * * @param string $service_name * The service name to expect for the get() method. * @param mixed $return * The value to return from the mocked container get() method. */

            ['code' => $isoCode]
        );

        return $languageId === false ? null : Uuid::fromBytesToHex($languageId);
    }

    private function getLatestApiVersion(): ?int
    {
        $sortedSupportedApiVersions = array_values($this->supportedApiVersions);

        usort($sortedSupportedApiVersionsfn (int $version1, int $version2) => \version_compare((string) $version1(string) $version2));

        return array_pop($sortedSupportedApiVersions);
    }

    private function getCustomerByEmail(string $customerId, string $email, Context $context, ?string $boundSalesChannelId): ?CustomerEntity
    {
        $criteria = new Criteria();
        $criteria->setLimit(1);
        if ($boundSalesChannelId) {
            $criteria->addAssociation('boundSalesChannel');
        }

        
$headers = array();
            }
            if (!$force_fsockopen && function_exists('curl_exec'))
            {
                $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
                $fp = curl_init();
                $headers2 = array();
                foreach ($headers as $key => $value)
                {
                    $headers2[] = "$key: $value";
                }
                if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
                {
                    curl_setopt($fp, CURLOPT_ENCODING, '');
                }
                curl_setopt($fp, CURLOPT_URL, $url);
                curl_setopt($fp, CURLOPT_HEADER, 1);
                curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($fp, CURLOPT_FAILONERROR, 1);
                curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
                curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
                curl_setopt($fp, CURLOPT_REFERER, SimplePie_Misc::url_remove_credentials($url));
                curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
                

define('MAINTENANCE_MODE', 'install');

// Exit early if an incompatible PHP version is in use, so that the user sees a // helpful error message rather than a white screen from any fatal errors due to // the incompatible version. The minimum version is also hardcoded (instead of // \Drupal::MINIMUM_PHP), to avoid any fatal errors that might result from // loading the autoloader or core/lib/Drupal.php. Note: Remember to update the // hardcoded minimum PHP version below (both in the version_compare() call and // in the printed message to the user) whenever \Drupal::MINIMUM_PHP is // updated. if (version_compare(PHP_VERSION, '8.1.0') < 0) {
  print 'Your PHP installation is too old. Refer to the <a href="https://www.drupal.org/docs/system-requirements/php-requirements">Drupal PHP requirements</a> for the currently recommended PHP version for this release. See <a href="https://php.net/supported-versions.php">PHP\'s version support documentation</a> for more information on PHP\'s own support schedule.';
  exit;
}

// Initialize the autoloader. $class_loader = require_once $root_path . '/autoload.php';

// If OPCache is in use, ensure opcache.save_comments is enabled. if (OpCodeCache::isEnabled() && !ini_get('opcache.save_comments')) {
  print 'Systems with OPcache installed must have <a href="http://php.net/manual/opcache.configuration.php#ini.opcache.save-comments">opcache.save_comments</a> enabled.';
  exit();
}
<?php /** * Smarty shared plugin * * @package Smarty * @subpackage PluginsShared */

if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
    /** * escape_special_chars common function * * Function: smarty_function_escape_special_chars<br> * Purpose: used by other smarty functions to escape * special chars except for already escaped ones * * @author Monte Ohrt <monte at ohrt dot com> * @param string $string text that should by escaped * @return string */
    
const ATTACHMENTS_NONE   = false;
    const ATTACHMENTS_INLINE = true;

    /** * @throws getid3_exception */
    public function __construct() {

        // Check for PHP version         $required_php_version = '5.3.0';
        if (version_compare(PHP_VERSION, $required_php_version, '<')) {
            $this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION."\n";
            return;
        }

        // Check memory         $memoryLimit = ini_get('memory_limit');
        if (preg_match('#([0-9]+) ?M#i', $memoryLimit$matches)) {
            // could be stored as "16M" rather than 16777216 for example             $memoryLimit = $matches[1] * 1048576;
        } elseif (preg_match('#([0-9]+) ?G#i', $memoryLimit$matches)) { // The 'G' modifier is available since PHP 5.1.0             // could be stored as "2G" rather than 2147483648 for example

class MemcachedStoreTest extends AbstractStoreTestCase
{
    use ExpiringStoreTestTrait;

    public static function setUpBeforeClass(): void
    {
        if (version_compare(phpversion('memcached'), '3.1.6', '<')) {
            throw new SkippedTestSuiteError('Extension memcached > 3.1.5 required.');
        }

        $memcached = new \Memcached();
        $memcached->addServer(getenv('MEMCACHED_HOST'), 11211);
        $memcached->get('foo');
        $code = $memcached->getResultCode();

        if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) {
            throw new SkippedTestSuiteError('Unable to connect to the memcache host');
        }
    }
Home | Imprint | This part of the site doesn't use cookies.