> */ public function getNodeTypes() : array { return [Identical::class, BooleanNot::class]; } /** * @param Identical|BooleanNot $node */ public function refactor(Node $node) : ?Node { if ($node instanceof Identical) { return $this->processIdentical($node); } if ($node->expr instanceof Identical) { $identical = $node->expr; $leftType = $this->getType($identical->left); if (!$leftType->isBoolean()->yes()) { return null; } $rightType = $this->getType($identical->right); if (!$rightType->isBoolean()->yes()) { return null; } return new NotIdentical($identical->left, $identical->right); } return null; } private function processIdentical(Identical $identical) : ?NotIdentical { $leftType = $this->getType($identical->left); if (!$leftType->isBoolean()->yes()) { return null; } $rightType = $this->getType($identical->right); if (!$rightType->isBoolean()->yes()) { return null; } if ($identical->left instanceof BooleanNot) { return new NotIdentical($identical->left->expr, $identical->right); } return null; } }