Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
<?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 $path;
/**
* @param string $path
*/
public function __construct($path)
{
$this->path = $path;
$this->getUrl();
}
/**
* @param string $remote
* @param string $targetDir
*
* @return GitRepository
*/
public static function download($remote, $targetDir)
{
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()
{
return $this->path;
}
public function getUrl()
{
return $this->getLastLine($this->execInPath('git config --get remote.origin.url'));
}
public function getLastCommitHash()
{
return $this->getLastLine($this->execInPath('git log -1 --format="%H"'));
}
public function getLastAuthor()
{
return $this->getLastLine($this->execInPath('git log -1 --format="%an"'));
}
public function getLastAuthoredDate()
{
return new \DateTime($this->getLastLine($this->execInPath('git log -1 --format="%ai"')));
}
public function getLastTag(callable $filter = null)
{
$tags = $this->execInPath('git tag -l --sort=v:refname');
if (null !== $filter) {
$tags = array_filter($tags, $filter);
}
return $this->getLastLine($tags);
}
public function checkout($branch)
{
$this->execInPath(sprintf('git checkout %s', escapeshellarg($branch)));
}
private function execInPath($command)
{
return self::exec(sprintf('cd %s && %s', escapeshellarg($this->path), $command));
}
private static function exec($command, $customErrorMessage = null)
{
exec(sprintf('%s 2>&1', $command), $output, $result);
if (0 !== $result) {
throw new RuntimeException(null !== $customErrorMessage ? $customErrorMessage : sprintf('The `%s` command failed.', $command));
}
return $output;
}
private function getLastLine(array $output)
{
return array_pop($output);
}
}

107
vendor/symfony/intl/Util/IcuVersion.php vendored Normal file
View File

@@ -0,0 +1,107 @@
<?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 string $version1 A version string
* @param string $version2 A version string to compare
* @param string $operator The comparison operator
* @param int|null $precision The number of components to compare. Pass
* NULL to compare the versions unchanged.
*
* @return bool Whether the comparison succeeded
*
* @see normalize()
*/
public static function compare($version1, $version2, $operator, $precision = null)
{
$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 string $version An ICU version string
* @param int|null $precision The number of components to include. Pass
* NULL to return the version unchanged.
*
* @return string|null the normalized ICU version or NULL if it couldn't be
* normalized
*/
public static function normalize($version, $precision)
{
$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()
{
}
}

View File

@@ -0,0 +1,110 @@
<?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.
*/
public static function requireIntl(TestCase $testCase, $minimumIcuVersion = null)
{
if (null === $minimumIcuVersion) {
$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 || \defined('HHVM_VERSION_ID')) && 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.
*/
public static function requireFullIntl(TestCase $testCase, $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.
*/
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.
*/
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()
{
}
}

98
vendor/symfony/intl/Util/Version.php vendored Normal file
View 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 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 string $version1 A version string
* @param string $version2 A version string to compare
* @param string $operator The comparison operator
* @param int|null $precision The number of components to compare. Pass
* NULL to compare the versions unchanged.
*
* @return bool Whether the comparison succeeded
*
* @see normalize()
*/
public static function compare($version1, $version2, $operator, $precision = null)
{
$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 string $version A version string
* @param int|null $precision The number of components to include. Pass
* NULL to return the version unchanged.
*
* @return string|null the normalized version or NULL if it couldn't be
* normalized
*/
public static function normalize($version, $precision)
{
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()
{
}
}