Skip to content

Commit 6f47d0c

Browse files
committed
minor #27712 [Serializer] CsvEncoder::AS_COLLECTION_KEY constant (ogizanagi)
This PR was merged into the 4.1 branch. Discussion ---------- [Serializer] CsvEncoder::AS_COLLECTION_KEY constant | Q | A | ------------- | --- | Branch? | 4.1 <!-- see below --> | Bug fix? | no | New feature? | not really <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A We use public constants for context options. For 4.1 IMHO as a consistency fix. Commits ------- 660a456 [Serializer] CsvEncoder::AS_COLLECTION_KEY constant
2 parents e32b965 + 660a456 commit 6f47d0c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Component/Serializer/Encoder/CsvEncoder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
2828
const KEY_SEPARATOR_KEY = 'csv_key_separator';
2929
const HEADERS_KEY = 'csv_headers';
3030
const ESCAPE_FORMULAS_KEY = 'csv_escape_formulas';
31+
const AS_COLLECTION_KEY = 'as_collection';
3132

3233
private $delimiter;
3334
private $enclosure;
@@ -157,7 +158,7 @@ public function decode($data, $format, array $context = array())
157158
}
158159
fclose($handle);
159160

160-
if ($context['as_collection'] ?? false) {
161+
if ($context[self::AS_COLLECTION_KEY] ?? false) {
161162
return $result;
162163
}
163164

src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public function testDecodeOnlyOneAsCollection()
324324
a
325325

326326
CSV
327-
, 'csv', array('as_collection' => true)));
327+
, 'csv', array(CsvEncoder::AS_COLLECTION_KEY => true)));
328328
}
329329

330330
public function testDecodeToManyRelation()

0 commit comments

Comments
 (0)