Skip to content

Commit

Permalink
[CodeQuality] Skip with comment inside on SimplifyIfElseToTernaryRector
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jan 20, 2025
1 parent 1576a7b commit 48ab03c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector\Fixture;

class SkipWithCommentInside
{
public function run()
{
if ( $user_id === 0 ) {
// some important comment
$access = true;
} else {
// some another important comment
$access = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ private function resolveOnlyStmtAssignExpr(array $stmts): ?Expr
return null;
}

if ($stmt->getComments() !== []) {
return null;
}

$stmtExpr = $stmt->expr;
if (! $stmtExpr instanceof Assign) {
return null;
Expand Down

0 comments on commit 48ab03c

Please sign in to comment.