mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 00:12:29 +02:00
Updated Rector to commit e007104cf6348db447120feeb76a1b1e7b889b44
e007104cf6
[DX] Enable polyfill rules on withPhpSets() config (#5981)
This commit is contained in:
parent
48397d3f81
commit
fdbe0039e0
17
config/set/php-polyfills.php
Normal file
17
config/set/php-polyfills.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202406;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php73\Rector\BooleanOr\IsCountableRector;
|
||||
use Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector;
|
||||
use Rector\Php80\Rector\Identical\StrEndsWithRector;
|
||||
use Rector\Php80\Rector\Identical\StrStartsWithRector;
|
||||
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
|
||||
use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
|
||||
// these rules can be used ahead of PHP version,
|
||||
// as long composer.json includes particular symfony/php-polyfill package
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([ArrayKeyFirstLastRector::class, IsCountableRector::class, GetDebugTypeRector::class, StrStartsWithRector::class, StrEndsWithRector::class, StrContainsRector::class]);
|
||||
};
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'a787d4c8f6b15ba3590e91746326241efeec8656';
|
||||
public const PACKAGE_VERSION = 'e007104cf6348db447120feeb76a1b1e7b889b44';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-06-19 17:37:29';
|
||||
public const RELEASE_DATE = '2024-06-20 04:49:36';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -381,6 +381,8 @@ final class RectorConfigBuilder
|
||||
} elseif ($php84) {
|
||||
$this->sets[] = LevelSetList::UP_TO_PHP_84;
|
||||
}
|
||||
// make use of polyfill packages in composer.json
|
||||
$this->sets[] = SetList::PHP_POLYFILLS;
|
||||
return $this;
|
||||
}
|
||||
public function withPreparedSets(
|
||||
|
@ -9,6 +9,10 @@ use Rector\Set\Contract\SetListInterface;
|
||||
*/
|
||||
final class SetList implements SetListInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PHP_POLYFILLS = __DIR__ . '/../../../config/set/php-polyfills.php';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
14
vendor/composer/installed.json
vendored
14
vendor/composer/installed.json
vendored
@ -2307,17 +2307,17 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony\/polyfill-mbstring",
|
||||
"version": "v1.29.0",
|
||||
"version_normalized": "1.29.0.0",
|
||||
"version": "v1.30.0",
|
||||
"version_normalized": "1.30.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symfony\/polyfill-mbstring.git",
|
||||
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
|
||||
"reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-mbstring\/zipball\/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
|
||||
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/polyfill-mbstring\/zipball\/fd22ab50000ef01661e2a31d850ebaa297f8e03c",
|
||||
"reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2329,7 +2329,7 @@
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"time": "2024-01-29T20:11:03+00:00",
|
||||
"time": "2024-06-19T12:30:46+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
@ -2370,7 +2370,7 @@
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https:\/\/github.com\/symfony\/polyfill-mbstring\/tree\/v1.29.0"
|
||||
"source": "https:\/\/github.com\/symfony\/polyfill-mbstring\/tree\/v1.30.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
2
vendor/scoper-autoload.php
vendored
2
vendor/scoper-autoload.php
vendored
@ -55,6 +55,7 @@ if (!function_exists('mb_http_input')) { function mb_http_input() { return \Rect
|
||||
if (!function_exists('mb_http_output')) { function mb_http_output() { return \RectorPrefix202406\mb_http_output(...func_get_args()); } }
|
||||
if (!function_exists('mb_internal_encoding')) { function mb_internal_encoding() { return \RectorPrefix202406\mb_internal_encoding(...func_get_args()); } }
|
||||
if (!function_exists('mb_language')) { function mb_language() { return \RectorPrefix202406\mb_language(...func_get_args()); } }
|
||||
if (!function_exists('mb_lcfirst')) { function mb_lcfirst() { return \RectorPrefix202406\mb_lcfirst(...func_get_args()); } }
|
||||
if (!function_exists('mb_list_encodings')) { function mb_list_encodings() { return \RectorPrefix202406\mb_list_encodings(...func_get_args()); } }
|
||||
if (!function_exists('mb_ord')) { function mb_ord() { return \RectorPrefix202406\mb_ord(...func_get_args()); } }
|
||||
if (!function_exists('mb_output_handler')) { function mb_output_handler() { return \RectorPrefix202406\mb_output_handler(...func_get_args()); } }
|
||||
@ -77,6 +78,7 @@ if (!function_exists('mb_strwidth')) { function mb_strwidth() { return \RectorPr
|
||||
if (!function_exists('mb_substitute_character')) { function mb_substitute_character() { return \RectorPrefix202406\mb_substitute_character(...func_get_args()); } }
|
||||
if (!function_exists('mb_substr')) { function mb_substr() { return \RectorPrefix202406\mb_substr(...func_get_args()); } }
|
||||
if (!function_exists('mb_substr_count')) { function mb_substr_count() { return \RectorPrefix202406\mb_substr_count(...func_get_args()); } }
|
||||
if (!function_exists('mb_ucfirst')) { function mb_ucfirst() { return \RectorPrefix202406\mb_ucfirst(...func_get_args()); } }
|
||||
if (!function_exists('parseArgs')) { function parseArgs() { return \RectorPrefix202406\parseArgs(...func_get_args()); } }
|
||||
if (!function_exists('print_node')) { function print_node() { return \RectorPrefix202406\print_node(...func_get_args()); } }
|
||||
if (!function_exists('showHelp')) { function showHelp() { return \RectorPrefix202406\showHelp(...func_get_args()); } }
|
||||
|
60
vendor/symfony/polyfill-mbstring/Mbstring.php
vendored
60
vendor/symfony/polyfill-mbstring/Mbstring.php
vendored
@ -47,6 +47,8 @@ namespace Symfony\Polyfill\Mbstring;
|
||||
* - mb_strstr - Finds first occurrence of a string within another
|
||||
* - mb_strwidth - Return width of string
|
||||
* - mb_substr_count - Count the number of substring occurrences
|
||||
* - mb_ucfirst - Make a string's first character uppercase
|
||||
* - mb_lcfirst - Make a string's first character lowercase
|
||||
*
|
||||
* Not implemented:
|
||||
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
|
||||
@ -73,6 +75,17 @@ final class Mbstring
|
||||
private static $internalEncoding = 'UTF-8';
|
||||
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
|
||||
{
|
||||
if (\is_array($s)) {
|
||||
if (\PHP_VERSION_ID < 70200) {
|
||||
\trigger_error('mb_convert_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
$r = [];
|
||||
foreach ($s as $str) {
|
||||
$r[] = self::mb_convert_encoding($str, $toEncoding, $fromEncoding);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
if (\is_array($fromEncoding) || null !== $fromEncoding && \false !== \strpos($fromEncoding, ',')) {
|
||||
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
|
||||
} else {
|
||||
@ -656,22 +669,15 @@ final class Mbstring
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null) : string
|
||||
public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null) : string
|
||||
{
|
||||
if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], \true)) {
|
||||
throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
|
||||
}
|
||||
if (null === $encoding) {
|
||||
$encoding = self::mb_internal_encoding();
|
||||
}
|
||||
try {
|
||||
$validEncoding = @self::mb_check_encoding('', $encoding);
|
||||
} catch (\ValueError $e) {
|
||||
throw new \ValueError(\sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
|
||||
}
|
||||
// BC for PHP 7.3 and lower
|
||||
if (!$validEncoding) {
|
||||
throw new \ValueError(\sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
|
||||
} else {
|
||||
self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given');
|
||||
}
|
||||
if (self::mb_strlen($pad_string, $encoding) <= 0) {
|
||||
throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
|
||||
@ -691,6 +697,28 @@ final class Mbstring
|
||||
return self::mb_substr(\str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding) . $string . self::mb_substr(\str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
|
||||
}
|
||||
}
|
||||
public static function mb_ucfirst(string $string, ?string $encoding = null) : string
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::mb_internal_encoding();
|
||||
} else {
|
||||
self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
|
||||
}
|
||||
$firstChar = \mb_substr($string, 0, 1, $encoding);
|
||||
$firstChar = \mb_convert_case($firstChar, \MB_CASE_TITLE, $encoding);
|
||||
return $firstChar . \mb_substr($string, 1, null, $encoding);
|
||||
}
|
||||
public static function mb_lcfirst(string $string, ?string $encoding = null) : string
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::mb_internal_encoding();
|
||||
} else {
|
||||
self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
|
||||
}
|
||||
$firstChar = \mb_substr($string, 0, 1, $encoding);
|
||||
$firstChar = \mb_convert_case($firstChar, \MB_CASE_LOWER, $encoding);
|
||||
return $firstChar . \mb_substr($string, 1, null, $encoding);
|
||||
}
|
||||
private static function getSubpart($pos, $part, $haystack, $encoding)
|
||||
{
|
||||
if (\false === $pos) {
|
||||
@ -750,4 +778,16 @@ final class Mbstring
|
||||
}
|
||||
return $encoding;
|
||||
}
|
||||
private static function assertEncoding(string $encoding, string $errorFormat) : void
|
||||
{
|
||||
try {
|
||||
$validEncoding = @self::mb_check_encoding('', $encoding);
|
||||
} catch (\ValueError $e) {
|
||||
throw new \ValueError(\sprintf($errorFormat, $encoding));
|
||||
}
|
||||
// BC for PHP 7.3 and lower
|
||||
if (!$validEncoding) {
|
||||
throw new \ValueError(\sprintf($errorFormat, $encoding));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,14 @@ if (!function_exists('mb_str_pad')) {
|
||||
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_ucfirst')) {
|
||||
function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_lcfirst')) {
|
||||
function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); }
|
||||
}
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
return;
|
||||
}
|
||||
|
@ -203,6 +203,14 @@ if (!function_exists('mb_str_pad')) {
|
||||
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_ucfirst')) {
|
||||
function mb_ucfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_lcfirst')) {
|
||||
function mb_lcfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); }
|
||||
}
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user