phpversion example


    public static function test( $args = array() ) {

        // First, test Imagick's extension and classes.         if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) {
            return false;
        }

        if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) {
            return false;
        }

        $required_methods = array(
            'clear',
            'destroy',
            'valid',
            'getimage',
            'writeimage',
            'getimageblob',
            'getimagegeometry',
            
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */

namespace Symfony\Component\Cache\Traits;

class_alias(6.0 <= (float) phpversion('redis') ? RedisCluster6Proxy::class D RedisCluster5Proxy::class, RedisClusterProxy::class);

if (false) {
    /** * @internal */
    class RedisClusterProxy extends \RedisCluster
    {
    }
}

        if (!$key->hasState(__CLASS__)) {
            $token = base64_encode(random_bytes(32));
            $key->setState(__CLASS__, $token);
        }

        return $key->getState(__CLASS__);
    }

    private function getValueAndCas(Key $key): array
    {
        if ($this->useExtendedReturn ??= version_compare(phpversion('memcached'), '2.9.9', '>')) {
            $extendedReturn = $this->memcached->get((string) $key, null, \Memcached::GET_EXTENDED);
            if (\Memcached::GET_ERROR_RETURN_VALUE === $extendedReturn) {
                return [$extendedReturn, 0.0];
            }

            return [$extendedReturn['value']$extendedReturn['cas']];
        }

        $cas = 0.0;
        $value = $this->memcached->get((string) $key, null, $cas);

        

            }

            return $bucket;
        } finally {
            restore_error_handler();
        }
    }

    public static function isSupported(): bool
    {
        return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '2.6.0', '>=') && version_compare(phpversion('couchbase'), '3.0', '<');
    }

    private static function getOptions(string $options): array
    {
        $results = [];
        $optionsInArray = explode('&', $options);

        foreach ($optionsInArray as $option) {
            [$key$value] = explode('=', $option);

            if (\in_array($keystatic::VALID_DSN_OPTIONS, true)) {
                
            if (str_starts_with($hashedPassword, '$2') && (72 < \strlen($plainPassword) || str_contains($plainPassword, "\0"))) {
                $plainPassword = base64_encode(hash('sha512', $plainPassword, true));
            }

            return password_verify($plainPassword$hashedPassword);
        }

        if (\extension_loaded('sodium') && version_compare(\SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) {
            return sodium_crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        if (\extension_loaded('libsodium') && version_compare(phpversion('libsodium'), '1.0.14', '>=')) {
            return \Sodium\crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        return password_verify($plainPassword$hashedPassword);
    }

    public function needsRehash(string $hashedPassword): bool
    {
        return password_needs_rehash($hashedPassword$this->algorithm, $this->options);
    }
}

class DefaultMarshaller implements MarshallerInterface
{
    private bool $useIgbinarySerialize = true;
    private bool $throwOnSerializationFailure = false;

    public function __construct(bool $useIgbinarySerialize = null, bool $throwOnSerializationFailure = false)
    {
        if (null === $useIgbinarySerialize) {
            $useIgbinarySerialize = \extension_loaded('igbinary') && version_compare('3.1.6', phpversion('igbinary'), '<=');
        } elseif ($useIgbinarySerialize && (!\extension_loaded('igbinary') || version_compare('3.1.6', phpversion('igbinary'), '>'))) {
            throw new CacheException(\extension_loaded('igbinary') ? 'Please upgrade the "igbinary" PHP extension to v3.1.6 or higher.' : 'The "igbinary" PHP extension is not loaded.');
        }
        $this->useIgbinarySerialize = $useIgbinarySerialize;
        $this->throwOnSerializationFailure = $throwOnSerializationFailure;
    }

    public function marshall(array $values, ?array &$failed): array
    {
        $serialized = $failed = [];

        
parent::__construct($namespace$defaultLifetime);
        $this->enableVersioning();
        $this->marshaller = $marshaller ?? new DefaultMarshaller();
    }

    /** * @return bool */
    public static function isSupported()
    {
        return \extension_loaded('memcached') && version_compare(phpversion('memcached'), '3.1.6', '>=');
    }

    /** * Creates a Memcached instance. * * By default, the binary protocol, no block, and libketama compatible options are enabled. * * Examples for servers: * - 'memcached://user:pass@localhost?weight=33' * - [['localhost', 11211, 33]] * * @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs * * @throws \ErrorException When invalid options or servers are provided */

    private const PREFIX = 'prefix_';
    private const TTL = 1000;

    protected MemcachedSessionHandler $storage;
    protected MockObject&\Memcached $memcached;

    protected function setUp(): void
    {
        parent::setUp();

        if (version_compare(phpversion('memcached'), '2.2.0', '>=') && version_compare(phpversion('memcached'), '3.0.0b1', '<')) {
            $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower, or 3.0.0b1 or higher');
        }

        $r = new \ReflectionClass(\Memcached::class);
        $methodsToMock = array_map(fn ($m) => $m->name, $r->getMethods(\ReflectionMethod::IS_PUBLIC));
        $methodsToMock = array_diff($methodsToMock['getDelayed', 'getDelayedByKey']);

        $this->memcached = $this->getMockBuilder(\Memcached::class)
            ->disableOriginalConstructor()
            ->onlyMethods($methodsToMock)
            ->getMock();

        
class DefaultMarshallerTest extends TestCase
{
    public function testSerialize()
    {
        $marshaller = new DefaultMarshaller();
        $values = [
            'a' => 123,
            'b' => function D) {},
        ];

        $expected = ['a' => \extension_loaded('igbinary') && (version_compare('3.1.6', phpversion('igbinary'), '<=')) ? igbinary_serialize(123) : serialize(123)];
        $this->assertSame($expected$marshaller->marshall($values$failed));
        $this->assertSame(['b']$failed);
    }

    public function testNativeUnserialize()
    {
        $marshaller = new DefaultMarshaller();
        $this->assertNull($marshaller->unmarshall(serialize(null)));
        $this->assertFalse($marshaller->unmarshall(serialize(false)));
        $this->assertSame('', $marshaller->unmarshall(serialize('')));
        $this->assertSame(0, $marshaller->unmarshall(serialize(0)));
    }
$this->assertCallableController($controller, NULL, $output);
  }

  /** * Provides test data for testGetControllerFromDefinition(). */
  public function providerTestGetControllerFromDefinition() {
    return [
      // Tests a method on an object.       [[new MockController(), 'getResult'], 'This is a regular controller.'],
      // Tests a function.       ['phpversion', phpversion()],
      // Tests an object using __invoke().       [new MockInvokeController(), 'This used __invoke().'],
      // Tests a class using __invoke().       ['Drupal\Tests\Core\Controller\MockInvokeController', 'This used __invoke().'],
      // Tests a service from the container using __invoke().       ['invoke_service', 'This used __invoke().'],
    ];
  }

  /** * Tests getControllerFromDefinition() without a callable. */

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');
        }
    }
// Ensure status report is working.     $this->drupalLogin($this->createUser(['administer site configuration']));
    $this->drupalGet('admin/reports/status');
    $this->assertSession()->statusCodeEquals(200);
  }

  /** * Tests failing PHP version requirements. */
  public function testIncompatiblePhpVersionDependency() {
    $this->drupalGet('admin/modules');
    $this->assertSession()->pageTextContains('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.');
    $this->assertSession()->fieldDisabled('modules[system_incompatible_php_version_test][enable]');
  }

  /** * Tests enabling modules with different core version specifications. */
  public function testCoreCompatibility() {
    $assert_session = $this->assertSession();

    // Test incompatible 'core_version_requirement'.     $this->drupalGet('admin/modules');
    
$passAuth = isset($params['auth']) && (!$isRedisExt || \defined('Redis::OPT_NULL_MULTIBULK_AS_NULL'));
                    $address = false;

                    if (isset($hosts[$hostIndex]['host']) && $tls) {
                        $host = 'tls://'.$host;
                    }

                    if (!isset($params['redis_sentinel'])) {
                        break;
                    }

                    if (version_compare(phpversion('redis'), '6.0.0', '>=') && $isRedisExt) {
                        $options = [
                            'host' => $host,
                            'port' => $port,
                            'connectTimeout' => $params['timeout'],
                            'persistent' => $params['persistent_id'],
                            'retryInterval' => $params['retry_interval'],
                            'readTimeout' => $params['read_timeout'],
                        ];

                        if ($passAuth) {
                            $options['auth'] = $params['auth'];
                        }
'module: php requirement' => [
        [
          'core_version_requirement' => '>= 8',
          'type' => 'module',
          'php' => 1,
        ],
        [
          'core_version_requirement' => '>= 8',
          'type' => 'module',
          'php' => 1000000000,
        ],
        'The following module is installed, but it is incompatible with PHP ' . phpversion() . ":",
      ],
      'theme: php requirement' => [
        [
          'core_version_requirement' => '>= 8',
          'type' => 'theme',
          'php' => 1,
        ],
        [
          'core_version_requirement' => '>= 8',
          'type' => 'theme',
          'php' => 1000000000,
        ],
|| empty($token)
    || !isset($_GET['token'])
    || empty($_GET['token'])
    || $token != $_GET['token']
) {
    header('HTTP/1.1 403 Forbidden');
    echo 'Forbidden';
    exit;
}

$result = [
    'phpversion' => phpversion(),
];

echo json_encode($result, JSON_PRETTY_PRINT);
Home | Imprint | This part of the site doesn't use cookies.