getPrice();', 'echo $object instanceof Product ? $object->getPrice() : null;')]);
}
/**
* @return array>
*/
public function getNodeTypes() : array
{
return [Ternary::class];
}
/**
* @param Ternary $node
*/
public function refactor(Node $node) : ?Node
{
if (!$node->if instanceof Expr) {
return null;
}
if (!$node->cond instanceof BooleanNot) {
return null;
}
$booleanNot = $node->cond;
if (!$booleanNot->expr instanceof Instanceof_) {
return null;
}
$node->cond = $booleanNot->expr;
// flip if and else
[$node->if, $node->else] = [$node->else, $node->if];
return $node;
}
}