Updated Rector to commit d8aa22b6713269ddafa80679777b3de9a4f456dd

d8aa22b671 [Printer][EarlyReturn] Enable InlineHTML on RemoveAlwaysElseRector (#3387)
This commit is contained in:
Tomas Votruba 2023-02-16 20:39:52 +00:00
parent def6b091b1
commit d17680f2a5
7 changed files with 29 additions and 24 deletions

View File

@ -12,7 +12,6 @@ use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\Throw_;
use Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -21,15 +20,6 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*/
final class RemoveAlwaysElseRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer
*/
private $inlineHTMLAnalyzer;
public function __construct(InlineHTMLAnalyzer $inlineHTMLAnalyzer)
{
$this->inlineHTMLAnalyzer = $inlineHTMLAnalyzer;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Split if statement, when if condition always break execution flow', [new CodeSample(<<<'CODE_SAMPLE'
@ -87,13 +77,13 @@ CODE_SAMPLE
$node->stmts = $firstElseIf->stmts;
$this->mirrorComments($node, $firstElseIf);
$nodesToReturnAfterNode = $this->getStatementsElseIfs($node);
if ($originalNode->else instanceof Else_ && !$this->inlineHTMLAnalyzer->hasInlineHTML($originalNode->else)) {
if ($originalNode->else instanceof Else_) {
$node->else = null;
$nodesToReturnAfterNode = \array_merge($nodesToReturnAfterNode, [$originalNode->else]);
}
return \array_merge([$if, $node], $nodesToReturnAfterNode);
}
if ($node->else instanceof Else_ && !$this->inlineHTMLAnalyzer->hasInlineHTML($node->else)) {
if ($node->else instanceof Else_) {
$stmts = $node->else->stmts;
$node->else = null;
return \array_merge([$node], $stmts);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '5db390cb7b67d3537acc34d3eabb04de1ef4b35a';
public const PACKAGE_VERSION = 'd8aa22b6713269ddafa80679777b3de9a4f456dd';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-02-15 15:15:07';
public const RELEASE_DATE = '2023-02-17 03:35:31';
/**
* @var int
*/

View File

@ -91,6 +91,20 @@ final class MixPhpHtmlDecorator
if ($stmt->getStartTokenPos() < 0) {
$inlineHTML->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$this->isRequireReprintInlineHTML = \true;
return;
}
$originalNode = $stmt->getAttribute(AttributeKey::ORIGINAL_NODE);
if (!$originalNode instanceof Node) {
return;
}
$node = $originalNode->getAttribute(AttributeKey::PARENT_NODE);
if (!$node instanceof Stmt) {
return;
}
// last Stmt that connected to InlineHTML just removed
if ($inlineHTML->getAttribute(AttributeKey::PARENT_NODE) !== $node) {
$inlineHTML->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$this->isRequireReprintInlineHTML = \true;
}
}
}

View File

@ -431,6 +431,7 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa
{
$content = \str_replace('<?php <?php', '<?php', $content);
$content = \str_replace('?>?>', '?>', $content);
$content = \str_replace("?>\n?>", '?>', $content);
if (\strncmp($content, "?>\n", \strlen("?>\n")) === 0) {
return \substr($content, 3);
}

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit27d85ec15b63c3e068ca1fd22deb4d94
class ComposerAutoloaderInit6d6c25c9d00903292b712e7cb95efb28
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit27d85ec15b63c3e068ca1fd22deb4d94
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit27d85ec15b63c3e068ca1fd22deb4d94', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit6d6c25c9d00903292b712e7cb95efb28', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit27d85ec15b63c3e068ca1fd22deb4d94', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit6d6c25c9d00903292b712e7cb95efb28', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit6d6c25c9d00903292b712e7cb95efb28::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit6d6c25c9d00903292b712e7cb95efb28::$files;
$requireFile = \Closure::bind(static function ($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 ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94
class ComposerStaticInit6d6c25c9d00903292b712e7cb95efb28
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3123,9 +3123,9 @@ class ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit27d85ec15b63c3e068ca1fd22deb4d94::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit6d6c25c9d00903292b712e7cb95efb28::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6d6c25c9d00903292b712e7cb95efb28::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit6d6c25c9d00903292b712e7cb95efb28::$classMap;
}, null, ClassLoader::class);
}