Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 14, 2024
1 parent 096d12d commit 1bb8d08
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions rules/CodeQuality/NodeFactory/ArrayItemNodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ArrayItemNodeFactory
*
* @var string[]
*/
private const EXTENSION_KEYS = ['gedmo'];
private const EXTENSION_KEYS = ['gedmo', 'joinColumns'];

/**
* @param array<string, mixed> $propertyMapping
Expand Down Expand Up @@ -51,28 +51,16 @@ public function create(array $propertyMapping, array $quotedFields = []): array
continue;
}

// special case for separate entity
if ($fieldKey === 'joinColumns') {
continue;
}

if (is_array($fieldValue)) {
$fieldValueArrayItemNodes = [];

foreach ($fieldValue as $fieldSingleKey => $fieldSingleValue) {
if (is_numeric($fieldSingleValue)) {
$fieldSingleValue = (string) $fieldSingleValue;
$fieldArrayItemNode = new ArrayItemNode($fieldSingleValue, new StringNode($fieldSingleKey));
} elseif (is_bool($fieldSingleValue)) {
$fieldSingleValue = NodeValueNormalizer::normalize($fieldSingleValue);
$fieldArrayItemNode = new ArrayItemNode($fieldSingleValue, new StringNode($fieldSingleKey));
} elseif (is_string($fieldSingleKey)) {
$fieldArrayItemNode = new ArrayItemNode(new StringNode($fieldSingleValue), new StringNode(
$fieldSingleKey
));
} else {
$fieldArrayItemNode = new ArrayItemNode(new StringNode($fieldSingleValue));
}
$fieldSingleNode = NodeValueNormalizer::normalize($fieldSingleValue);

$fieldArrayItemNode = new ArrayItemNode(
$fieldSingleNode,
is_string($fieldSingleKey) ? new StringNode($fieldSingleKey) : null
);

$fieldValueArrayItemNodes[] = $fieldArrayItemNode;
}
Expand Down

0 comments on commit 1bb8d08

Please sign in to comment.