first commit
This commit is contained in:
108
plugins/simplesaml/lib/vendor/symfony/intl/Util/GitRepository.php
vendored
Normal file
108
plugins/simplesaml/lib/vendor/symfony/intl/Util/GitRepository.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* 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\Intl\Util;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Intl\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class GitRepository
|
||||
{
|
||||
private string $path;
|
||||
|
||||
public function __construct(string $path)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
$this->getUrl();
|
||||
}
|
||||
|
||||
public static function download(string $remote, string $targetDir): self
|
||||
{
|
||||
self::exec('which git', 'The command "git" is not installed.');
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
if (!$filesystem->exists($targetDir.'/.git')) {
|
||||
$filesystem->remove($targetDir);
|
||||
$filesystem->mkdir($targetDir);
|
||||
|
||||
self::exec(sprintf('git clone %s %s', escapeshellarg($remote), escapeshellarg($targetDir)));
|
||||
}
|
||||
|
||||
return new self(realpath($targetDir));
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->getLastLine($this->execInPath('git config --get remote.origin.url'));
|
||||
}
|
||||
|
||||
public function getLastCommitHash(): string
|
||||
{
|
||||
return $this->getLastLine($this->execInPath('git log -1 --format="%H"'));
|
||||
}
|
||||
|
||||
public function getLastAuthor(): string
|
||||
{
|
||||
return $this->getLastLine($this->execInPath('git log -1 --format="%an"'));
|
||||
}
|
||||
|
||||
public function getLastAuthoredDate(): \DateTimeImmutable
|
||||
{
|
||||
return new \DateTimeImmutable($this->getLastLine($this->execInPath('git log -1 --format="%ai"')));
|
||||
}
|
||||
|
||||
public function getLastTag(?callable $filter = null): string
|
||||
{
|
||||
$tags = $this->execInPath('git tag -l --sort=v:refname');
|
||||
|
||||
if (null !== $filter) {
|
||||
$tags = array_filter($tags, $filter);
|
||||
}
|
||||
|
||||
return $this->getLastLine($tags);
|
||||
}
|
||||
|
||||
public function checkout(string $branch): void
|
||||
{
|
||||
$this->execInPath(sprintf('git checkout %s', escapeshellarg($branch)));
|
||||
}
|
||||
|
||||
private function execInPath(string $command): array
|
||||
{
|
||||
return self::exec(sprintf('cd %s && %s', escapeshellarg($this->path), $command));
|
||||
}
|
||||
|
||||
private static function exec(string $command, ?string $customErrorMessage = null): array
|
||||
{
|
||||
exec(sprintf('%s 2>&1', $command), $output, $result);
|
||||
|
||||
if (0 !== $result) {
|
||||
throw new RuntimeException($customErrorMessage ?? sprintf('The "%s" command failed.', $command));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function getLastLine(array $output): string
|
||||
{
|
||||
return array_pop($output);
|
||||
}
|
||||
}
|
83
plugins/simplesaml/lib/vendor/symfony/intl/Util/GzipStreamWrapper.php
vendored
Normal file
83
plugins/simplesaml/lib/vendor/symfony/intl/Util/GzipStreamWrapper.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* 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\Intl\Util;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class GzipStreamWrapper
|
||||
{
|
||||
/** @var resource|null */
|
||||
public $context;
|
||||
|
||||
/** @var resource */
|
||||
private $handle;
|
||||
private string $path;
|
||||
|
||||
public static function require(string $path): array
|
||||
{
|
||||
if (!\extension_loaded('zlib')) {
|
||||
throw new \LogicException(sprintf('The "zlib" extension is required to load the "%s/%s" map, please enable it in your php.ini file.', basename(\dirname($path)), basename($path)));
|
||||
}
|
||||
|
||||
if (!\function_exists('opcache_is_script_cached') || !@opcache_is_script_cached($path)) {
|
||||
stream_wrapper_unregister('file');
|
||||
stream_wrapper_register('file', self::class);
|
||||
}
|
||||
|
||||
return require $path;
|
||||
}
|
||||
|
||||
public function stream_open(string $path, string $mode): bool
|
||||
{
|
||||
stream_wrapper_restore('file');
|
||||
$this->path = $path;
|
||||
|
||||
return false !== $this->handle = fopen('compress.zlib://'.$path, $mode);
|
||||
}
|
||||
|
||||
public function stream_read(int $count): string|false
|
||||
{
|
||||
return fread($this->handle, $count);
|
||||
}
|
||||
|
||||
public function stream_eof(): bool
|
||||
{
|
||||
return feof($this->handle);
|
||||
}
|
||||
|
||||
public function stream_set_option(int $option, int $arg1, int $arg2): bool
|
||||
{
|
||||
return match ($option) {
|
||||
\STREAM_OPTION_BLOCKING => stream_set_blocking($this->handle, $arg1),
|
||||
\STREAM_OPTION_READ_TIMEOUT => stream_set_timeout($this->handle, $arg1, $arg2),
|
||||
\STREAM_OPTION_WRITE_BUFFER => 0 === stream_set_write_buffer($this->handle, $arg2),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
public function stream_stat(): array|false
|
||||
{
|
||||
if (!$stat = stat($this->path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$h = fopen($this->path, 'r');
|
||||
fseek($h, -4, \SEEK_END);
|
||||
$size = unpack('V', fread($h, 4));
|
||||
fclose($h);
|
||||
|
||||
$stat[7] = $stat['size'] = end($size);
|
||||
|
||||
return $stat;
|
||||
}
|
||||
}
|
98
plugins/simplesaml/lib/vendor/symfony/intl/Util/IcuVersion.php
vendored
Normal file
98
plugins/simplesaml/lib/vendor/symfony/intl/Util/IcuVersion.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* 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\Intl\Util;
|
||||
|
||||
/**
|
||||
* Facilitates the comparison of ICU version strings.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class IcuVersion
|
||||
{
|
||||
/**
|
||||
* Compares two ICU versions with an operator.
|
||||
*
|
||||
* This method is identical to {@link version_compare()}, except that you
|
||||
* can pass the number of regarded version components in the last argument
|
||||
* $precision.
|
||||
*
|
||||
* Also, a single digit release version and a single digit major version
|
||||
* are contracted to a two digit release version. If no major version
|
||||
* is given, it is substituted by zero.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* IcuVersion::compare('1.2.3', '1.2.4', '==')
|
||||
* // => false
|
||||
*
|
||||
* IcuVersion::compare('1.2.3', '1.2.4', '==', 2)
|
||||
* // => true
|
||||
*
|
||||
* IcuVersion::compare('1.2.3', '12.3', '==')
|
||||
* // => true
|
||||
*
|
||||
* IcuVersion::compare('1', '10', '==')
|
||||
* // => true
|
||||
*
|
||||
* @param int|null $precision The number of components to compare. Pass
|
||||
* NULL to compare the versions unchanged.
|
||||
*
|
||||
* @see normalize()
|
||||
*/
|
||||
public static function compare(string $version1, string $version2, string $operator, ?int $precision = null): bool
|
||||
{
|
||||
$version1 = self::normalize($version1, $precision);
|
||||
$version2 = self::normalize($version2, $precision);
|
||||
|
||||
return version_compare($version1, $version2, $operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a version string to the number of components given in the
|
||||
* parameter $precision.
|
||||
*
|
||||
* A single digit release version and a single digit major version are
|
||||
* contracted to a two digit release version. If no major version is given,
|
||||
* it is substituted by zero.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* IcuVersion::normalize('1.2.3.4');
|
||||
* // => '12.3.4'
|
||||
*
|
||||
* IcuVersion::normalize('1.2.3.4', 1);
|
||||
* // => '12'
|
||||
*
|
||||
* IcuVersion::normalize('1.2.3.4', 2);
|
||||
* // => '12.3'
|
||||
*
|
||||
* @param int|null $precision The number of components to include. Pass
|
||||
* NULL to return the version unchanged.
|
||||
*/
|
||||
public static function normalize(string $version, ?int $precision): ?string
|
||||
{
|
||||
$version = preg_replace('/^(\d)\.(\d)/', '$1$2', $version);
|
||||
|
||||
if (1 === \strlen($version)) {
|
||||
$version .= '0';
|
||||
}
|
||||
|
||||
return Version::normalize($version, $precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be instantiated.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
116
plugins/simplesaml/lib/vendor/symfony/intl/Util/IntlTestHelper.php
vendored
Normal file
116
plugins/simplesaml/lib/vendor/symfony/intl/Util/IntlTestHelper.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* 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\Intl\Util;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
|
||||
/**
|
||||
* Helper class for preparing test cases that rely on the Intl component.
|
||||
*
|
||||
* Any test that tests functionality relying on either the intl classes or
|
||||
* the resource bundle data should call either of the methods
|
||||
* {@link requireIntl()} or {@link requireFullIntl()}. Calling
|
||||
* {@link requireFullIntl()} is only necessary if you use functionality in the
|
||||
* test that is not provided by the stub intl implementation.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class IntlTestHelper
|
||||
{
|
||||
/**
|
||||
* Should be called before tests that work fine with the stub implementation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function requireIntl(TestCase $testCase, ?string $minimumIcuVersion = null)
|
||||
{
|
||||
$minimumIcuVersion ??= Intl::getIcuStubVersion();
|
||||
|
||||
// We only run tests if the version is *one specific version*.
|
||||
// This condition is satisfied if
|
||||
//
|
||||
// * the intl extension is loaded with version Intl::getIcuStubVersion()
|
||||
// * the intl extension is not loaded
|
||||
|
||||
if ($minimumIcuVersion && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '<', 1)) {
|
||||
$testCase->markTestSkipped('ICU version '.$minimumIcuVersion.' is required.');
|
||||
}
|
||||
|
||||
// Normalize the default locale in case this is not done explicitly
|
||||
// in the test
|
||||
\Locale::setDefault('en');
|
||||
|
||||
// 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.
|
||||
//
|
||||
// Tests should only rely on functionality that is implemented in the
|
||||
// stub classes.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the test unless the current system has a 32bit architecture.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function require32Bit(TestCase $testCase)
|
||||
{
|
||||
if (4 !== \PHP_INT_SIZE) {
|
||||
$testCase->markTestSkipped('PHP 32 bit is required.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the test unless the current system has a 64bit architecture.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function require64Bit(TestCase $testCase)
|
||||
{
|
||||
if (8 !== \PHP_INT_SIZE) {
|
||||
$testCase->markTestSkipped('PHP 64 bit is required.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be instantiated.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
89
plugins/simplesaml/lib/vendor/symfony/intl/Util/Version.php
vendored
Normal file
89
plugins/simplesaml/lib/vendor/symfony/intl/Util/Version.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* 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\Intl\Util;
|
||||
|
||||
/**
|
||||
* Facilitates the comparison of version strings.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
/**
|
||||
* Compares two versions with an operator.
|
||||
*
|
||||
* This method is identical to {@link version_compare()}, except that you
|
||||
* can pass the number of regarded version components in the last argument
|
||||
* $precision.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* Version::compare('1.2.3', '1.2.4', '==')
|
||||
* // => false
|
||||
*
|
||||
* Version::compare('1.2.3', '1.2.4', '==', 2)
|
||||
* // => true
|
||||
*
|
||||
* @param int|null $precision The number of components to compare. Pass
|
||||
* NULL to compare the versions unchanged.
|
||||
*
|
||||
* @see normalize()
|
||||
*/
|
||||
public static function compare(string $version1, string $version2, string $operator, ?int $precision = null): bool
|
||||
{
|
||||
$version1 = self::normalize($version1, $precision);
|
||||
$version2 = self::normalize($version2, $precision);
|
||||
|
||||
return version_compare($version1, $version2, $operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a version string to the number of components given in the
|
||||
* parameter $precision.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* Version::normalize('1.2.3', 1);
|
||||
* // => '1'
|
||||
*
|
||||
* Version::normalize('1.2.3', 2);
|
||||
* // => '1.2'
|
||||
*
|
||||
* @param int|null $precision The number of components to include. Pass
|
||||
* NULL to return the version unchanged.
|
||||
*/
|
||||
public static function normalize(string $version, ?int $precision): ?string
|
||||
{
|
||||
if (null === $precision) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
$pattern = '[^\.]+';
|
||||
|
||||
for ($i = 2; $i <= $precision; ++$i) {
|
||||
$pattern = sprintf('[^\.]+(\.%s)?', $pattern);
|
||||
}
|
||||
|
||||
if (!preg_match('/^'.$pattern.'/', $version, $matches)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Must not be instantiated.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user