diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 6c124a7f8c5..f19453ead8a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -29,7 +29,6 @@ jobs: - 'e2e/no-parallel-reflection-resolver' - 'e2e/parallel-custom-config' - 'e2e/parallel-reflection-resolver' - - 'e2e/plain-views' - 'e2e/applied-rule-removed-node' - 'e2e/parallel with space' - 'e2e/removed-and-added-files-collector' diff --git a/.github/workflows/e2e_with_cache.yaml b/.github/workflows/e2e_with_cache.yaml index 220768b3aaf..1f249cdeec2 100644 --- a/.github/workflows/e2e_with_cache.yaml +++ b/.github/workflows/e2e_with_cache.yaml @@ -25,7 +25,6 @@ jobs: php_version: ['8.1'] directory: - 'e2e/applied-rule-removed-node-with-cache' - - 'e2e/timeout-file-not-cached' name: End to end test - ${{ matrix.directory }} diff --git a/e2e/plain-views/.editorconfig b/e2e/plain-views/.editorconfig deleted file mode 100644 index 7c4b9dfd606..00000000000 --- a/e2e/plain-views/.editorconfig +++ /dev/null @@ -1,3 +0,0 @@ -[src/view.php] -insert_final_newline = false -trim_trailing_whitespace = false diff --git a/e2e/plain-views/.gitignore b/e2e/plain-views/.gitignore deleted file mode 100644 index 61ead86667c..00000000000 --- a/e2e/plain-views/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/vendor diff --git a/e2e/plain-views/composer.json b/e2e/plain-views/composer.json deleted file mode 100644 index 5468cd74606..00000000000 --- a/e2e/plain-views/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "require": { - "php": "^8.1" - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/e2e/plain-views/expected-output.diff b/e2e/plain-views/expected-output.diff deleted file mode 100644 index e7a894c8fce..00000000000 --- a/e2e/plain-views/expected-output.diff +++ /dev/null @@ -1,25 +0,0 @@ -1 file with changes -=================== - -1) src/short_open_tag_with_import_name.php:0 - - ---------- begin diff ---------- -@@ @@ - -
- -
-- paths([ - __DIR__.'/src/', - ]); - - $rectorConfig->rule(CommonNotEqualRector::class); - $rectorConfig->importNames(); - $rectorConfig->fileExtensions(['php', 'phtml']); -}; diff --git a/e2e/plain-views/src/comment_before_closing_tag.php b/e2e/plain-views/src/comment_before_closing_tag.php deleted file mode 100644 index 449b98219f2..00000000000 --- a/e2e/plain-views/src/comment_before_closing_tag.php +++ /dev/null @@ -1,6 +0,0 @@ -
- - -
diff --git a/e2e/plain-views/src/comment_before_closing_tag2.php b/e2e/plain-views/src/comment_before_closing_tag2.php deleted file mode 100644 index 092085aa960..00000000000 --- a/e2e/plain-views/src/comment_before_closing_tag2.php +++ /dev/null @@ -1,15 +0,0 @@ -
-

- List of users -

