Skip to content

Commit

Permalink
Fixed phpcs errors and warnings because of which the merge checks wer…
Browse files Browse the repository at this point in the history
…e failing
  • Loading branch information
Abhishek Jakhotiya committed Nov 16, 2023
1 parent 8fb1e13 commit e8232c6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Magento2/Rector/Src/AddHtmlEscaperToOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,28 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
// if the echo already has escapeHtml called on $block or escaper, don't do anthing
// if the echo already has escapeHtml called on $block or escaper, don't do anthing

$echoContent = $node->exprs[0];
$echoContent = $node->exprs[0];

if($echoContent instanceof Node\Expr\Variable || $echoContent instanceof Node\Expr\FuncCall){
$node->exprs[0] = new Node\Expr\MethodCall(new Node\Expr\Variable('escaper'),'escapeHtml',[new Node\Arg($echoContent)]);
return $node;
}
if ($echoContent instanceof Node\Expr\Variable || $echoContent instanceof Node\Expr\FuncCall) {
$node->exprs[0] = new Node\Expr\MethodCall(
new Node\Expr\Variable('escaper'),
'escapeHtml',
[new Node\Arg($echoContent)]
);
return $node;
}

if($echoContent instanceof Node\Expr\MethodCall && $echoContent->name != 'escapeHtml'){
if ($echoContent instanceof Node\Expr\MethodCall && $echoContent->name != 'escapeHtml') {

$node->exprs[0] = new Node\Expr\MethodCall(new Node\Expr\Variable('escaper'),'escapeHtml',[new Node\Arg($echoContent)]);
return $node;
}
$node->exprs[0] = new Node\Expr\MethodCall(
new Node\Expr\Variable('escaper'),
'escapeHtml',
[new Node\Arg($echoContent)]
);
return $node;
}

return null;
}
Expand Down

0 comments on commit e8232c6

Please sign in to comment.