Skip to content

Commit 2f0e0f3

Browse files
committed
adding support for associative arrays in annotations
1 parent 7d3042c commit 2f0e0f3

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/Util/ClassSourceManipulator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ private function buildAnnotationLine(string $annotationClass, array $options)
206206
$formattedOptions = array_map(function ($option, $value) {
207207
if (is_array($value)) {
208208
if (!isset($value[0])) {
209+
return sprintf('%s={%s}', $option, implode(', ', array_map(function ($val, $key) {
210+
return sprintf('"%s" = %s', $key, $this->quoteAnnotationValue($val));
211+
}, $value, array_keys($value))));
212+
209213
// associative array: we'll add this if/when we need it
210214
throw new \Exception('Not currently supported');
211215
}

tests/Util/ClassSourceManipulatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public function getAddEntityFieldTests()
211211
'type' => 'string',
212212
'length' => 255,
213213
'nullable' => false,
214+
'options' => ['comment' => 'new field']
214215
],
215216
false, // only methods
216217
'User_simple.php'

tests/Util/fixtures/add_entity_field/User_simple.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class User
1717
private $id;
1818

1919
/**
20-
* @ORM\Column(type="string", length=255, nullable=false)
20+
* @ORM\Column(type="string", length=255, nullable=false, options={"comment" = "new field"})
2121
*/
2222
private $fooProp;
2323

0 commit comments

Comments
 (0)