Skip to content

Commit 5fad592

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [VarExporter] Uniform unitialized property error message under ghost and non-ghost objects [AssetMapper] Ignore comment lines in JavaScriptImportPathCompiler Update configuration path in help message [Validator] Review Albanian translation [Process] Fix Inconsistent Exit Status in proc_get_status for PHP Versions Below 8.3 [Validator] Update Czech (cz) translation Sync translations [Mailer][Postmark][Webhook] Make allowed IPs configurable Review portuguese translations [Validator] Fix fields without constraints in `Collection` deal with fields for which no constraints have been configured [DomCrawler] [Form] Fix the exclusion of <template>
2 parents 0f71a6e + ca32356 commit 5fad592

File tree

5 files changed

+88
-17
lines changed

5 files changed

+88
-17
lines changed

Constraints/Collection.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Collection extends Composite
3535

3636
public function __construct(?array $fields = null, ?array $groups = null, mixed $payload = null, ?bool $allowExtraFields = null, ?bool $allowMissingFields = null, ?string $extraFieldsMessage = null, ?string $missingFieldsMessage = null)
3737
{
38-
if (\is_array($fields) && ([] === $fields || ($firstField = reset($fields)) instanceof Constraint || ($firstField[0] ?? null) instanceof Constraint)) {
38+
if (self::isFieldsOption($fields)) {
3939
$fields = ['fields' => $fields];
4040
}
4141

@@ -73,4 +73,31 @@ protected function getCompositeOption(): string
7373
{
7474
return 'fields';
7575
}
76+
77+
private static function isFieldsOption($options): bool
78+
{
79+
if (!\is_array($options)) {
80+
return false;
81+
}
82+
83+
foreach ($options as $optionOrField) {
84+
if ($optionOrField instanceof Constraint) {
85+
return true;
86+
}
87+
88+
if (null === $optionOrField) {
89+
continue;
90+
}
91+
92+
if (!\is_array($optionOrField)) {
93+
return false;
94+
}
95+
96+
if ($optionOrField && !($optionOrField[0] ?? null) instanceof Constraint) {
97+
return false;
98+
}
99+
}
100+
101+
return true;
102+
}
76103
}

Resources/translations/validators.cs.xlf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</trans-unit>
137137
<trans-unit id="37" resname="This is not a valid IP address.">
138138
<source>This value is not a valid IP address.</source>
139-
<target state="needs-review-translation">Tato hodnota není platnou IP adresou.</target>
139+
<target>Tato hodnota není platnou IP adresou.</target>
140140
</trans-unit>
141141
<trans-unit id="38">
142142
<source>This value is not a valid language.</source>
@@ -192,7 +192,7 @@
192192
</trans-unit>
193193
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
194194
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
195-
<target state="needs-review-translation">V php.ini nebyla nastavena cesta k dočasnému adresáři, nebo nastavený adresář neexistuje.</target>
195+
<target>V php.ini nebyla nastavena cesta k dočasnému adresáři, nebo nastavený adresář neexistuje.</target>
196196
</trans-unit>
197197
<trans-unit id="52">
198198
<source>Cannot write temporary file to disk.</source>
@@ -224,7 +224,7 @@
224224
</trans-unit>
225225
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
226226
<source>This value is not a valid International Bank Account Number (IBAN).</source>
227-
<target state="needs-review-translation">Tato hodnota není platným Mezinárodním bankovním číslem účtu (IBAN).</target>
227+
<target>Tato hodnota není platným Mezinárodním bankovním číslem účtu (IBAN).</target>
228228
</trans-unit>
229229
<trans-unit id="60">
230230
<source>This value is not a valid ISBN-10.</source>
@@ -312,15 +312,15 @@
312312
</trans-unit>
313313
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
314314
<source>This value is not a valid Business Identifier Code (BIC).</source>
315-
<target state="needs-review-translation">Tato hodnota není platným Kódem obchodního identifikátoru (BIC).</target>
315+
<target>Tato hodnota není platným Kódem obchodního identifikátoru (BIC).</target>
316316
</trans-unit>
317317
<trans-unit id="82">
318318
<source>Error</source>
319319
<target>Chyba</target>
320320
</trans-unit>
321321
<trans-unit id="83" resname="This is not a valid UUID.">
322322
<source>This value is not a valid UUID.</source>
323-
<target state="needs-review-translation">Tato hodnota není platným UUID.</target>
323+
<target>Tato hodnota není platným UUID.</target>
324324
</trans-unit>
325325
<trans-unit id="84">
326326
<source>This value should be a multiple of {{ compared_value }}.</source>
@@ -436,7 +436,7 @@
436436
</trans-unit>
437437
<trans-unit id="112">
438438
<source>This value is not a valid MAC address.</source>
439-
<target state="needs-review-translation">Tato hodnota není platnou MAC adresou.</target>
439+
<target>Tato hodnota není platnou MAC adresou.</target>
440440
</trans-unit>
441441
</body>
442442
</file>

Resources/translations/validators.pt.xlf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</trans-unit>
137137
<trans-unit id="37" resname="This is not a valid IP address.">
138138
<source>This value is not a valid IP address.</source>
139-
<target state="needs-review-translation">Este valor não é um endereço IP válido.</target>
139+
<target>Este valor não é um endereço IP válido.</target>
140140
</trans-unit>
141141
<trans-unit id="38">
142142
<source>This value is not a valid language.</source>
@@ -192,7 +192,7 @@
192192
</trans-unit>
193193
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
194194
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
195-
<target state="needs-review-translation">Nenhuma pasta temporária foi configurada no php.ini, ou a pasta configurada não existe.</target>
195+
<target>Nenhuma pasta temporária foi configurada no php.ini, ou a pasta configurada não existe.</target>
196196
</trans-unit>
197197
<trans-unit id="52">
198198
<source>Cannot write temporary file to disk.</source>
@@ -224,7 +224,7 @@
224224
</trans-unit>
225225
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
226226
<source>This value is not a valid International Bank Account Number (IBAN).</source>
227-
<target state="needs-review-translation">Este valor não é um Número de Conta Bancária Internacional (IBAN) válido.</target>
227+
<target>Este valor não é um Número de Conta Bancária Internacional (IBAN) válido.</target>
228228
</trans-unit>
229229
<trans-unit id="60">
230230
<source>This value is not a valid ISBN-10.</source>
@@ -312,15 +312,15 @@
312312
</trans-unit>
313313
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
314314
<source>This value is not a valid Business Identifier Code (BIC).</source>
315-
<target state="needs-review-translation">Este valor não é um Código de Identificação de Negócio (BIC) válido.</target>
315+
<target>Este valor não é um Código de Identificação de Negócio (BIC) válido.</target>
316316
</trans-unit>
317317
<trans-unit id="82">
318318
<source>Error</source>
319319
<target>Erro</target>
320320
</trans-unit>
321321
<trans-unit id="83" resname="This is not a valid UUID.">
322322
<source>This value is not a valid UUID.</source>
323-
<target state="needs-review-translation">Este valor não é um UUID válido.</target>
323+
<target>Este valor não é um UUID válido.</target>
324324
</trans-unit>
325325
<trans-unit id="84">
326326
<source>This value should be a multiple of {{ compared_value }}.</source>

Resources/translations/validators.sq.xlf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<header>
55
<note>
66
Për fjalët e huaja, të cilat nuk kanë përkthim të drejtpërdrejtë, ju lutemi të ndiqni rregullat e mëposhtme:
7-
a) në rast se emri është akronim i përdorur gjerësisht si i përveçëm, atëherë, emri lakohet pa thonjëza dhe mbaresa shkruhet me vizë ndarëse. Gjinia gjykohet sipas rastit. Shembull: JSON (mashkullore)
8-
b) në rast se emri është akronim i papërdorur gjerësisht si i përveçëm, atëherë, emri lakohet pa thonjëza dhe mbaresa shkruhet me vizë ndarëse. Gjinia është femërore. Shembull: URL (femërore)
9-
c) në rast se emri duhet lakuar për shkak të rasës në fjali, atëherë, emri lakohet pa thonjëza dhe mbaresa shkruhet me vizë ndarëse. Shembull: host-i, prej host-it
10-
d) në rast se emri nuk duhet lakuar për shkak të trajtës në fjali, atëherë, emri rrethote me thonjëzat “”. Shembull: “locale”
7+
a) në rast se emri është akronim i përdorur gjerësisht si i përveçëm, atëherë, emri lakohet pa thonjëza dhe mbaresa shkruhet me vizë ndarëse. Gjinia gjykohet sipas rastit. Shembull: JSON (mashkullore)
8+
b) në rast se emri është akronim i papërdorur gjerësisht si i përveçëm, atëherë, emri lakohet pa thonjëza dhe mbaresa shkruhet me vizë ndarëse. Gjinia është femërore. Shembull: URL (femërore)
9+
c) në rast se emri duhet lakuar për shkak të rasës në fjali, atëherë, emri lakohet pa thonjëza dhe mbaresa shkruhet me vizë ndarëse. Shembull: host-i, prej host-it
10+
d) në rast se emri nuk duhet lakuar për shkak të trajtës në fjali, atëherë, emri rrethote me thonjëzat “”. Shembull: “locale”
1111
</note>
1212
</header>
1313
<body>
@@ -329,7 +329,7 @@
329329
</trans-unit>
330330
<trans-unit id="83" resname="This is not a valid UUID.">
331331
<source>This value is not a valid UUID.</source>
332-
<target state="needs-review-translation">Kjo vlerë nuk është një UUID e vlefshme.</target>
332+
<target>Kjo vlerë nuk është një UUID e vlefshme.</target>
333333
</trans-unit>
334334
<trans-unit id="84">
335335
<source>This value should be a multiple of {{ compared_value }}.</source>

