Skip to content

Commit

Permalink
Merge pull request #151 from spryker-sdk/feature/sdk-2855-add-missed-…
Browse files Browse the repository at this point in the history
…plugin-classes

SDK 2855 add missed plugin classes
  • Loading branch information
pavelmaksimov25 authored Oct 27, 2023
2 parents b16d7d2 + 3e188ed commit 431e07e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Builder/Visitor/AddPluginToPluginListVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ protected function addNewPluginWithConditionIntoList(ClassMethod $node): Node
$newStmts[] = $this->createNewConditionStatement($returnStmt->expr);
}
if ($returnStmt->expr instanceof FuncCall || $returnStmt->expr instanceof Array_) {
$newStmts[] = $this->createAssignEmptyArray(static::PLUGINS_VARIBLE);
$newStmts[] = $this->createAssignArray(
static::PLUGINS_VARIBLE,
$returnStmt->expr instanceof Array_ ? $returnStmt->expr : null,
);
$newStmts[] = $this->createNewConditionStatement((new BuilderFactory())->var(static::PLUGINS_VARIBLE));
$returnStmt->expr = (new BuilderFactory())->var(static::PLUGINS_VARIBLE);
}
Expand All @@ -223,15 +226,16 @@ protected function addNewPluginWithConditionIntoList(ClassMethod $node): Node

/**
* @param string $varName
* @param \PhpParser\Node\Expr\Array_|null $initialArray
*
* @return \PhpParser\Node\Stmt\Expression
*/
protected function createAssignEmptyArray(string $varName): Expression
protected function createAssignArray(string $varName, ?Array_ $initialArray = null): Expression
{
return new Expression(
new Assign(
(new BuilderFactory())->var($varName),
new Array_(),
$initialArray ?? new Array_(),
),
);
}
Expand Down

0 comments on commit 431e07e

Please sign in to comment.