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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

true and $x = 42 and false;

var_dump($x);

?>
-----
<?php

true && ($x = 42) && false;

var_dump($x);

?>
6 changes: 6 additions & 0 deletions src/PhpParser/Printer/BetterStandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ private function wrapBinaryOpWithBrackets(Node $node): void
$node->left->setAttribute(AttributeKey::ORIGINAL_NODE, null);
}

if ($node->right instanceof Assign
&& $this->origTokens instanceof TokenStream
&& ! $this->origTokens->haveParens($node->right->getStartTokenPos(), $node->right->getEndTokenPos())) {
$node->right->setAttribute(AttributeKey::ORIGINAL_NODE, null);
}

if ($node->left instanceof BinaryOp &&
$node->left->getAttribute(AttributeKey::ORIGINAL_NODE) instanceof Node) {
$node->left->setAttribute(AttributeKey::ORIGINAL_NODE, null);
Expand Down
Loading