From 81835f9f7a5b6b6f133409396561c5108ab65ca4 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 16 Oct 2023 13:22:26 +0300 Subject: [PATCH] SDK-5049: Skip duplicate plugin in if section (#146) --- src/Builder/Visitor/AddPluginToPluginListVisitor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Builder/Visitor/AddPluginToPluginListVisitor.php b/src/Builder/Visitor/AddPluginToPluginListVisitor.php index c56c190a..84c48370 100644 --- a/src/Builder/Visitor/AddPluginToPluginListVisitor.php +++ b/src/Builder/Visitor/AddPluginToPluginListVisitor.php @@ -370,6 +370,9 @@ protected function addNewPluginInstance(If_ $statement): void if ($stmt->expr->expr instanceof ArrayItem && $this->isArrayItemEqual($stmt->expr->expr)) { continue; } + if ($stmt->expr->expr instanceof New_ && $stmt->expr->expr->class->toString() === $this->classMetadataTransfer->getSource()) { + continue; + } array_unshift($statement->stmts, $this->createNewAssignStatement($stmt->expr));