Updated Rector to commit 78a42c7b8a

78a42c7b8a [DowngradePhp73] Add DowngradePhp73JsonConstRector (#1782)
This commit is contained in:
Tomas Votruba 2022-02-08 22:20:53 +00:00
parent 1c13355cf7
commit adcb702c28
11 changed files with 83 additions and 22 deletions

View File

@ -5,6 +5,7 @@ namespace RectorPrefix20220208;
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector;
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector;
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector;
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector;
@ -22,4 +23,5 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class);
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class);
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector::class);
$services->set(\Rector\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector::class);
};

View File

@ -32,7 +32,7 @@ final class DowngradePhp72JsonConstRector extends \Rector\Core\Rector\AbstractRe
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Json constant that available only in php 7.2 to 0', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove Json constant that available only in php 7.2', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
$inDecoder = new Decoder($connection, true, 512, \JSON_INVALID_UTF8_IGNORE);
$inDecoder = new Decoder($connection, true, 512, \JSON_INVALID_UTF8_SUBSTITUTE);
CODE_SAMPLE

View File

@ -0,0 +1,57 @@
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp73\Rector\ConstFetch;
use PhpParser\Node;
use PhpParser\Node\Expr\BinaryOp\BitwiseOr;
use PhpParser\Node\Expr\ConstFetch;
use Rector\Core\Rector\AbstractRector;
use Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://www.php.net/manual/en/function.json-encode.php#refsect1-function.json-encode-changelog
*
* @see \Rector\Tests\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector\DowngradePhp73JsonConstRectorTest
*/
final class DowngradePhp73JsonConstRector extends \Rector\Core\Rector\AbstractRector
{
/**
* @var string[]
*/
private const CONSTANTS = ['JSON_THROW_ON_ERROR'];
/**
* @readonly
* @var \Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner
*/
private $jsonConstCleaner;
public function __construct(\Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner $jsonConstCleaner)
{
$this->jsonConstCleaner = $jsonConstCleaner;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove Json constant that available only in php 7.3', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
json_encode($content, JSON_THROW_ON_ERROR);
CODE_SAMPLE
, <<<'CODE_SAMPLE'
json_encode($content, 0);
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\ConstFetch::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class];
}
/**
* @param ConstFetch|BitwiseOr $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
return $this->jsonConstCleaner->clean($node, self::CONSTANTS);
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'e2bd1841f453150064274d3eedd6fb4db535f5a3';
public const PACKAGE_VERSION = '78a42c7b8a9b3f56365241437c760d076af149b9';
/**
* @var string
*/
public const RELEASE_DATE = '2022-02-08 22:03:29';
public const RELEASE_DATE = '2022-02-09 05:12:41';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20220208\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1f478404d094907764608e16fb7951cf::getLoader();
return ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58::getLoader();

View File

@ -34,7 +34,7 @@ class Decoder extends \RectorPrefix20220208\Evenement\EventEmitter implements \R
throw new \BadMethodCallException('Options parameter is only supported on PHP 5.4+');
}
if (\defined('JSON_THROW_ON_ERROR')) {
$options = $options & ~\JSON_THROW_ON_ERROR;
$options = $options & ~0;
}
// @codeCoverageIgnoreEnd
$this->input = $input;

View File

@ -30,7 +30,7 @@ class Encoder extends \RectorPrefix20220208\Evenement\EventEmitter implements \R
throw new \BadMethodCallException('Depth parameter is only supported on PHP 5.5+');
}
if (\defined('JSON_THROW_ON_ERROR')) {
$options = $options & ~\JSON_THROW_ON_ERROR;
$options = $options & ~0;
}
// @codeCoverageIgnoreEnd
$this->output = $output;

View File

