> */ public function getNodeTypes() : array { return [Ternary::class]; } /** * @param Ternary $node */ public function refactor(Node $node) : ?Node { if (!$node->cond instanceof BooleanNot) { return null; } if (!$node->if instanceof Expr) { return null; } $node->cond = $node->cond->expr; [$node->if, $node->else] = [$node->else, $node->if]; if ($node->if instanceof Ternary) { $ternary = $node->if; $ternary->setAttribute(AttributeKey::KIND, 'wrapped_with_brackets'); $ternary->setAttribute(AttributeKey::ORIGINAL_NODE, null); } return $node; } }