Updated Rector to commit a638a676b4c23c70ed65e52463a4c193d72d2c7d

a638a676b4 [PHP 7.4] Fix literator separator string/int missmatch in PHPStan type (#2913)
This commit is contained in:
Tomas Votruba 2022-09-05 17:52:37 +00:00
parent cb35f4b8c0
commit 94c101e7d9
12 changed files with 56 additions and 26 deletions

View File

@ -134,4 +134,9 @@ final class AttributeKey
* @var string
*/
public const PHP_ATTRIBUTE_NAME = 'php_attribute_name';
/**
* Helper attribute to reprint raw value of int/float/string
* @var string
*/
public const REPRINT_RAW_VALUE = 'reprint_raw_value';
}

View File

@ -105,7 +105,11 @@ CODE_SAMPLE
$literalSeparatedNumber .= '.0';
}
}
$node->value = $literalSeparatedNumber;
// this cannot be integer directly to $node->value, as PHPStan sees it as error type
// @see https://github.com/rectorphp/rector/issues/7454
$node->setAttribute(AttributeKey::RAW_VALUE, $literalSeparatedNumber);
$node->setAttribute(AttributeKey::REPRINT_RAW_VALUE, \true);
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
return $node;
}
public function provideMinPhpVersion() : int

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'f230e5463ae1bfd9e1d6070935def31ae493109e';
public const PACKAGE_VERSION = 'a638a676b4c23c70ed65e52463a4c193d72d2c7d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-09-05 14:42:35';
public const RELEASE_DATE = '2022-09-05 17:48:03';
/**
* @var int
*/

View File

@ -17,6 +17,7 @@ use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\DNumber;
use PhpParser\Node\Scalar\EncapsedStringPart;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
@ -216,8 +217,8 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa
*/
protected function pScalar_DNumber(DNumber $dNumber) : string
{
if (\is_string($dNumber->value)) {
return $dNumber->value;
if ($this->shouldPrintNewRawValue($dNumber)) {
return (string) $dNumber->getAttribute(AttributeKey::RAW_VALUE);
}
return parent::pScalar_DNumber($dNumber);
}
@ -384,6 +385,25 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa
{
return (($modifiers & Class_::MODIFIER_FINAL) !== 0 ? 'final ' : '') . (($modifiers & Class_::MODIFIER_ABSTRACT) !== 0 ? 'abstract ' : '') . (($modifiers & Class_::MODIFIER_PUBLIC) !== 0 ? 'public ' : '') . (($modifiers & Class_::MODIFIER_PROTECTED) !== 0 ? 'protected ' : '') . (($modifiers & Class_::MODIFIER_PRIVATE) !== 0 ? 'private ' : '') . (($modifiers & Class_::MODIFIER_STATIC) !== 0 ? 'static ' : '') . (($modifiers & Class_::MODIFIER_READONLY) !== 0 ? 'readonly ' : '');
}
/**
* Invoke re-print even if only raw value was changed.
* That allows PHPStan to use int strict types, while changing the value with literal "_"
* @return string|int
*/
protected function pScalar_LNumber(LNumber $lNumber)
{
if ($this->shouldPrintNewRawValue($lNumber)) {
return (string) $lNumber->getAttribute(AttributeKey::RAW_VALUE);
}
return parent::pScalar_LNumber($lNumber);
}
/**
* @param \PhpParser\Node\Scalar\LNumber|\PhpParser\Node\Scalar\DNumber $lNumber
*/
private function shouldPrintNewRawValue($lNumber) : bool
{
return $lNumber->getAttribute(AttributeKey::REPRINT_RAW_VALUE) === \true;
}
private function resolveContentOnExpr(Expr $expr, string $content) : string
{
$parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE);

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInite6d9d73ab60df60c9870f2003c9c9d29::getLoader();
return ComposerAutoloaderInitf9241782ab23a36b90edd25998ef5eff::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInite6d9d73ab60df60c9870f2003c9c9d29
class ComposerAutoloaderInitf9241782ab23a36b90edd25998ef5eff
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInite6d9d73ab60df60c9870f2003c9c9d29
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInite6d9d73ab60df60c9870f2003c9c9d29', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf9241782ab23a36b90edd25998ef5eff', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInite6d9d73ab60df60c9870f2003c9c9d29', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf9241782ab23a36b90edd25998ef5eff', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf9241782ab23a36b90edd25998ef5eff::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitf9241782ab23a36b90edd25998ef5eff::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiree6d9d73ab60df60c9870f2003c9c9d29($fileIdentifier, $file);
composerRequiref9241782ab23a36b90edd25998ef5eff($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInite6d9d73ab60df60c9870f2003c9c9d29
* @param string $file
* @return void
*/
function composerRequiree6d9d73ab60df60c9870f2003c9c9d29($fileIdentifier, $file)
function composerRequiref9241782ab23a36b90edd25998ef5eff($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 ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29
class ComposerStaticInitf9241782ab23a36b90edd25998ef5eff
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3093,9 +3093,9 @@ class ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInite6d9d73ab60df60c9870f2003c9c9d29::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf9241782ab23a36b90edd25998ef5eff::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf9241782ab23a36b90edd25998ef5eff::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf9241782ab23a36b90edd25998ef5eff::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1922,12 +1922,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "def9fd5dc5eddc074de8e1ceda1693a7b14dfb1f"
"reference": "0e30fa8810b90e2024d8f0c6f6d474cb8147fa41"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/def9fd5dc5eddc074de8e1ceda1693a7b14dfb1f",
"reference": "def9fd5dc5eddc074de8e1ceda1693a7b14dfb1f",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/0e30fa8810b90e2024d8f0c6f6d474cb8147fa41",
"reference": "0e30fa8810b90e2024d8f0c6f6d474cb8147fa41",
"shasum": ""
},
"require": {
@ -1944,7 +1944,7 @@
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.6",
"rector\/rector-debugging": "dev-main",
"rector\/rector-src": "dev-main",
"rector\/rector-src": "dev-main#12f2056",
"symplify\/easy-ci": "^11.1",
"symplify\/easy-coding-standard": "^11.1",
"symplify\/phpstan-extensions": "^11.1",
@ -1952,7 +1952,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-09-04T09:42:10+00:00",
"time": "2022-09-05T17:29:32+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a489bf0'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 79161af'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main def9fd5'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3f58e44'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4e464b4'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a489bf0'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 79161af'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0e30fa8'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3f58e44'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4e464b4'));
private function __construct()
{
}

View File

@ -14,7 +14,7 @@
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.6",
"rector\/rector-debugging": "dev-main",
"rector\/rector-src": "dev-main",
"rector\/rector-src": "dev-main#12f2056",
"symplify\/easy-ci": "^11.1",
"symplify\/easy-coding-standard": "^11.1",
"symplify\/phpstan-extensions": "^11.1",

View File

@ -60,7 +60,8 @@ CODE_SAMPLE
if (\strpos((string) $rawValue, '+') !== \false) {
return null;
}
// trigger reprint
$rawValueWithoutUnderscores = \str_replace('_', '', $rawValue);
$node->setAttribute(AttributeKey::RAW_VALUE, $rawValueWithoutUnderscores);
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
return $node;
}