Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PhpParser/Node/BetterNodeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ static function (Node $subNode) use (&$scopedNode, $foundNode): ?int {

/**
* @api
* @deprecated Hook into the previous node instead, to work only with current context
*
* Resolve next node from any Node, eg: Expr, Identifier, Name, etc
*/
Expand Down
8 changes: 1 addition & 7 deletions src/PhpParser/Parser/InlineCodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
use Nette\Utils\Strings;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\Encapsed;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
use Rector\Core\Util\StringUtils;
Expand Down Expand Up @@ -65,7 +63,6 @@ public function __construct(
private readonly BetterStandardPrinter $betterStandardPrinter,
private readonly SimplePhpParser $simplePhpParser,
private readonly ValueResolver $valueResolver,
private readonly BetterNodeFinder $betterNodeFinder
) {
}

Expand Down Expand Up @@ -148,10 +145,7 @@ private function resolveConcatValue(Concat $concat): string
}

if ($concat->right instanceof String_ && str_starts_with($concat->right->value, '($')) {
$node = $this->betterNodeFinder->resolveNextNode($concat);
if ($node instanceof Variable) {
$concat->right->value .= '.';
}
$concat->right->value .= '.';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on original solution, it using Token based check, I will update it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I wonder why no test is failing here though 🤔

Let's go with current version in this PR untill we find the breaking code, so we have it covered in test fixture for sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it definitelly breaking change, as we limit to variable on purpose to avoid next is func call, but let's see how large it break

}

$string = $this->stringify($concat->left) . $this->stringify($concat->right);
Expand Down