Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e5dfcf

Browse filesBrowse files
committed
Merge branch '3.4' into 4.2
* 3.4: [Phpunit] fixed support for PHP 5.3 Response prepare method update [Workflow] Added missing license header Check if Client exists when test.client does not exist, to provide clearer exception message [Form] Preventing validation of children if parent with Valid constraint has no validation groups [Tests] fixed compatbility of assertEquals(): void [Intl] Fix test [Validator] Add the missing translations for the Arabic (ar) locale [Intl] Add compile binary [Form] Fixed some phpdocs
2 parents b296860 + 9dad29d commit 7e5dfcf
Copy full SHA for 7e5dfcf

17 files changed

+152-68Lines changed: 152 additions & 68 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Symfony/Bridge/PhpUnit/bin/simple-phpunit‎

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ if ('phpdbg' === PHP_SAPI) {
7474
$PHP .= ' -qrr';
7575
}
7676

77-
$defaultEnvs = [
77+
$defaultEnvs = array(
7878
'COMPOSER' => 'composer.json',
7979
'COMPOSER_VENDOR_DIR' => 'vendor',
8080
'COMPOSER_BIN_DIR' => 'bin',
81-
];
81+
);
8282

8383
foreach ($defaultEnvs as $envName => $envValue) {
8484
if ($envValue !== getenv($envName)) {
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ protected static function createClient(array $options = [], array $server = [])
3636
try {
3737
$client = $kernel->getContainer()->get('test.client');
3838
} catch (ServiceNotFoundException $e) {
39-
throw new \LogicException('You cannot create the client used in functional tests if the BrowserKit component is not available. Try running "composer require symfony/browser-kit".');
39+
if (class_exists(Client::class)) {
40+
throw new \LogicException('You cannot create the client used in functional tests if the "framework.test" config is not set to true.');
41+
}
42+
throw new \LogicException('You cannot create the client used in functional tests if the BrowserKit component is not available. Try running "composer require symfony/browser-kit"');
4043
}
4144

4245
$client->setServerParameters($server);
Collapse file

‎src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
* A list of choices with arbitrary data types.
1616
*
1717
* The user of this class is responsible for assigning string values to the
18-
* choices. Both the choices and their values are passed to the constructor.
19-
* Each choice must have a corresponding value (with the same array key) in
20-
* the value array.
18+
* choices annd for their uniqueness.
19+
* Both the choices and their values are passed to the constructor.
20+
* Each choice must have a corresponding value (with the same key) in
21+
* the values array.
2122
*
2223
* @author Bernhard Schussek <bschussek@gmail.com>
2324
*/
@@ -43,12 +44,6 @@ class ArrayChoiceList implements ChoiceListInterface
4344
* @var int[]|string[]
4445
*/
4546
protected $originalKeys;
46-
47-
/**
48-
* The callback for creating the value for a choice.
49-
*
50-
* @var callable
51-
*/
5247
protected $valueCallback;
5348

5449
/**
@@ -212,6 +207,8 @@ protected function flatten(array $choices, $value, &$choicesByValues, &$keysByVa
212207
/**
213208
* Checks whether the given choices can be cast to strings without
214209
* generating duplicates.
210+
* This method is responsible for preventing conflict between scalar values
211+
* and the empty value.
215212
*
216213
* @param array $choices The choices
217214
* @param array|null $cache The cache for previously checked entries. Internal
@@ -232,6 +229,7 @@ private function castableToString(array $choices, array &$cache = [])
232229
return false;
233230
}
234231

232+
// prevent having false casted to the empty string by isset()
235233
$choice = false === $choice ? '0' : (string) $choice;
236234

237235
if (isset($cache[$choice])) {
Collapse file

‎src/Symfony/Component/Form/ChoiceList/ChoiceListInterface.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/ChoiceListInterface.php
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,25 @@ public function getChoices();
3535
/**
3636
* Returns the values for the choices.
3737
*
38-
* The values are strings that do not contain duplicates.
38+
* The values are strings that do not contain duplicates:
39+
*
40+
* $form->add('field', 'choice', [
41+
* 'choices' => [
42+
* 'Decided' => ['Yes' => true, 'No' => false],
43+
* 'Undecided' => ['Maybe' => null],
44+
* ],
45+
* ]);
46+
*
47+
* In this example, the result of this method is:
48+
*
49+
* [
50+
* 'Yes' => '0',
51+
* 'No' => '1',
52+
* 'Maybe' => '2',
53+
* ]
54+
*
55+
* Null and false MUST NOT conflict when being casted to string.
56+
* For this some default incremented values SHOULD be computed.
3957
*
4058
* @return string[] The choice values
4159
*/
@@ -62,6 +80,12 @@ public function getValues();
6280
* 'Undecided' => ['Maybe' => '2'],
6381
* ]
6482
*
83+
* Nested arrays do not make sense in a view format unless
84+
* they are used as a convenient way of grouping.
85+
* If the implementation does not intend to support grouped choices,
86+
* this method SHOULD be equivalent to {@link getValues()}.
87+
* The $groupBy callback parameter SHOULD be used instead.
88+
*
6589
* @return string[] The choice values
6690
*/
6791
public function getStructuredValues();
Collapse file

‎src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ interface ChoiceListFactoryInterface
2828
* The choices should be passed in the values of the choices array.
2929
*
3030
* Optionally, a callable can be passed for generating the choice values.
31-
* The callable receives the choice as first and the array key as the second
32-
* argument.
31+
* The callable receives the choice as only argument.
32+
* Null may be passed when the choice list contains the empty value.
3333
*
3434
* @param iterable $choices The choices
3535
* @param callable|null $value The callable generating the choice
@@ -43,8 +43,8 @@ public function createListFromChoices($choices, $value = null);
4343
* Creates a choice list that is loaded with the given loader.
4444
*
4545
* Optionally, a callable can be passed for generating the choice values.
46-
* The callable receives the choice as first and the array key as the second
47-
* argument.
46+
* The callable receives the choice as only argument.
47+
* Null may be passed when the choice list contains the empty value.
4848
*
4949
* @param ChoiceLoaderInterface $loader The choice loader
5050
* @param callable|null $value The callable generating the choice
Collapse file

‎src/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ interface ChoiceLoaderInterface
2828
* Loads a list of choices.
2929
*
3030
* Optionally, a callable can be passed for generating the choice values.
31-
* The callable receives the choice as first and the array key as the second
32-
* argument.
31+
* The callable receives the choice as only argument.
32+
* Null may be passed when the choice list contains the empty value.
3333
*
3434
* @param callable|null $value The callable which generates the values
3535
* from choices
@@ -45,8 +45,8 @@ public function loadChoiceList($value = null);
4545
* corresponding values in the given array.
4646
*
4747
* Optionally, a callable can be passed for generating the choice values.
48-
* The callable receives the choice as first and the array key as the second
49-
* argument.
48+
* The callable receives the choice as only argument.
49+
* Null may be passed when the choice list contains the empty value.
5050
*
5151
* @param string[] $values An array of choice values. Non-existing
5252
* values in this array are ignored
@@ -63,8 +63,8 @@ public function loadChoicesForValues(array $values, $value = null);
6363
* corresponding choices in the given array.
6464
*
6565
* Optionally, a callable can be passed for generating the choice values.
66-
* The callable receives the choice as first and the array key as the second
67-
* argument.
66+
* The callable receives the choice as only argument.
67+
* Null may be passed when the choice list contains the empty value.
6868
*
6969
* @param array $choices An array of choices. Non-existing choices in
7070
* this array are ignored
Collapse file

‎src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public function validate($form, Constraint $formConstraint)
4444
if ($form->isSubmitted() && $form->isSynchronized()) {
4545
// Validate the form data only if transformation succeeded
4646
$groups = self::getValidationGroups($form);
47+
48+
if (!$groups) {
49+
return;
50+
}
51+
4752
$data = $form->getData();
4853

4954
// Validate the data against its own constraints
Collapse file

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer;
16+
use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait;
1617

1718
class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase
1819
{
19-
public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
20-
{
21-
if ($expected instanceof \DateTime && $actual instanceof \DateTime) {
22-
$expected = $expected->format('c');
23-
$actual = $actual->format('c');
24-
}
25-
26-
parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
27-
}
20+
use DateTimeEqualsTrait;
2821

2922
public function transformProvider()
3023
{
@@ -95,7 +88,7 @@ public function testReverseTransform($toTz, $fromTz, $to, $from)
9588
$transformer = new DateTimeToHtml5LocalDateTimeTransformer($toTz, $fromTz);
9689

9790
if (null !== $to) {
98-
$this->assertEquals(new \DateTime($to), $transformer->reverseTransform($from));
91+
$this->assertDateTimeEquals(new \DateTime($to), $transformer->reverseTransform($from));
9992
} else {
10093
$this->assertNull($transformer->reverseTransform($from));
10194
}
Collapse file

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
+13-20Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer;
16+
use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait;
1617
use Symfony\Component\Intl\Util\IntlTestHelper;
1718

1819
class DateTimeToLocalizedStringTransformerTest extends TestCase
1920
{
21+
use DateTimeEqualsTrait;
22+
2023
protected $dateTime;
2124
protected $dateTimeWithoutSeconds;
2225

@@ -39,16 +42,6 @@ protected function tearDown()
3942
$this->dateTimeWithoutSeconds = null;
4043
}
4144

42-
public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
43-
{
44-
if ($expected instanceof \DateTime && $actual instanceof \DateTime) {
45-
$expected = $expected->format('c');
46-
$actual = $actual->format('c');
47-
}
48-
49-
parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
50-
}
51-
5245
public function dataProvider()
5346
{
5447
return [
@@ -152,7 +145,7 @@ public function testReverseTransformWithNoConstructorParameters()
152145

153146
$dateTime = new \DateTime('2010-02-03 04:05');
154147

155-
$this->assertEquals(
148+
$this->assertDateTimeEquals(
156149
$dateTime->format('c'),
157150
$transformer->reverseTransform('03.02.2010, 04:05')->format('c')
158151
);
@@ -217,14 +210,14 @@ public function testReverseTransform($dateFormat, $timeFormat, $pattern, $input,
217210

218211
$output = new \DateTime($output);
219212

220-
$this->assertEquals($output, $transformer->reverseTransform($input));
213+
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
221214
}
222215

223216
public function testReverseTransformFullTime()
224217
{
225218
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);
226219

227-
$this->assertEquals($this->dateTime, $transformer->reverseTransform('03.02.2010, 04:05:06 GMT+00:00'));
220+
$this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('03.02.2010, 04:05:06 GMT+00:00'));
228221
}
229222

230223
public function testReverseTransformFromDifferentLocale()
@@ -233,7 +226,7 @@ public function testReverseTransformFromDifferentLocale()
233226

234227
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
235228

236-
$this->assertEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM'));
229+
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM'));
237230
}
238231

239232
public function testReverseTransformWithDifferentTimezones()
@@ -243,7 +236,7 @@ public function testReverseTransformWithDifferentTimezones()
243236
$dateTime = new \DateTime('2010-02-03 04:05:00 Asia/Hong_Kong');
244237
$dateTime->setTimezone(new \DateTimeZone('America/New_York'));
245238

246-
$this->assertEquals($dateTime, $transformer->reverseTransform('03.02.2010, 04:05'));
239+
$this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010, 04:05'));
247240
}
248241

249242
public function testReverseTransformOnlyDateWithDifferentTimezones()
@@ -252,21 +245,21 @@ public function testReverseTransformOnlyDateWithDifferentTimezones()
252245

253246
$dateTime = new \DateTime('2017-01-10 11:00', new \DateTimeZone('Europe/Berlin'));
254247

255-
$this->assertEquals($dateTime, $transformer->reverseTransform('2017-01-10'));
248+
$this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('2017-01-10'));
256249
}
257250

258251
public function testReverseTransformWithDifferentPatterns()
259252
{
260253
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss');
261254

262-
$this->assertEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
255+
$this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
263256
}
264257

265258
public function testReverseTransformDateOnlyWithDstIssue()
266259
{
267260
$transformer = new DateTimeToLocalizedStringTransformer('Europe/Rome', 'Europe/Rome', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'dd/MM/yyyy');
268261

269-
$this->assertEquals(
262+
$this->assertDateTimeEquals(
270263
new \DateTime('1978-05-28', new \DateTimeZone('Europe/Rome')),
271264
$transformer->reverseTransform('28/05/1978')
272265
);
@@ -276,7 +269,7 @@ public function testReverseTransformDateOnlyWithDstIssueAndEscapedText()
276269
{
277270
$transformer = new DateTimeToLocalizedStringTransformer('Europe/Rome', 'Europe/Rome', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, "'day': dd 'month': MM 'year': yyyy");
278271

279-
$this->assertEquals(
272+
$this->assertDateTimeEquals(
280273
new \DateTime('1978-05-28', new \DateTimeZone('Europe/Rome')),
281274
$transformer->reverseTransform('day: 28 month: 05 year: 1978')
282275
);
@@ -314,7 +307,7 @@ public function testReverseTransformWithNonExistingDate()
314307
{
315308
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT);
316309

317-
$this->assertEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
310+
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
318311
}
319312

320313
/**
Collapse file

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php
+4-11Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer;
16+
use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait;
1617

1718
class DateTimeToRfc3339TransformerTest extends TestCase
1819
{
20+
use DateTimeEqualsTrait;
21+
1922
protected $dateTime;
2023
protected $dateTimeWithoutSeconds;
2124

@@ -33,16 +36,6 @@ protected function tearDown()
3336
$this->dateTimeWithoutSeconds = null;
3437
}
3538

36-
public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
37-
{
38-
if ($expected instanceof \DateTime && $actual instanceof \DateTime) {
39-
$expected = $expected->format('c');
40-
$actual = $actual->format('c');
41-
}
42-
43-
parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
44-
}
45-
4639
public function allProvider()
4740
{
4841
return [
@@ -108,7 +101,7 @@ public function testReverseTransform($toTz, $fromTz, $to, $from)
108101
$transformer = new DateTimeToRfc3339Transformer($toTz, $fromTz);
109102

110103
if (null !== $to) {
111-
$this->assertEquals(new \DateTime($to), $transformer->reverseTransform($from));
104+
$this->assertDateTimeEquals(new \DateTime($to), $transformer->reverseTransform($from));
112105
} else {
113106
$this->assertNull($transformer->reverseTransform($from));
114107
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.