binaryOpManipulator = $binaryOpManipulator; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Simplify negated conditions with de Morgan theorem', [new CodeSample(<<<'CODE_SAMPLE' $a = 5; $b = 10; $result = !($a > 20 || $b <= 50); CODE_SAMPLE , <<<'CODE_SAMPLE' $a = 5; $b = 10; $result = $a <= 20 && $b > 50; CODE_SAMPLE )]); } /** * @return array> */ public function getNodeTypes() : array { return [BooleanNot::class]; } /** * @param BooleanNot $node */ public function refactor(Node $node) : ?BinaryOp { if (!$node->expr instanceof BooleanOr) { return null; } return $this->binaryOpManipulator->inverseBooleanOr($node->expr); } }