Tests/Constraints/CollectionTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,50 @@ public function testEmptyFieldsInOptions()
162162
'extraFieldsMessage' => 'foo bar baz',
163163
]);
164164

165+
$this->assertSame([], $constraint->fields);
166+
$this->assertTrue($constraint->allowExtraFields);
167+
$this->assertSame('foo bar baz', $constraint->extraFieldsMessage);
168+
}
169+
170+
/**
171+
* @testWith [[]]
172+
* [null]
173+
*/
174+
public function testEmptyConstraintListForField(?array $fieldConstraint)
175+
{
176+
$constraint = new Collection(
177+
[
178+
'foo' => $fieldConstraint,
179+
],
180+
null,
181+
null,
182+
true,
183+
null,
184+
'foo bar baz'
185+
);
186+
187+
$this->assertArrayHasKey('foo', $constraint->fields);
188+
$this->assertInstanceOf(Required::class, $constraint->fields['foo']);
189+
$this->assertTrue($constraint->allowExtraFields);
190+
$this->assertSame('foo bar baz', $constraint->extraFieldsMessage);
191+
}
192+
193+
/**
194+
* @testWith [[]]
195+
* [null]
196+
*/
197+
public function testEmptyConstraintListForFieldInOptions(?array $fieldConstraint)
198+
{
199+
$constraint = new Collection([
200+
'fields' => [
201+
'foo' => $fieldConstraint,
202+
],
203+
'allowExtraFields' => true,
204+
'extraFieldsMessage' => 'foo bar baz',
205+
]);
206+
207+
$this->assertArrayHasKey('foo', $constraint->fields);
208+
$this->assertInstanceOf(Required::class, $constraint->fields['foo']);
165209
$this->assertTrue($constraint->allowExtraFields);
166210
$this->assertSame('foo bar baz', $constraint->extraFieldsMessage);
167211
}

0 commit comments

Comments
 (0)