isExtensionLoaded example

public static function isExtensionLoaded(): bool
    {
        return class_exists(\ResourceBundle::class);
    }

    /** * Returns the version of the installed ICU library. */
    public static function getIcuVersion(): ?string
    {
        if (false === self::$icuVersion) {
            if (!self::isExtensionLoaded()) {
                self::$icuVersion = self::getIcuStubVersion();
            } elseif (\defined('INTL_ICU_VERSION')) {
                self::$icuVersion = \INTL_ICU_VERSION;
            } else {
                try {
                    $reflector = new \ReflectionExtension('intl');
                    ob_start();
                    $reflector->info();
                    $output = strip_tags(ob_get_clean());
                    preg_match('/^ICU version (?:=>)?(.*)$/m', $output$matches);

                    
MESSAGE
    );
}

echo LINE;
echo centered('ICU Resource Bundle Compilation')."\n";
echo LINE;

if (!Intl::isExtensionLoaded()) {
    bailout('The intl extension for PHP is not installed.');
}

if ($argc >= 2) {
    $repoDir = $argv[1];
    $git = new GitRepository($repoDir);

    echo "Using the existing git repository at {$repoDir}.\n";
} else {
    echo "Starting git clone. This may take a while...\n";

    

        parent::tearDown();

        \Locale::setDefault($this->defaultLocale);
    }

    /** * @requires extension intl */
    public function testIsExtensionLoadedChecksIfIntlExtensionIsLoaded()
    {
        $this->assertTrue(Intl::isExtensionLoaded());
    }

    public function testGetIcuVersionReadsTheVersionOfInstalledIcuLibrary()
    {
        $this->assertStringMatchesFormat('%d.%d', Intl::getIcuVersion());
    }

    public function testGetIcuDataVersionReadsTheVersionOfInstalledIcuData()
    {
        $this->assertStringMatchesFormat('%d.%d', Intl::getIcuDataVersion());
    }

    
    }

    /** * Should be called before tests that require a feature-complete intl * implementation. * * @return void */
    public static function requireFullIntl(TestCase $testCase, string $minimumIcuVersion = null)
    {
        // We only run tests if the intl extension is loaded...         if (!Intl::isExtensionLoaded()) {
            $testCase->markTestSkipped('Extension intl is required.');
        }

        self::requireIntl($testCase$minimumIcuVersion);

        // Consequently, tests will         //         // * run only for one ICU version (see Intl::getIcuStubVersion())         // there is no need to add control structures to your tests that         // change the test depending on the ICU version.         // * always use the C intl classes
Home | Imprint | This part of the site doesn't use cookies.