@ -2008,6 +2008,7 @@ return array(
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradePregUnmatchedAsNullConstantRector' => $baseDir . '/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php',
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradeStreamIsattyRector' => $baseDir . '/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php',
'Rector\\DowngradePhp72\\Rector\\FunctionLike\\DowngradeObjectTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php',
'Rector\\DowngradePhp73\\Rector\\ConstFetch\\DowngradePhp73JsonConstRector' => $baseDir . '/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php',
'Rector\\DowngradePhp73\\Rector\\FuncCall\\DowngradeArrayKeyFirstLastRector' => $baseDir . '/rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php',
'Rector\\DowngradePhp73\\Rector\\FuncCall\\DowngradeIsCountableRector' => $baseDir . '/rules/DowngradePhp73/Rector/FuncCall/DowngradeIsCountableRector.php',
'Rector\\DowngradePhp73\\Rector\\FuncCall\\DowngradeTrailingCommasInFunctionCallsRector' => $baseDir . '/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1f478404d094907764608e16fb7951cf
class ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1f478404d094907764608e16fb7951cf
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1f478404d094907764608e16fb7951cf', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit1f478404d094907764608e16fb7951cf', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58', '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\ComposerStaticInit1f478404d094907764608e16fb7951cf::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit3ca87db3aa5231356decdf31415d3a58::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,12 +42,12 @@ class ComposerAutoloaderInit1f478404d094907764608e16fb7951cf
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit1f478404d094907764608e16fb7951cf::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit3ca87db3aa5231356decdf31415d3a58::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1f478404d094907764608e16fb7951cf($fileIdentifier, $file);
composerRequire3ca87db3aa5231356decdf31415d3a58($fileIdentifier, $file);
}
return $loader;
@ -59,7 +59,7 @@ class ComposerAutoloaderInit1f478404d094907764608e16fb7951cf
* @param string $file
* @return void
*/
function composerRequire1f478404d094907764608e16fb7951cf($fileIdentifier, $file)
function composerRequire3ca87db3aa5231356decdf31415d3a58($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1f478404d094907764608e16fb7951cf
class ComposerStaticInit3ca87db3aa5231356decdf31415d3a58
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -2398,6 +2398,7 @@ class ComposerStaticInit1f478404d094907764608e16fb7951cf
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradePregUnmatchedAsNullConstantRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php',
'Rector\\DowngradePhp72\\Rector\\FuncCall\\DowngradeStreamIsattyRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php',
'Rector\\DowngradePhp72\\Rector\\FunctionLike\\DowngradeObjectTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php',
'Rector\\DowngradePhp73\\Rector\\ConstFetch\\DowngradePhp73JsonConstRector' => __DIR__ . '/../..' . '/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php',
'Rector\\DowngradePhp73\\Rector\\FuncCall\\DowngradeArrayKeyFirstLastRector' => __DIR__ . '/../..' . '/rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php',
'Rector\\DowngradePhp73\\Rector\\FuncCall\\DowngradeIsCountableRector' => __DIR__ . '/../..' . '/rules/DowngradePhp73/Rector/FuncCall/DowngradeIsCountableRector.php',
'Rector\\DowngradePhp73\\Rector\\FuncCall\\DowngradeTrailingCommasInFunctionCallsRector' => __DIR__ . '/../..' . '/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php',
@ -3863,9 +3864,9 @@ class ComposerStaticInit1f478404d094907764608e16fb7951cf
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1f478404d094907764608e16fb7951cf::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1f478404d094907764608e16fb7951cf::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1f478404d094907764608e16fb7951cf::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit3ca87db3aa5231356decdf31415d3a58::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3ca87db3aa5231356decdf31415d3a58::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3ca87db3aa5231356decdf31415d3a58::$classMap;
}, null, ClassLoader::class);
}

View File

@ -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('RectorPrefix20220208\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit1f478404d094907764608e16fb7951cf', false) && !interface_exists('ComposerAutoloaderInit1f478404d094907764608e16fb7951cf', false) && !trait_exists('ComposerAutoloaderInit1f478404d094907764608e16fb7951cf', false)) {
spl_autoload_call('RectorPrefix20220208\ComposerAutoloaderInit1f478404d094907764608e16fb7951cf');
if (!class_exists('ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58', false) && !interface_exists('ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58', false) && !trait_exists('ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58', false)) {
spl_autoload_call('RectorPrefix20220208\ComposerAutoloaderInit3ca87db3aa5231356decdf31415d3a58');
}
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('RectorPrefix20220208\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220208\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire1f478404d094907764608e16fb7951cf')) {
function composerRequire1f478404d094907764608e16fb7951cf() {
return \RectorPrefix20220208\composerRequire1f478404d094907764608e16fb7951cf(...func_get_args());
if (!function_exists('composerRequire3ca87db3aa5231356decdf31415d3a58')) {
function composerRequire3ca87db3aa5231356decdf31415d3a58() {
return \RectorPrefix20220208\composerRequire3ca87db3aa5231356decdf31415d3a58(...func_get_args());
}
}
if (!function_exists('scanPath')) {