mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit babf1be7dba2b451790b18fc58eadd9fc4101e52
babf1be7db
mask
This commit is contained in:
parent
8fe6be7927
commit
8e7b067fa3
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '5db4ed9285348a3e88e68b535c841aef62e2b429';
|
||||
public const PACKAGE_VERSION = 'babf1be7dba2b451790b18fc58eadd9fc4101e52';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-02-22 21:38:42';
|
||||
public const RELEASE_DATE = '2022-02-22 21:38:56';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220222\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0::getLoader();
|
||||
return ComposerAutoloaderInit54b93249be1419561b6fe0914037f943::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1085,6 +1085,7 @@ return array(
|
||||
'RectorPrefix20220222\\Symfony\\Component\\Process\\ProcessUtils' => $vendorDir . '/symfony/process/ProcessUtils.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\AbstractString' => $vendorDir . '/symfony/string/AbstractString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\AbstractUnicodeString' => $vendorDir . '/symfony/string/AbstractUnicodeString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\ByteString' => $vendorDir . '/symfony/string/ByteString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\CodePointString' => $vendorDir . '/symfony/string/CodePointString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/string/Exception/ExceptionInterface.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\Exception\\InvalidArgumentException' => $vendorDir . '/symfony/string/Exception/InvalidArgumentException.php',
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0
|
||||
class ComposerAutoloaderInit54b93249be1419561b6fe0914037f943
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit54b93249be1419561b6fe0914037f943', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit54b93249be1419561b6fe0914037f943', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit4a051b40663d476c18387166d527ecf0::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit54b93249be1419561b6fe0914037f943::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit4a051b40663d476c18387166d527ecf0::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit54b93249be1419561b6fe0914037f943::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire4a051b40663d476c18387166d527ecf0($fileIdentifier, $file);
|
||||
composerRequire54b93249be1419561b6fe0914037f943($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire4a051b40663d476c18387166d527ecf0($fileIdentifier, $file)
|
||||
function composerRequire54b93249be1419561b6fe0914037f943($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit4a051b40663d476c18387166d527ecf0
|
||||
class ComposerStaticInit54b93249be1419561b6fe0914037f943
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@ -1459,6 +1459,7 @@ class ComposerStaticInit4a051b40663d476c18387166d527ecf0
|
||||
'RectorPrefix20220222\\Symfony\\Component\\Process\\ProcessUtils' => __DIR__ . '/..' . '/symfony/process/ProcessUtils.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\AbstractString' => __DIR__ . '/..' . '/symfony/string/AbstractString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\AbstractUnicodeString' => __DIR__ . '/..' . '/symfony/string/AbstractUnicodeString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\ByteString' => __DIR__ . '/..' . '/symfony/string/ByteString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\CodePointString' => __DIR__ . '/..' . '/symfony/string/CodePointString.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/string/Exception/ExceptionInterface.php',
|
||||
'RectorPrefix20220222\\Symfony\\Component\\String\\Exception\\InvalidArgumentException' => __DIR__ . '/..' . '/symfony/string/Exception/InvalidArgumentException.php',
|
||||
@ -3847,9 +3848,9 @@ class ComposerStaticInit4a051b40663d476c18387166d527ecf0
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4a051b40663d476c18387166d527ecf0::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4a051b40663d476c18387166d527ecf0::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4a051b40663d476c18387166d527ecf0::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit54b93249be1419561b6fe0914037f943::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit54b93249be1419561b6fe0914037f943::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit54b93249be1419561b6fe0914037f943::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20220222\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0', false) && !interface_exists('ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0', false) && !trait_exists('ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0', false)) {
|
||||
spl_autoload_call('RectorPrefix20220222\ComposerAutoloaderInit4a051b40663d476c18387166d527ecf0');
|
||||
if (!class_exists('ComposerAutoloaderInit54b93249be1419561b6fe0914037f943', false) && !interface_exists('ComposerAutoloaderInit54b93249be1419561b6fe0914037f943', false) && !trait_exists('ComposerAutoloaderInit54b93249be1419561b6fe0914037f943', false)) {
|
||||
spl_autoload_call('RectorPrefix20220222\ComposerAutoloaderInit54b93249be1419561b6fe0914037f943');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220222\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220222\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire4a051b40663d476c18387166d527ecf0')) {
|
||||
function composerRequire4a051b40663d476c18387166d527ecf0() {
|
||||
return \RectorPrefix20220222\composerRequire4a051b40663d476c18387166d527ecf0(...func_get_args());
|
||||
if (!function_exists('composerRequire54b93249be1419561b6fe0914037f943')) {
|
||||
function composerRequire54b93249be1419561b6fe0914037f943() {
|
||||
return \RectorPrefix20220222\composerRequire54b93249be1419561b6fe0914037f943(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
315
vendor/symfony/string/ByteString.php
vendored
315
vendor/symfony/string/ByteString.php
vendored
@ -8,13 +8,11 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace RectorPrefix20220222\Symfony\Component\String;
|
||||
|
||||
namespace Symfony\Component\String;
|
||||
|
||||
use Symfony\Component\String\Exception\ExceptionInterface;
|
||||
use Symfony\Component\String\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\String\Exception\RuntimeException;
|
||||
|
||||
use RectorPrefix20220222\Symfony\Component\String\Exception\ExceptionInterface;
|
||||
use RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException;
|
||||
use RectorPrefix20220222\Symfony\Component\String\Exception\RuntimeException;
|
||||
/**
|
||||
* Represents a binary-safe string of bytes.
|
||||
*
|
||||
@ -23,15 +21,13 @@ use Symfony\Component\String\Exception\RuntimeException;
|
||||
*
|
||||
* @throws ExceptionInterface
|
||||
*/
|
||||
class ByteString extends AbstractString
|
||||
class ByteString extends \RectorPrefix20220222\Symfony\Component\String\AbstractString
|
||||
{
|
||||
private const ALPHABET_ALPHANUMERIC = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
|
||||
public function __construct(string $string = '')
|
||||
{
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following method was derived from code of the Hack Standard Library (v4.40 - 2020-05-03)
|
||||
*
|
||||
@ -41,35 +37,31 @@ class ByteString extends AbstractString
|
||||
*
|
||||
* Copyright (c) 2004-2020, Facebook, Inc. (https://www.facebook.com/)
|
||||
*/
|
||||
|
||||
public static function fromRandom(int $length = 16, string $alphabet = null): self
|
||||
public static function fromRandom(int $length = 16, string $alphabet = null) : self
|
||||
{
|
||||
if ($length <= 0) {
|
||||
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException(\sprintf('A strictly positive length is expected, "%d" given.', $length));
|
||||
}
|
||||
|
||||
$alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
|
||||
$alphabetSize = \strlen($alphabet);
|
||||
$bits = (int) ceil(log($alphabetSize, 2.0));
|
||||
$bits = (int) \ceil(\log($alphabetSize, 2.0));
|
||||
if ($bits <= 0 || $bits > 56) {
|
||||
throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
|
||||
}
|
||||
|
||||
$ret = '';
|
||||
while ($length > 0) {
|
||||
$urandomLength = (int) ceil(2 * $length * $bits / 8.0);
|
||||
$data = random_bytes($urandomLength);
|
||||
$urandomLength = (int) \ceil(2 * $length * $bits / 8.0);
|
||||
$data = \random_bytes($urandomLength);
|
||||
$unpackedData = 0;
|
||||
$unpackedBits = 0;
|
||||
for ($i = 0; $i < $urandomLength && $length > 0; ++$i) {
|
||||
// Unpack 8 bits
|
||||
$unpackedData = ($unpackedData << 8) | \ord($data[$i]);
|
||||
$unpackedData = $unpackedData << 8 | \ord($data[$i]);
|
||||
$unpackedBits += 8;
|
||||
|
||||
// While we have enough bits to select a character from the alphabet, keep
|
||||
// consuming the random data
|
||||
for (; $unpackedBits >= $bits && $length > 0; $unpackedBits -= $bits) {
|
||||
$index = ($unpackedData & ((1 << $bits) - 1));
|
||||
$index = $unpackedData & (1 << $bits) - 1;
|
||||
$unpackedData >>= $bits;
|
||||
// Unfortunately, the alphabet size is not necessarily a power of two.
|
||||
// Worst case, it is 2^k + 1, which means we need (k+1) bits and we
|
||||
@ -81,269 +73,218 @@ class ByteString extends AbstractString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new static($ret);
|
||||
}
|
||||
|
||||
public function bytesAt(int $offset): array
|
||||
public function bytesAt(int $offset) : array
|
||||
{
|
||||
$str = $this->string[$offset] ?? '';
|
||||
|
||||
return '' === $str ? [] : [\ord($str)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function append(string ...$suffix)
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
|
||||
|
||||
$str->string .= 1 >= \count($suffix) ? $suffix[0] ?? '' : \implode('', $suffix);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function camel()
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
|
||||
|
||||
$str->string = \lcfirst(\str_replace(' ', '', \ucwords(\preg_replace('/[^a-zA-Z0-9\\x7f-\\xff]++/', ' ', $this->string))));
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function chunk(int $length = 1): array
|
||||
public function chunk(int $length = 1) : array
|
||||
{
|
||||
if (1 > $length) {
|
||||
throw new InvalidArgumentException('The chunk length must be greater than zero.');
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException('The chunk length must be greater than zero.');
|
||||
}
|
||||
|
||||
if ('' === $this->string) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$str = clone $this;
|
||||
$chunks = [];
|
||||
|
||||
foreach (str_split($this->string, $length) as $chunk) {
|
||||
foreach (\str_split($this->string, $length) as $chunk) {
|
||||
$str->string = $chunk;
|
||||
$chunks[] = clone $str;
|
||||
}
|
||||
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[]|string|\Symfony\Component\String\AbstractString $suffix
|
||||
*/
|
||||
public function endsWith($suffix): bool
|
||||
public function endsWith($suffix) : bool
|
||||
{
|
||||
if ($suffix instanceof AbstractString) {
|
||||
if ($suffix instanceof \RectorPrefix20220222\Symfony\Component\String\AbstractString) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (!\is_string($suffix)) {
|
||||
return parent::endsWith($suffix);
|
||||
}
|
||||
|
||||
return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
|
||||
return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === \substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[]|string|\Symfony\Component\String\AbstractString $string
|
||||
*/
|
||||
public function equalsTo($string): bool
|
||||
public function equalsTo($string) : bool
|
||||
{
|
||||
if ($string instanceof AbstractString) {
|
||||
if ($string instanceof \RectorPrefix20220222\Symfony\Component\String\AbstractString) {
|
||||
$string = $string->string;
|
||||
} elseif (!\is_string($string)) {
|
||||
return parent::equalsTo($string);
|
||||
}
|
||||
|
||||
if ('' !== $string && $this->ignoreCase) {
|
||||
return 0 === strcasecmp($string, $this->string);
|
||||
return 0 === \strcasecmp($string, $this->string);
|
||||
}
|
||||
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function folded()
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtolower($str->string);
|
||||
|
||||
$str->string = \strtolower($str->string);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[]|string|\Symfony\Component\String\AbstractString $needle
|
||||
*/
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
public function indexOf($needle, int $offset = 0) : ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
if ($needle instanceof \RectorPrefix20220222\Symfony\Component\String\AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$i = $this->ignoreCase ? stripos($this->string, $needle, $offset) : strpos($this->string, $needle, $offset);
|
||||
|
||||
return false === $i ? null : $i;
|
||||
$i = $this->ignoreCase ? \stripos($this->string, $needle, $offset) : \strpos($this->string, $needle, $offset);
|
||||
return \false === $i ? null : $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[]|string|\Symfony\Component\String\AbstractString $needle
|
||||
*/
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
public function indexOfLast($needle, int $offset = 0) : ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
if ($needle instanceof \RectorPrefix20220222\Symfony\Component\String\AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$i = $this->ignoreCase ? strripos($this->string, $needle, $offset) : strrpos($this->string, $needle, $offset);
|
||||
|
||||
return false === $i ? null : $i;
|
||||
$i = $this->ignoreCase ? \strripos($this->string, $needle, $offset) : \strrpos($this->string, $needle, $offset);
|
||||
return \false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function isUtf8(): bool
|
||||
public function isUtf8() : bool
|
||||
{
|
||||
return '' === $this->string || preg_match('//u', $this->string);
|
||||
return '' === $this->string || \preg_match('//u', $this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function join(array $strings, string $lastGlue = null)
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
$tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
|
||||
$str->string = implode($this->string, $strings).$tail;
|
||||
|
||||
$tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . \array_pop($strings) : '';
|
||||
$str->string = \implode($this->string, $strings) . $tail;
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function length(): int
|
||||
public function length() : int
|
||||
{
|
||||
return \strlen($this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function lower()
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtolower($str->string);
|
||||
|
||||
$str->string = \strtolower($str->string);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function match(string $regexp, int $flags = 0, int $offset = 0): array
|
||||
public function match(string $regexp, int $flags = 0, int $offset = 0) : array
|
||||
{
|
||||
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
|
||||
|
||||
$match = (\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags ? 'preg_match_all' : 'preg_match';
|
||||
if ($this->ignoreCase) {
|
||||
$regexp .= 'i';
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
|
||||
\set_error_handler(static function ($t, $m) {
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException($m);
|
||||
});
|
||||
try {
|
||||
if (false === $match($regexp, $this->string, $matches, $flags, $offset)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
if (\false === $match($regexp, $this->string, $matches, $flags, $offset)) {
|
||||
$lastError = \preg_last_error();
|
||||
foreach (\get_defined_constants(\true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === \substr($k, -6)) {
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\RuntimeException('Matching failed with ' . $k . '.');
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException('Matching failed with unknown error code.');
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\RuntimeException('Matching failed with unknown error code.');
|
||||
}
|
||||
array_walk_recursive($matches, function (&$value) {
|
||||
\array_walk_recursive($matches, function (&$value) {
|
||||
if ($value === '') {
|
||||
$value = null;
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
\restore_error_handler();
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function padBoth(int $length, string $padStr = ' ')
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
|
||||
|
||||
$str->string = \str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function padEnd(int $length, string $padStr = ' ')
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
|
||||
|
||||
$str->string = \str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function padStart(int $length, string $padStr = ' ')
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
|
||||
|
||||
$str->string = \str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function prepend(string ...$prefix)
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
|
||||
|
||||
$str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : \implode('', $prefix)) . $str->string;
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function replace(string $from, string $to)
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
if ('' !== $from) {
|
||||
$str->string = $this->ignoreCase ? str_ireplace($from, $to, $this->string) : str_replace($from, $to, $this->string);
|
||||
$str->string = $this->ignoreCase ? \str_ireplace($from, $to, $this->string) : \str_replace($from, $to, $this->string);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable|string $to
|
||||
* @return $this
|
||||
@ -353,219 +294,175 @@ class ByteString extends AbstractString
|
||||
if ($this->ignoreCase) {
|
||||
$fromRegexp .= 'i';
|
||||
}
|
||||
|
||||
$replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
|
||||
\set_error_handler(static function ($t, $m) {
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException($m);
|
||||
});
|
||||
try {
|
||||
if (null === $string = $replace($fromRegexp, $to, $this->string)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
if (null === ($string = $replace($fromRegexp, $to, $this->string))) {
|
||||
$lastError = \preg_last_error();
|
||||
foreach (\get_defined_constants(\true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === \substr($k, -6)) {
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\RuntimeException('Matching failed with ' . $k . '.');
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException('Matching failed with unknown error code.');
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\RuntimeException('Matching failed with unknown error code.');
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
\restore_error_handler();
|
||||
}
|
||||
|
||||
$str = clone $this;
|
||||
$str->string = $string;
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function reverse()
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strrev($str->string);
|
||||
|
||||
$str->string = \strrev($str->string);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function slice(int $start = 0, int $length = null)
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
|
||||
|
||||
$str->string = (string) \substr($this->string, $start, $length ?? \PHP_INT_MAX);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function snake()
|
||||
{
|
||||
$str = $this->camel()->title();
|
||||
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
|
||||
|
||||
$str->string = \strtolower(\preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\\d])([A-Z])/'], 'RectorPrefix20220222\\1_\\2', $str->string));
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function splice(string $replacement, int $start = 0, int $length = null)
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
|
||||
|
||||
$str->string = \substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null) : array
|
||||
{
|
||||
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
if (1 > ($limit = $limit ?? \PHP_INT_MAX)) {
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
if ('' === $delimiter) {
|
||||
throw new InvalidArgumentException('Split delimiter is empty.');
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException('Split delimiter is empty.');
|
||||
}
|
||||
|
||||
if (null !== $flags) {
|
||||
return parent::split($delimiter, $limit, $flags);
|
||||
}
|
||||
|
||||
$str = clone $this;
|
||||
$chunks = $this->ignoreCase
|
||||
? preg_split('{'.preg_quote($delimiter).'}iD', $this->string, $limit)
|
||||
: explode($delimiter, $this->string, $limit);
|
||||
|
||||
$chunks = $this->ignoreCase ? \preg_split('{' . \preg_quote($delimiter) . '}iD', $this->string, $limit) : \explode($delimiter, $this->string, $limit);
|
||||
foreach ($chunks as &$chunk) {
|
||||
$str->string = $chunk;
|
||||
$chunk = clone $str;
|
||||
}
|
||||
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[]|string|\Symfony\Component\String\AbstractString $prefix
|
||||
*/
|
||||
public function startsWith($prefix): bool
|
||||
public function startsWith($prefix) : bool
|
||||
{
|
||||
if ($prefix instanceof AbstractString) {
|
||||
if ($prefix instanceof \RectorPrefix20220222\Symfony\Component\String\AbstractString) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (!\is_string($prefix)) {
|
||||
return parent::startsWith($prefix);
|
||||
}
|
||||
|
||||
return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
|
||||
return '' !== $prefix && 0 === ($this->ignoreCase ? \strncasecmp($this->string, $prefix, \strlen($prefix)) : \strncmp($this->string, $prefix, \strlen($prefix)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function title(bool $allWords = false)
|
||||
public function title(bool $allWords = \false)
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
|
||||
|
||||
$str->string = $allWords ? \ucwords($str->string) : \ucfirst($str->string);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function toUnicodeString(string $fromEncoding = null): UnicodeString
|
||||
public function toUnicodeString(string $fromEncoding = null) : \RectorPrefix20220222\Symfony\Component\String\UnicodeString
|
||||
{
|
||||
return new UnicodeString($this->toCodePointString($fromEncoding)->string);
|
||||
return new \RectorPrefix20220222\Symfony\Component\String\UnicodeString($this->toCodePointString($fromEncoding)->string);
|
||||
}
|
||||
|
||||
public function toCodePointString(string $fromEncoding = null): CodePointString
|
||||
public function toCodePointString(string $fromEncoding = null) : \RectorPrefix20220222\Symfony\Component\String\CodePointString
|
||||
{
|
||||
$u = new CodePointString();
|
||||
|
||||
if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], true) && preg_match('//u', $this->string)) {
|
||||
$u = new \RectorPrefix20220222\Symfony\Component\String\CodePointString();
|
||||
if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], \true) && \preg_match('//u', $this->string)) {
|
||||
$u->string = $this->string;
|
||||
|
||||
return $u;
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
|
||||
\set_error_handler(static function ($t, $m) {
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException($m);
|
||||
});
|
||||
try {
|
||||
try {
|
||||
$validEncoding = false !== mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', true);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$validEncoding = \false !== \mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', \true);
|
||||
} catch (\RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException $e) {
|
||||
if (!\function_exists('iconv')) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$u->string = iconv($fromEncoding ?? 'Windows-1252', 'UTF-8', $this->string);
|
||||
|
||||
$u->string = \iconv($fromEncoding ?? 'Windows-1252', 'UTF-8', $this->string);
|
||||
return $u;
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
\restore_error_handler();
|
||||
}
|
||||
|
||||
if (!$validEncoding) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
|
||||
throw new \RectorPrefix20220222\Symfony\Component\String\Exception\InvalidArgumentException(\sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
|
||||
}
|
||||
|
||||
$u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');
|
||||
|
||||
$u->string = \mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');
|
||||
return $u;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C")
|
||||
public function trim(string $chars = " \t\n\r\0\v\f")
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = trim($str->string, $chars);
|
||||
|
||||
$str->string = \trim($str->string, $chars);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C")
|
||||
public function trimEnd(string $chars = " \t\n\r\0\v\f")
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = rtrim($str->string, $chars);
|
||||
|
||||
$str->string = \rtrim($str->string, $chars);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C")
|
||||
public function trimStart(string $chars = " \t\n\r\0\v\f")
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = ltrim($str->string, $chars);
|
||||
|
||||
$str->string = \ltrim($str->string, $chars);
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function upper()
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtoupper($str->string);
|
||||
|
||||
$str->string = \strtoupper($str->string);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function width(bool $ignoreAnsiDecoration = true): int
|
||||
public function width(bool $ignoreAnsiDecoration = \true) : int
|
||||
{
|
||||
$string = preg_match('//u', $this->string) ? $this->string : preg_replace('/[\x80-\xFF]/', '?', $this->string);
|
||||
|
||||
return (new CodePointString($string))->width($ignoreAnsiDecoration);
|
||||
$string = \preg_match('//u', $this->string) ? $this->string : \preg_replace('/[\\x80-\\xFF]/', '?', $this->string);
|
||||
return (new \RectorPrefix20220222\Symfony\Component\String\CodePointString($string))->width($ignoreAnsiDecoration);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user