- -
diff --git a/e2e/plain-views/src/commented_elseif_alternate_syntax.php b/e2e/plain-views/src/commented_elseif_alternate_syntax.php deleted file mode 100644 index 651f0810ec6..00000000000 --- a/e2e/plain-views/src/commented_elseif_alternate_syntax.php +++ /dev/null @@ -1,17 +0,0 @@ -
- getMinAmount()) && ($_max = $this->getMaxAmount()) && ($_min == $_max)): ?> - - currency($_min, true, false) ?> - - getMinAmount()) && $_min != 0): ?> - __('From') ?> - - currency($_min,true,false) ?> - - getMaxAmount()): ?> - __('Up To') ?> - - currency($_max,true,false) ?> - - -
\ No newline at end of file diff --git a/e2e/plain-views/src/empty.php b/e2e/plain-views/src/empty.php deleted file mode 100644 index b3d9bbc7f37..00000000000 --- a/e2e/plain-views/src/empty.php +++ /dev/null @@ -1 +0,0 @@ - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- - - \ No newline at end of file diff --git a/e2e/plain-views/src/view_with_not_equal_already_common.php b/e2e/plain-views/src/view_with_not_equal_already_common.php deleted file mode 100644 index c053a830012..00000000000 --- a/e2e/plain-views/src/view_with_not_equal_already_common.php +++ /dev/null @@ -1,4 +0,0 @@ - -
- -
\ No newline at end of file diff --git a/e2e/plain-views/src/with_whitespace_previous.php b/e2e/plain-views/src/with_whitespace_previous.php deleted file mode 100644 index ab702892f97..00000000000 --- a/e2e/plain-views/src/with_whitespace_previous.php +++ /dev/null @@ -1,6 +0,0 @@ - - - -cacheClass(FileCacheStorage::class); - $rectorConfig->parallel(1); - - $rectorConfig->paths([ - __DIR__ . '/src', - ]); - - $rectorConfig->sets([LevelSetList::UP_TO_PHP_82]); -}; diff --git a/e2e/timeout-file-not-cached/src/SomeFixturePrinter.php b/e2e/timeout-file-not-cached/src/SomeFixturePrinter.php deleted file mode 100644 index a4255bcb36f..00000000000 --- a/e2e/timeout-file-not-cached/src/SomeFixturePrinter.php +++ /dev/null @@ -1,625 +0,0 @@ - $insertionMap - */ -final class SomeFixturePrinter extends Standard implements NodePrinterInterface -{ - /** - * @var string - * @see https://regex101.com/r/jUFizd/1 - */ - private const NEWLINE_END_REGEX = "#\n$#"; - - /** - * @var string - * @see https://regex101.com/r/F5x783/1 - */ - private const USE_REGEX = '#( use)\(#'; - - /** - * @var string - * @see https://regex101.com/r/DrsMY4/1 - */ - private const QUOTED_SLASH_REGEX = "#'|\\\\(?=[\\\\']|$)#"; - - /** - * Remove extra spaces before new Nop_ nodes - * @see https://regex101.com/r/iSvroO/1 - * @var string - */ - private const EXTRA_SPACE_BEFORE_NOP_REGEX = '#^[ \t]+$#m'; - - /** - * @see https://regex101.com/r/qZiqGo/13 - * @var string - */ - private const REPLACE_COLON_WITH_SPACE_REGEX = '#(^.*function .*\(.*\)) : #'; - - /** - * Use space by default - */ - private string $tabOrSpaceIndentCharacter = ' '; - - /** - * @param mixed[] $options - */ - public function __construct( - private readonly DocBlockUpdater $docBlockUpdater, - private readonly RectorConfigProvider $rectorConfigProvider, - private readonly CurrentFileProvider $currentFileProvider, - private readonly MixPhpHtmlDecorator $mixPhpHtmlDecorator, - array $options = [] - ) { - parent::__construct($options); - - // print return type double colon right after the bracket "function(): string" - $this->initializeInsertionMap(); - $this->insertionMap['Stmt_ClassMethod->returnType'] = [')', false, ': ', null]; - $this->insertionMap['Stmt_Function->returnType'] = [')', false, ': ', null]; - $this->insertionMap['Expr_Closure->returnType'] = [')', false, ': ', null]; - $this->insertionMap['Expr_ArrowFunction->returnType'] = [')', false, ': ', null]; - - $this->tabOrSpaceIndentCharacter = $this->rectorConfigProvider->getIndentChar(); - } - - /** - * @param Node[] $stmts - * @param Node[] $origStmts - * @param mixed[] $origTokens - */ - public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string - { - $newStmts = $this->resolveNewStmts($stmts); - - $content = parent::printFormatPreserving($newStmts, $origStmts, $origTokens); - - // add new line in case of added stmts - if (count($newStmts) !== count($origStmts) && ! StringUtils::isMatch($content, self::NEWLINE_END_REGEX)) { - $content .= $this->nl; - } - - if (! $this->mixPhpHtmlDecorator->isRequireReprintInlineHTML()) { - return $content; - } - - // ensure disable flag isRequireReprintInlineHTML on change file - $this->mixPhpHtmlDecorator->disableIsRequireReprintInlineHTML(); - - $content = $this->cleanSurplusTag($content); - return $this->cleanEndWithPHPOpenTag($content); - } - - /** - * @param Node|Node[]|null $node - */ - public function print(Node | array | null $node): string - { - if ($node === null) { - $node = []; - } - - if (! is_array($node)) { - $node = [$node]; - } - - return $this->prettyPrint($node); - } - - /** - * @param Node[] $stmts - */ - public function prettyPrintFile(array $stmts): string - { - // to keep indexes from 0 - $stmts = array_values($stmts); - - return parent::prettyPrintFile($stmts) . PHP_EOL; - } - - /** - * @api magic method in parent - */ - public function pFileWithoutNamespace(FileWithoutNamespace $fileWithoutNamespace): string - { - $content = $this->pStmts($fileWithoutNamespace->stmts, false); - - return ltrim($content); - } - - protected function p(Node $node, $parentFormatPreserved = false): string - { - $content = parent::p($node, $parentFormatPreserved); - - if ($node instanceof Expr) { - $content = $this->resolveContentOnExpr($node, $content); - } - - return $node->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES) === true - ? ('(' . $content . ')') - : $content; - } - - /** - * This allows to use both spaces and tabs vs. original space-only - */ - protected function setIndentLevel(int $level): void - { - $level = max($level, 0); - $this->indentLevel = $level; - $this->nl = "\n" . str_repeat($this->tabOrSpaceIndentCharacter, $level); - } - - /** - * This allows to use both spaces and tabs vs. original space-only - */ - protected function indent(): void - { - $indentSize = $this->rectorConfigProvider->getIndentSize(); - - $this->indentLevel += $indentSize; - $this->nl .= str_repeat($this->tabOrSpaceIndentCharacter, $indentSize); - } - - /** - * This allows to use both spaces and tabs vs. original space-only - */ - protected function outdent(): void - { - if ($this->tabOrSpaceIndentCharacter === ' ') { - // - 4 spaces - assert($this->indentLevel >= 4); - $this->indentLevel -= 4; - } else { - // - 1 tab - assert($this->indentLevel >= 1); - --$this->indentLevel; - } - - $this->nl = "\n" . str_repeat($this->tabOrSpaceIndentCharacter, $this->indentLevel); - } - - /** - * @param mixed[] $nodes - * @param mixed[] $origNodes - * @param int|null $fixup - */ - protected function pArray( - array $nodes, - array $origNodes, - int &$pos, - int $indentAdjustment, - string $parentNodeType, - string $subNodeName, - $fixup - ): ?string { - // reindex positions for printer - $nodes = array_values($nodes); - - $this->decorateInlineHTMLOrNopAndUpdatePhpdocInfo($nodes); - - $content = parent::pArray($nodes, $origNodes, $pos, $indentAdjustment, $parentNodeType, $subNodeName, $fixup); - - if ($content === null) { - return $content; - } - - if (! $this->containsNop($nodes)) { - return $content; - } - - return Strings::replace($content, self::EXTRA_SPACE_BEFORE_NOP_REGEX); - } - - /** - * Do not preslash all slashes (parent behavior), but only those: - * - * - followed by "\" - * - by "'" - * - or the end of the string - * - * Prevents `Vendor\Class` => `Vendor\\Class`. - */ - protected function pSingleQuotedString(string $string): string - { - return "'" . Strings::replace($string, self::QUOTED_SLASH_REGEX, '\\\\$0') . "'"; - } - - /** - * Emulates 1_000 in PHP 7.3- version - */ - protected function pScalar_DNumber(DNumber $dNumber): string - { - if ($this->shouldPrintNewRawValue($dNumber)) { - return (string) $dNumber->getAttribute(AttributeKey::RAW_VALUE); - } - - return parent::pScalar_DNumber($dNumber); - } - - /** - * Add space: - * "use(" - * ↓ - * "use (" - */ - protected function pExpr_Closure(Closure $closure): string - { - $closureContent = parent::pExpr_Closure($closure); - - if ($closure->uses === []) { - return $closureContent; - } - - return Strings::replace($closureContent, self::USE_REGEX, '$1 ('); - } - - /** - * Do not add "()" on Expressions - * @see https://github.com/rectorphp/rector/pull/401#discussion_r181487199 - */ - protected function pExpr_Yield(Yield_ $yield): string - { - if (! $yield->value instanceof Expr) { - return 'yield'; - } - - $parentNode = $yield->getAttribute(AttributeKey::PARENT_NODE); - // brackets are needed only in case of assign, @see https://www.php.net/manual/en/language.generators.syntax.php - $shouldAddBrackets = $parentNode instanceof Assign; - - return sprintf( - '%syield %s%s%s', - $shouldAddBrackets ? '(' : '', - $yield->key instanceof Expr ? $this->p($yield->key) . ' => ' : '', - $this->p($yield->value), - $shouldAddBrackets ? ')' : '' - ); - } - - /** - * Print arrays in short [] by default, - * to prevent manual explicit array shortening. - */ - protected function pExpr_Array(Array_ $array): string - { - if (! $array->hasAttribute(AttributeKey::KIND)) { - $array->setAttribute(AttributeKey::KIND, Array_::KIND_SHORT); - } - - if ($array->getAttribute(AttributeKey::NEWLINED_ARRAY_PRINT) === true) { - $printedArray = '['; - $printedArray .= $this->pCommaSeparatedMultiline($array->items, true); - - return $printedArray . ($this->nl . ']'); - } - - return parent::pExpr_Array($array); - } - - /** - * Fixes escaping of regular patterns - */ - protected function pScalar_String(String_ $string): string - { - $isRegularPattern = (bool) $string->getAttribute(AttributeKey::IS_REGULAR_PATTERN, false); - if (! $isRegularPattern) { - return parent::pScalar_String($string); - } - - $kind = $string->getAttribute(AttributeKey::KIND, String_::KIND_SINGLE_QUOTED); - if ($kind === String_::KIND_DOUBLE_QUOTED) { - return $this->wrapValueWith($string, '"'); - } - - if ($kind === String_::KIND_SINGLE_QUOTED) { - return $this->wrapValueWith($string, "'"); - } - - return parent::pScalar_String($string); - } - - /** - * @param Node[] $nodes - */ - protected function pStmts(array $nodes, bool $indent = true): string - { - $this->decorateInlineHTMLOrNopAndUpdatePhpdocInfo($nodes); - - return parent::pStmts($nodes, $indent); - } - - /** - * "...$params) : ReturnType" - * ↓ - * "...$params): ReturnType" - */ - protected function pStmt_ClassMethod(ClassMethod $classMethod): string - { - $content = parent::pStmt_ClassMethod($classMethod); - - if (! $classMethod->returnType instanceof Node) { - return $content; - } - - // this approach is chosen, to keep changes in parent pStmt_ClassMethod() updated - return Strings::replace($content, self::REPLACE_COLON_WITH_SPACE_REGEX, '$1: '); - } - - /** - * It remove all spaces extra to parent - */ - protected function pStmt_Declare(Declare_ $declare): string - { - $declareString = parent::pStmt_Declare($declare); - - return Strings::replace($declareString, '#\s+#'); - } - - protected function pExpr_Ternary(Ternary $ternary): string - { - $kind = $ternary->getAttribute(AttributeKey::KIND); - if ($kind === 'wrapped_with_brackets') { - $pExprTernary = parent::pExpr_Ternary($ternary); - return '(' . $pExprTernary . ')'; - } - - return parent::pExpr_Ternary($ternary); - } - - /** - * Remove extra \\ from FQN use imports, for easier use in the code - */ - protected function pStmt_Use(Use_ $use): string - { - if ($use->type !== Use_::TYPE_NORMAL) { - return parent::pStmt_Use($use); - } - - foreach ($use->uses as $useUse) { - if (! $useUse->name instanceof FullyQualified) { - continue; - } - - $useUse->name = new Name($useUse->name->toString()); - } - - return parent::pStmt_Use($use); - } - - protected function pScalar_EncapsedStringPart(EncapsedStringPart $encapsedStringPart): string - { - // parent throws exception, but we need to compare string - return '`' . $encapsedStringPart->value . '`'; - } - - protected function pCommaSeparated(array $nodes): string - { - $result = parent::pCommaSeparated($nodes); - - $last = end($nodes); - - if ($last instanceof Node) { - $trailingComma = $last->getAttribute(AttributeKey::FUNC_ARGS_TRAILING_COMMA); - if ($trailingComma === false) { - $result = rtrim($result, ','); - } - } - - return $result; - } - - /** - * Override parent pModifiers to set position of final and abstract modifier early, so instead of - * - * public final const MY_CONSTANT = "Hello world!"; - * - * it should be - * - * final public const MY_CONSTANT = "Hello world!"; - * - * @see https://github.com/rectorphp/rector/issues/6963 - * @see https://github.com/nikic/PHP-Parser/pull/826 - */ - protected function pModifiers(int $modifiers): string - { - 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 "_" - */ - protected function pScalar_LNumber(LNumber $lNumber): string|int - { - if ($this->shouldPrintNewRawValue($lNumber)) { - return (string) $lNumber->getAttribute(AttributeKey::RAW_VALUE); - } - - return parent::pScalar_LNumber($lNumber); - } - - /** - * Keep attributes on newlines - */ - protected function pParam(Param $param): string - { - return $this->pAttrGroups($param->attrGroups) - . $this->pModifiers($param->flags) - . ($param->type instanceof Node ? $this->p($param->type) . ' ' : '') - . ($param->byRef ? '&' : '') - . ($param->variadic ? '...' : '') - . $this->p($param->var) - . ($param->default instanceof Expr ? ' = ' . $this->p($param->default) : ''); - } - - private function cleanEndWithPHPOpenTag(string $content): string - { - if (str_ends_with($content, "?>', '?>', $content); - - if (str_starts_with($content, "?>\n")) { - return substr($content, 3); - } - - if (str_starts_with($content, "")) { - return substr($content, 10); - } - - return $content; - } - - private function shouldPrintNewRawValue(LNumber|DNumber $lNumber): bool - { - return $lNumber->getAttribute(AttributeKey::REPRINT_RAW_VALUE) === true; - } - - private function resolveContentOnExpr(Expr $expr, string $content): string - { - $parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE); - if (! $parentNode instanceof ArrowFunction) { - return $content; - } - - if ($parentNode->expr !== $expr) { - return $content; - } - - if (! $parentNode->hasAttribute(AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) { - return $content; - } - - /** @var Comment[] $comments */ - $comments = $expr->getAttribute(AttributeKey::COMMENTS) ?? []; - - if ($comments === []) { - return $content; - } - - $text = ''; - foreach ($comments as $comment) { - $text .= $comment->getText() . "\n"; - } - - return $content = $text . $content; - } - - /** - * @param Node[] $stmts - * @return Node[]|mixed[] - */ - private function resolveNewStmts(array $stmts): array - { - $stmts = array_values($stmts); - - if (count($stmts) === 1 && $stmts[0] instanceof FileWithoutNamespace) { - return $this->resolveNewStmts($stmts[0]->stmts); - } - - return $stmts; - } - - /** - * @param array $nodes - */ - private function decorateInlineHTMLOrNopAndUpdatePhpdocInfo(array $nodes): void - { - $file = $this->currentFileProvider->getFile(); - $hasDiff = $file instanceof File && $file->getFileDiff() instanceof FileDiff; - - // move phpdoc from node to "comment" attribute - foreach ($nodes as $key => $node) { - if (! $node instanceof Node) { - continue; - } - - if ($node instanceof InlineHTML && $hasDiff) { - $this->mixPhpHtmlDecorator->decorateInlineHTML($node, $key, $nodes); - } - - if ($node instanceof Nop && $hasDiff) { - $this->mixPhpHtmlDecorator->decorateAfterNop($node, $key, $nodes); - } - - $this->docBlockUpdater->updateNodeWithPhpDocInfo($node); - } - } - - /** - * @param Node[] $nodes - */ - private function containsNop(array $nodes): bool - { - foreach ($nodes as $node) { - if ($node instanceof Nop) { - return true; - } - } - - return false; - } - - private function wrapValueWith(String_ $string, string $wrap): string - { - return $wrap . $string->value . $wrap; - } -} diff --git a/rector.php b/rector.php index f8432d4afa3..138b3bb5e7f 100644 --- a/rector.php +++ b/rector.php @@ -73,6 +73,9 @@ '**/Expected*', __DIR__ . '/tests/PhpUnit/MultipleFilesChangedTrait/MultipleFilesChangedTraitTest.php', + // ignore for now, as printer cleans duplicate string of itself + __DIR__ . '/src/PhpParser/Printer/BetterStandardPrinter.php', + // to keep original API from PHPStan untouched __DIR__ . '/packages/Caching/ValueObject/Storage/FileCacheStorage.php', diff --git a/rules-tests/CodeQuality/Rector/Expression/TernaryFalseExpressionToIfRector/Fixture/with_html.php.inc b/rules-tests/CodeQuality/Rector/Expression/TernaryFalseExpressionToIfRector/Fixture/with_html.php.inc deleted file mode 100644 index 9217dfb0972..00000000000 --- a/rules-tests/CodeQuality/Rector/Expression/TernaryFalseExpressionToIfRector/Fixture/with_html.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - - - ------ - - - diff --git a/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php.php.inc b/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php.php.inc deleted file mode 100644 index febedd0fd91..00000000000 --- a/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -
- -
------ -
- -
diff --git a/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php2.php.inc b/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php2.php.inc deleted file mode 100644 index 5d5df746a7a..00000000000 --- a/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php2.php.inc +++ /dev/null @@ -1,23 +0,0 @@ - -
- -
------ - -
- -
diff --git a/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php3.php.inc b/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php3.php.inc deleted file mode 100644 index 9e17670e427..00000000000 --- a/rules-tests/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector/Fixture/mix_html_php3.php.inc +++ /dev/null @@ -1,28 +0,0 @@ - -
- -
- ------ - -
- -
- 2) { - return; - } else { ?> - this is world - ------ - 2) { - return; - } - ?> - this is world - diff --git a/src/Kernel/RectorKernel.php b/src/Kernel/RectorKernel.php index 04a0d2ab159..4c68f421113 100644 --- a/src/Kernel/RectorKernel.php +++ b/src/Kernel/RectorKernel.php @@ -17,7 +17,7 @@ final class RectorKernel /** * @var string */ - private const CACHE_KEY = 'v45'; + private const CACHE_KEY = 'v47'; private ContainerInterface|null $container = null; diff --git a/src/NodeDecorator/MixPhpHtmlDecorator.php b/src/NodeDecorator/MixPhpHtmlDecorator.php deleted file mode 100644 index a08ac796f33..00000000000 --- a/src/NodeDecorator/MixPhpHtmlDecorator.php +++ /dev/null @@ -1,136 +0,0 @@ -nodeRemover = $nodeRemover; - } - - public function isRequireReprintInlineHTML(): bool - { - return $this->isRequireReprintInlineHTML; - } - - public function disableIsRequireReprintInlineHTML(): void - { - $this->isRequireReprintInlineHTML = false; - } - - /** - * @param array $nodes - */ - public function decorateInlineHTML(InlineHTML $inlineHTML, int $key, array $nodes): void - { - if (isset($nodes[$key - 1]) && ! $nodes[$key - 1] instanceof InlineHTML && $nodes[$key - 1] instanceof Stmt) { - $this->rePrintInlineHTML($inlineHTML, $nodes[$key - 1]); - } - - if (! isset($nodes[$key + 1])) { - return; - } - - if ($nodes[$key + 1] instanceof InlineHTML) { - return; - } - - if (! $nodes[$key + 1] instanceof Stmt) { - return; - } - - $this->rePrintInlineHTML($inlineHTML, $nodes[$key + 1]); - } - - /** - * @param array $nodes - */ - public function decorateAfterNop(Nop $nop, int $key, array $nodes): void - { - if (! isset($nodes[$key + 1]) || $nodes[$key + 1] instanceof InlineHTML) { - return; - } - - if (! $nodes[$key + 1] instanceof Stmt) { - return; - } - - $firstNodeAfterNop = $nodes[$key + 1]; - if ($firstNodeAfterNop->getStartTokenPos() >= 0) { - return; - } - - // Token start = -1, just added - $nodeComments = []; - foreach ($nop->getComments() as $comment) { - if ($comment instanceof Doc) { - $nodeComments[] = new Comment( - $comment->getText(), - $comment->getStartLine(), - $comment->getStartFilePos(), - $comment->getStartTokenPos(), - $comment->getEndLine(), - $comment->getEndFilePos(), - $comment->getEndTokenPos() - ); - continue; - } - - $nodeComments[] = $comment; - } - - $firstNodeAfterNop->setAttribute(AttributeKey::COMMENTS, $nodeComments); - - // remove Nop is marked as comment of Next Node - $this->nodeRemover->removeNode($nop); - - $this->isRequireReprintInlineHTML = true; - } - - private function rePrintInlineHTML(InlineHTML $inlineHTML, Stmt $stmt): void - { - // Token start = -1, just added - 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; - } - - $parentInlineHTML = $inlineHTML->getAttribute(AttributeKey::PARENT_NODE); - - // last Stmt that connected to InlineHTML just removed detected by different start token pos - if ($parentInlineHTML instanceof Stmt && $parentInlineHTML->getStartTokenPos() !== $node->getStartTokenPos()) { - $inlineHTML->setAttribute(AttributeKey::ORIGINAL_NODE, null); - $this->isRequireReprintInlineHTML = true; - } - } -} diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php index fd3000897fe..653caaca981 100644 --- a/src/PhpParser/Printer/BetterStandardPrinter.php +++ b/src/PhpParser/Printer/BetterStandardPrinter.php @@ -24,19 +24,14 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Declare_; -use PhpParser\Node\Stmt\InlineHTML; use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Use_; use PhpParser\PrettyPrinter\Standard; use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Configuration\RectorConfigProvider; use Rector\Core\Contract\PhpParser\NodePrinterInterface; -use Rector\Core\NodeDecorator\MixPhpHtmlDecorator; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; -use Rector\Core\Provider\CurrentFileProvider; use Rector\Core\Util\StringUtils; -use Rector\Core\ValueObject\Application\File; -use Rector\Core\ValueObject\Reporting\FileDiff; use Rector\NodeTypeResolver\Node\AttributeKey; /** @@ -88,8 +83,6 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa public function __construct( private readonly DocBlockUpdater $docBlockUpdater, private readonly RectorConfigProvider $rectorConfigProvider, - private readonly CurrentFileProvider $currentFileProvider, - private readonly MixPhpHtmlDecorator $mixPhpHtmlDecorator, array $options = [] ) { parent::__construct($options); @@ -121,13 +114,6 @@ public function printFormatPreserving(array $stmts, array $origStmts, array $ori $content .= $this->nl; } - if (! $this->mixPhpHtmlDecorator->isRequireReprintInlineHTML()) { - return $content; - } - - // ensure disable flag isRequireReprintInlineHTML on change file - $this->mixPhpHtmlDecorator->disableIsRequireReprintInlineHTML(); - $content = $this->cleanSurplusTag($content); return $this->cleanEndWithPHPOpenTag($content); } @@ -586,23 +572,12 @@ private function resolveNewStmts(array $stmts): array */ private function decorateInlineHTMLOrNopAndUpdatePhpdocInfo(array $nodes): void { - $file = $this->currentFileProvider->getFile(); - $hasDiff = $file instanceof File && $file->getFileDiff() instanceof FileDiff; - // move phpdoc from node to "comment" attribute - foreach ($nodes as $key => $node) { + foreach ($nodes as $node) { if (! $node instanceof Node) { continue; } - if ($node instanceof InlineHTML && $hasDiff) { - $this->mixPhpHtmlDecorator->decorateInlineHTML($node, $key, $nodes); - } - - if ($node instanceof Nop && $hasDiff) { - $this->mixPhpHtmlDecorator->decorateAfterNop($node, $key, $nodes); - } - $this->docBlockUpdater->updateNodeWithPhpDocInfo($node); } } diff --git a/tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNodeStmtTest.php b/tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNodeStmtTest.php deleted file mode 100644 index 6cbe0ad8ab8..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNodeStmtTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNopRectorTest.php b/tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNopRectorTest.php deleted file mode 100644 index 96a8dd242c5..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/AddNodeAfterNopRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixtureNextNop'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/add_next_nop_configured_rule.php'; - } -} diff --git a/tests/Issues/AddNodeAfterNodeStmt/Fixture/before_html.php.inc b/tests/Issues/AddNodeAfterNodeStmt/Fixture/before_html.php.inc deleted file mode 100644 index 6659b494fe8..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/Fixture/before_html.php.inc +++ /dev/null @@ -1,12 +0,0 @@ -
some text
- ------ -
some text
- diff --git a/tests/Issues/AddNodeAfterNodeStmt/Fixture/fixture.php.inc b/tests/Issues/AddNodeAfterNodeStmt/Fixture/fixture.php.inc deleted file mode 100644 index fb96f4c1c9c..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/Fixture/fixture.php.inc +++ /dev/null @@ -1,32 +0,0 @@ - ------ - diff --git a/tests/Issues/AddNodeAfterNodeStmt/Fixture/next_html.php.inc b/tests/Issues/AddNodeAfterNodeStmt/Fixture/next_html.php.inc deleted file mode 100644 index 396c056c17f..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/Fixture/next_html.php.inc +++ /dev/null @@ -1,13 +0,0 @@ - -
some text
------ - -
some text
diff --git a/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/fixture.php.inc b/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/fixture.php.inc deleted file mode 100644 index f5713f5cab5..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/fixture.php.inc +++ /dev/null @@ -1,14 +0,0 @@ - -
filter ;?>
------ - -
filter ;?>
\ No newline at end of file diff --git a/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/next_line_php_in_inline_html.php.inc b/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/next_line_php_in_inline_html.php.inc deleted file mode 100644 index d7e203e5a92..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/next_line_php_in_inline_html.php.inc +++ /dev/null @@ -1,22 +0,0 @@ - -
filter ; - -?>
------ - -
filter ; - -?>
\ No newline at end of file diff --git a/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/not_first_stmt.php.inc b/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/not_first_stmt.php.inc deleted file mode 100644 index da8913f8cc6..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/FixtureNextNop/not_first_stmt.php.inc +++ /dev/null @@ -1,14 +0,0 @@ -
- -
------ -
- -
diff --git a/tests/Issues/AddNodeAfterNodeStmt/Source/AddNextNopRector.php b/tests/Issues/AddNodeAfterNodeStmt/Source/AddNextNopRector.php deleted file mode 100644 index 99c9eeedb2b..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/Source/AddNextNopRector.php +++ /dev/null @@ -1,49 +0,0 @@ -phpDocInfoFactory->createEmpty($echo); - $phpDocInfo->addTagValueNode( - new VarTagValueNode( - new IdentifierTypeNode('string'), - '$container', - '' - ) - ); - - return [ - $node, - $echo, - ]; - } -} diff --git a/tests/Issues/AddNodeAfterNodeStmt/Source/AddNextStmtRector.php b/tests/Issues/AddNodeAfterNodeStmt/Source/AddNextStmtRector.php deleted file mode 100644 index 9e5e2ad7af9..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/Source/AddNextStmtRector.php +++ /dev/null @@ -1,36 +0,0 @@ -rule(AddNextNopRector::class); -}; diff --git a/tests/Issues/AddNodeAfterNodeStmt/config/configured_rule.php b/tests/Issues/AddNodeAfterNodeStmt/config/configured_rule.php deleted file mode 100644 index 819a045f328..00000000000 --- a/tests/Issues/AddNodeAfterNodeStmt/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(AddNextStmtRector::class); -}; diff --git a/tests/Issues/AddNodeBeforeNodeStmt/AddNodeBeforeInlineHTMLTest.php b/tests/Issues/AddNodeBeforeNodeStmt/AddNodeBeforeInlineHTMLTest.php deleted file mode 100644 index dd01b38e212..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/AddNodeBeforeInlineHTMLTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixtureBeforeInlineHTML'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/before_inline_html_configured_rule.php'; - } -} diff --git a/tests/Issues/AddNodeBeforeNodeStmt/AddNodeBeforeNodeStmtTest.php b/tests/Issues/AddNodeBeforeNodeStmt/AddNodeBeforeNodeStmtTest.php deleted file mode 100644 index 02dd28a66f3..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/AddNodeBeforeNodeStmtTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/AddNodeBeforeNodeStmt/Fixture/before_html.php.inc b/tests/Issues/AddNodeBeforeNodeStmt/Fixture/before_html.php.inc deleted file mode 100644 index 8819b2c07c2..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/Fixture/before_html.php.inc +++ /dev/null @@ -1,11 +0,0 @@ -
some text
- ------ -
some text
- -
some text
- ------ - -
some text
- - -
some text
- ------ - - -
some text
- diff --git a/tests/Issues/AddNodeBeforeNodeStmt/Fixture/fixture.php.inc b/tests/Issues/AddNodeBeforeNodeStmt/Fixture/fixture.php.inc deleted file mode 100644 index 78efef34121..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/Fixture/fixture.php.inc +++ /dev/null @@ -1,32 +0,0 @@ - ------ - diff --git a/tests/Issues/AddNodeBeforeNodeStmt/Fixture/next_html.php.inc b/tests/Issues/AddNodeBeforeNodeStmt/Fixture/next_html.php.inc deleted file mode 100644 index c886b487e97..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/Fixture/next_html.php.inc +++ /dev/null @@ -1,12 +0,0 @@ - -
some text next
------ - -
some text next
\ No newline at end of file diff --git a/tests/Issues/AddNodeBeforeNodeStmt/FixtureBeforeInlineHTML/fixture.php.inc b/tests/Issues/AddNodeBeforeNodeStmt/FixtureBeforeInlineHTML/fixture.php.inc deleted file mode 100644 index ebc97a67a1c..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/FixtureBeforeInlineHTML/fixture.php.inc +++ /dev/null @@ -1,14 +0,0 @@ -
------ - -
\ No newline at end of file diff --git a/tests/Issues/AddNodeBeforeNodeStmt/FixtureBeforeInlineHTML/fixture2.php.inc b/tests/Issues/AddNodeBeforeNodeStmt/FixtureBeforeInlineHTML/fixture2.php.inc deleted file mode 100644 index fd023418560..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/FixtureBeforeInlineHTML/fixture2.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -
filter ;?>
------ - -
filter ; -?>
diff --git a/tests/Issues/AddNodeBeforeNodeStmt/Source/AddBeforeInlineHTMLRector.php b/tests/Issues/AddNodeBeforeNodeStmt/Source/AddBeforeInlineHTMLRector.php deleted file mode 100644 index 73b15b49238..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/Source/AddBeforeInlineHTMLRector.php +++ /dev/null @@ -1,80 +0,0 @@ -justAdded[$this->file->getFilePath()])) { - return null; - } - - $expression1 = new Expression( - new Assign( - new Variable('test'), new String_('test') - ) - ); - - $phpDocInfo = $this->phpDocInfoFactory->createEmpty($expression1); - $phpDocInfo->addTagValueNode( - new VarTagValueNode( - new IdentifierTypeNode('string'), - '$container', - '' - ) - ); - - $expression2 = new Expression( - new Assign( - new Variable('test2'), new String_('test2') - ) - ); - - $phpDocInfo = $this->phpDocInfoFactory->createEmpty($expression2); - $phpDocInfo->addTagValueNode( - new VarTagValueNode( - new IdentifierTypeNode('string'), - '$container', - '' - ) - ); - - $node->stmts = array_merge([$expression1, $expression2], $node->stmts); - - $this->justAdded[$this->file->getFilePath()] = true; - - return $node; - } -} diff --git a/tests/Issues/AddNodeBeforeNodeStmt/Source/AddBeforeStmtRector.php b/tests/Issues/AddNodeBeforeNodeStmt/Source/AddBeforeStmtRector.php deleted file mode 100644 index 27dac824cef..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/Source/AddBeforeStmtRector.php +++ /dev/null @@ -1,36 +0,0 @@ -rule(AddBeforeInlineHTMLRector::class); -}; diff --git a/tests/Issues/AddNodeBeforeNodeStmt/config/configured_rule.php b/tests/Issues/AddNodeBeforeNodeStmt/config/configured_rule.php deleted file mode 100644 index ab71bd5e47a..00000000000 --- a/tests/Issues/AddNodeBeforeNodeStmt/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(AddBeforeStmtRector::class); -}; diff --git a/tests/Issues/InsertFirstBeforeInlineHTML/Fixture/fixture.php.inc b/tests/Issues/InsertFirstBeforeInlineHTML/Fixture/fixture.php.inc deleted file mode 100644 index 62d1afcdad5..00000000000 --- a/tests/Issues/InsertFirstBeforeInlineHTML/Fixture/fixture.php.inc +++ /dev/null @@ -1,10 +0,0 @@ -
filter ;?>
------ - -
filter ; -?>
diff --git a/tests/Issues/InsertFirstBeforeInlineHTML/InsertFirstBeforeInlineHTMLTest.php b/tests/Issues/InsertFirstBeforeInlineHTML/InsertFirstBeforeInlineHTMLTest.php deleted file mode 100644 index 1aa724bb64a..00000000000 --- a/tests/Issues/InsertFirstBeforeInlineHTML/InsertFirstBeforeInlineHTMLTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/InsertFirstBeforeInlineHTML/Source/InsertBeforeInlineHTMLRector.php b/tests/Issues/InsertFirstBeforeInlineHTML/Source/InsertBeforeInlineHTMLRector.php deleted file mode 100644 index e3cc82ac862..00000000000 --- a/tests/Issues/InsertFirstBeforeInlineHTML/Source/InsertBeforeInlineHTMLRector.php +++ /dev/null @@ -1,48 +0,0 @@ -justAdded[$this->file->getFilePath()])) { - return null; - } - - $echo = new Echo_([new String_('this is new stmt before InlineHTML')]); - - $node->stmts = array_merge( - [$echo, $echo], - $node->stmts - ); - - $this->justAdded[$this->file->getFilePath()] = true; - - return $node; - } -} diff --git a/tests/Issues/InsertFirstBeforeInlineHTML/config/configured_rule.php b/tests/Issues/InsertFirstBeforeInlineHTML/config/configured_rule.php deleted file mode 100644 index 599e3a6f68c..00000000000 --- a/tests/Issues/InsertFirstBeforeInlineHTML/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(InsertBeforeInlineHTMLRector::class); -}; diff --git a/tests/Issues/InsertLastAfterInlineHTML/Fixture/fixture.php.inc b/tests/Issues/InsertLastAfterInlineHTML/Fixture/fixture.php.inc deleted file mode 100644 index 260f6c6172d..00000000000 --- a/tests/Issues/InsertLastAfterInlineHTML/Fixture/fixture.php.inc +++ /dev/null @@ -1,8 +0,0 @@ -
filter ;?>
------ -
filter ; -?>
-doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/InsertLastAfterInlineHTML/Source/InsertAfterInlineHTMLRector.php b/tests/Issues/InsertLastAfterInlineHTML/Source/InsertAfterInlineHTMLRector.php deleted file mode 100644 index a774ede23ff..00000000000 --- a/tests/Issues/InsertLastAfterInlineHTML/Source/InsertAfterInlineHTMLRector.php +++ /dev/null @@ -1,47 +0,0 @@ -justAdded[$this->file->getFilePath()])) { - return null; - } - - $echo = new Echo_([new String_('this is new stmt after InlineHTML')]); - - $node->stmts = array_merge( - $node->stmts, - [$echo, $echo], - ); - - $this->justAdded[$this->file->getFilePath()] = true; - - return $node; - } -} diff --git a/tests/Issues/InsertLastAfterInlineHTML/config/configured_rule.php b/tests/Issues/InsertLastAfterInlineHTML/config/configured_rule.php deleted file mode 100644 index 6bd622060ac..00000000000 --- a/tests/Issues/InsertLastAfterInlineHTML/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(InsertAfterInlineHTMLRector::class); -}; diff --git a/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/FixtureArrayAfterInlineHTML/fixture.php.inc b/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/FixtureArrayAfterInlineHTML/fixture.php.inc deleted file mode 100644 index a90ddb810b4..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/FixtureArrayAfterInlineHTML/fixture.php.inc +++ /dev/null @@ -1,8 +0,0 @@ -
some content
------ -
some content
-doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixtureArrayAfterInlineHTML'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/Source/ArrayAddAfterInlineHTMLRector.php b/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/Source/ArrayAddAfterInlineHTMLRector.php deleted file mode 100644 index 1d2186b213f..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/Source/ArrayAddAfterInlineHTMLRector.php +++ /dev/null @@ -1,61 +0,0 @@ -justAdded[$this->file->getFilePath()])) { - return null; - } - - $echo = new Echo_([new String_("this is new stmt after InlineHTML")]); - - $phpDocInfo = $this->phpDocInfoFactory->createEmpty($echo); - $phpDocInfo->addTagValueNode( - new VarTagValueNode( - new IdentifierTypeNode('string'), - '$container', - '' - ) - ); - - $this->justAdded[$this->file->getFilePath()] = true; - - return [ - $node, - $echo, - ]; - } -} diff --git a/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/config/configured_rule.php b/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/config/configured_rule.php deleted file mode 100644 index 0cb73aa2c6e..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterInlineHTMLStmt/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(ArrayAddAfterInlineHTMLRector::class); -}; diff --git a/tests/Issues/ReturnArrayNodeAfterNopStmt/FixtureArrayNextNop/fixture.php.inc b/tests/Issues/ReturnArrayNodeAfterNopStmt/FixtureArrayNextNop/fixture.php.inc deleted file mode 100644 index f5713f5cab5..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterNopStmt/FixtureArrayNextNop/fixture.php.inc +++ /dev/null @@ -1,14 +0,0 @@ - -
filter ;?>
------ - -
filter ;?>
\ No newline at end of file diff --git a/tests/Issues/ReturnArrayNodeAfterNopStmt/FixtureArrayNextNop/next_line_php_in_inline_html.php.inc b/tests/Issues/ReturnArrayNodeAfterNopStmt/FixtureArrayNextNop/next_line_php_in_inline_html.php.inc deleted file mode 100644 index d7e203e5a92..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterNopStmt/FixtureArrayNextNop/next_line_php_in_inline_html.php.inc +++ /dev/null @@ -1,22 +0,0 @@ - -
filter ; - -?>
------ - -
filter ; - -?>
\ No newline at end of file diff --git a/tests/Issues/ReturnArrayNodeAfterNopStmt/ReturnArrayNodeAfterNodeStmtTest.php b/tests/Issues/ReturnArrayNodeAfterNopStmt/ReturnArrayNodeAfterNodeStmtTest.php deleted file mode 100644 index c4c876837b9..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterNopStmt/ReturnArrayNodeAfterNodeStmtTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixtureArrayNextNop'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/array_next_nop_configured_rule.php'; - } -} diff --git a/tests/Issues/ReturnArrayNodeAfterNopStmt/Source/ArrayAddNextNopRector.php b/tests/Issues/ReturnArrayNodeAfterNopStmt/Source/ArrayAddNextNopRector.php deleted file mode 100644 index a641c0cb7f7..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterNopStmt/Source/ArrayAddNextNopRector.php +++ /dev/null @@ -1,61 +0,0 @@ -justAdded[$this->file->getFilePath()])) { - return null; - } - - $echo = new Echo_([new String_("this is new stmt after Nop")]); - - $phpDocInfo = $this->phpDocInfoFactory->createEmpty($echo); - $phpDocInfo->addTagValueNode( - new VarTagValueNode( - new IdentifierTypeNode('string'), - '$container', - '' - ) - ); - - $this->justAdded[$this->file->getFilePath()] = true; - - return [ - $node, - $echo, - ]; - } -} diff --git a/tests/Issues/ReturnArrayNodeAfterNopStmt/config/array_next_nop_configured_rule.php b/tests/Issues/ReturnArrayNodeAfterNopStmt/config/array_next_nop_configured_rule.php deleted file mode 100644 index 034d68f0f71..00000000000 --- a/tests/Issues/ReturnArrayNodeAfterNopStmt/config/array_next_nop_configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(ArrayAddNextNopRector::class); -}; diff --git a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/FixtureArrayBeforeInlineHTML/fixture.php.inc b/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/FixtureArrayBeforeInlineHTML/fixture.php.inc deleted file mode 100644 index a400816ef4a..00000000000 --- a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/FixtureArrayBeforeInlineHTML/fixture.php.inc +++ /dev/null @@ -1,16 +0,0 @@ -
filter ;?>
------ - -
filter ; -?>
diff --git a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/FixtureArrayBeforeInlineHTML/next_line_php_in_inline_html.php.inc b/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/FixtureArrayBeforeInlineHTML/next_line_php_in_inline_html.php.inc deleted file mode 100644 index 6194933c442..00000000000 --- a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/FixtureArrayBeforeInlineHTML/next_line_php_in_inline_html.php.inc +++ /dev/null @@ -1,20 +0,0 @@ -
filter ; - -?>
------ - -
filter ; -?>
diff --git a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/ReturnArrayNodeBeforeInlineHTMLStmtTest.php b/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/ReturnArrayNodeBeforeInlineHTMLStmtTest.php deleted file mode 100644 index de8e8093db7..00000000000 --- a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/ReturnArrayNodeBeforeInlineHTMLStmtTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixtureArrayBeforeInlineHTML'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/Source/ArrayAddBeforeInlineHTMLRector.php b/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/Source/ArrayAddBeforeInlineHTMLRector.php deleted file mode 100644 index 6f6f8719582..00000000000 --- a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/Source/ArrayAddBeforeInlineHTMLRector.php +++ /dev/null @@ -1,62 +0,0 @@ -justAdded[$this->file->getFilePath()])) { - return null; - } - - $echo = new Echo_([new String_("this is new stmt before InlineHTML")]); - - $phpDocInfo = $this->phpDocInfoFactory->createEmpty($echo); - $phpDocInfo->addTagValueNode( - new VarTagValueNode( - new IdentifierTypeNode('string'), - '$container', - '' - ) - ); - - $this->justAdded[$this->file->getFilePath()] = true; - - return [ - $echo, - $echo, - $node, - ]; - } -} diff --git a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/config/configured_rule.php b/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/config/configured_rule.php deleted file mode 100644 index f15fd8666b6..00000000000 --- a/tests/Issues/ReturnArrayNodeBeforeInlineHTMLStmt/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(ArrayAddBeforeInlineHTMLRector::class); -};