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 44aa362

Browse filesBrowse files
author
Robin Chalas
committed
Merge branch '4.2'
* 4.2: Ensure final input of CommandTester works with default Do not risk waiting 100 seconds [Intl] handle null date and time types Revert "minor #28610 [Form] Check for Intl availibility (ro0NL)" Do not ignore the choice groups for caching
2 parents b948d5a + b594ad6 commit 44aa362
Copy full SHA for 44aa362

File tree

Expand file treeCollapse file tree

11 files changed

+76
-79
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+76
-79
lines changed

‎src/Symfony/Component/Console/Tester/TesterTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tester/TesterTrait.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ private static function createStream(array $inputs)
162162
{
163163
$stream = fopen('php://memory', 'r+', false);
164164

165-
fwrite($stream, implode(PHP_EOL, $inputs));
165+
foreach ($inputs as $input) {
166+
fwrite($stream, $input.PHP_EOL);
167+
}
168+
166169
rewind($stream);
167170

168171
return $stream;

‎src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,31 @@ public function testCommandWithInputs()
112112
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
113113
}
114114

115+
public function testCommandWithDefaultInputs()
116+
{
117+
$questions = array(
118+
'What\'s your name?',
119+
'How are you?',
120+
'Where do you come from?',
121+
);
122+
123+
$command = new Command('foo');
124+
$command->setHelperSet(new HelperSet(array(new QuestionHelper())));
125+
$command->setCode(function ($input, $output) use ($questions, $command) {
126+
$helper = $command->getHelper('question');
127+
$helper->ask($input, $output, new Question($questions[0], 'Bobby'));
128+
$helper->ask($input, $output, new Question($questions[1], 'Fine'));
129+
$helper->ask($input, $output, new Question($questions[2], 'France'));
130+
});
131+
132+
$tester = new CommandTester($command);
133+
$tester->setInputs(array('', '', ''));
134+
$tester->execute(array());
135+
136+
$this->assertEquals(0, $tester->getStatusCode());
137+
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
138+
}
139+
115140
/**
116141
* @expectedException \RuntimeException
117142
* @expectedMessage Aborted

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php
+1-30Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,6 @@ public static function generateHash($value, $namespace = '')
6262
return hash('sha256', $namespace.':'.serialize($value));
6363
}
6464

65-
/**
66-
* Flattens an array into the given output variable.
67-
*
68-
* @param array $array The array to flatten
69-
* @param array $output The flattened output
70-
*
71-
* @internal
72-
*/
73-
private static function flatten(array $array, &$output)
74-
{
75-
if (null === $output) {
76-
$output = array();
77-
}
78-
79-
foreach ($array as $key => $value) {
80-
if (\is_array($value)) {
81-
self::flatten($value, $output);
82-
continue;
83-
}
84-
85-
$output[$key] = $value;
86-
}
87-
}
88-
8965
public function __construct(ChoiceListFactoryInterface $decoratedFactory)
9066
{
9167
$this->decoratedFactory = $decoratedFactory;
@@ -113,12 +89,7 @@ public function createListFromChoices($choices, $value = null)
11389
// The value is not validated on purpose. The decorated factory may
11490
// decide which values to accept and which not.
11591

116-
// We ignore the choice groups for caching. If two choice lists are
117-
// requested with the same choices, but a different grouping, the same
118-
// choice list is returned.
119-
self::flatten($choices, $flatChoices);
120-
121-
$hash = self::generateHash(array($flatChoices, $value), 'fromChoices');
92+
$hash = self::generateHash(array($choices, $value), 'fromChoices');
12293

12394
if (!isset($this->lists[$hash])) {
12495
$this->lists[$hash] = $this->decoratedFactory->createListFromChoices($choices, $value);

‎src/Symfony/Component/Form/Extension/Core/Type/CountryType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/CountryType.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

‎src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

‎src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

‎src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

‎src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,24 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
6464
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
6565
}
6666

67-
public function testCreateFromChoicesFlattensChoices()
67+
public function testCreateFromChoicesGroupedChoices()
6868
{
6969
$choices1 = array('key' => array('A' => 'a'));
7070
$choices2 = array('A' => 'a');
71-
$list = new \stdClass();
71+
$list1 = new \stdClass();
72+
$list2 = new \stdClass();
7273

73-
$this->decoratedFactory->expects($this->once())
74+
$this->decoratedFactory->expects($this->at(0))
7475
->method('createListFromChoices')
7576
->with($choices1)
76-
->will($this->returnValue($list));
77+
->will($this->returnValue($list1));
78+
$this->decoratedFactory->expects($this->at(1))
79+
->method('createListFromChoices')
80+
->with($choices2)
81+
->will($this->returnValue($list2));
7782

78-
$this->assertSame($list, $this->factory->createListFromChoices($choices1));
79-
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
83+
$this->assertSame($list1, $this->factory->createListFromChoices($choices1));
84+
$this->assertSame($list2, $this->factory->createListFromChoices($choices2));
8085
}
8186

8287
/**

‎src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ class IntlDateFormatter
118118
private $timeZoneId;
119119

120120
/**
121-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
122-
* @param int $datetype Type of date formatting, one of the format type constants
123-
* @param int $timetype Type of time formatting, one of the format type constants
124-
* @param mixed $timezone Timezone identifier
125-
* @param int $calendar Calendar to use for formatting or parsing. The only currently
126-
* supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN")
127-
* @param string $pattern Optional pattern to use when formatting
121+
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
122+
* @param int|null $datetype Type of date formatting, one of the format type constants
123+
* @param int|null $timetype Type of time formatting, one of the format type constants
124+
* @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier
125+
* @param int $calendar Calendar to use for formatting or parsing. The only currently
126+
* supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN")
127+
* @param string|null $pattern Optional pattern to use when formatting
128128
*
129129
* @see http://www.php.net/manual/en/intldateformatter.create.php
130130
* @see http://userguide.icu-project.org/formatparse/datetime
@@ -142,8 +142,8 @@ public function __construct(?string $locale, int $datetype, int $timetype, $time
142142
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
143143
}
144144

145-
$this->datetype = $datetype;
146-
$this->timetype = $timetype;
145+
$this->datetype = null !== $datetype ? $datetype : self::FULL;
146+
$this->timetype = null !== $timetype ? $timetype : self::FULL;
147147

148148
$this->setPattern($pattern);
149149
$this->setTimeZone($timezone);
@@ -152,13 +152,13 @@ public function __construct(?string $locale, int $datetype, int $timetype, $time
152152
/**
153153
* Static constructor.
154154
*
155-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
156-
* @param int $datetype Type of date formatting, one of the format type constants
157-
* @param int $timetype Type of time formatting, one of the format type constants
158-
* @param string $timezone Timezone identifier
159-
* @param int $calendar Calendar to use for formatting or parsing; default is Gregorian
160-
* One of the calendar constants
161-
* @param string $pattern Optional pattern to use when formatting
155+
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
156+
* @param int|null $datetype Type of date formatting, one of the format type constants
157+
* @param int|null $timetype Type of time formatting, one of the format type constants
158+
* @param \IntlTimeZone|\DateTimeZone|string|null $timezone Timezone identifier
159+
* @param int $calendar Calendar to use for formatting or parsing; default is Gregorian
160+
* One of the calendar constants
161+
* @param string|null $pattern Optional pattern to use when formatting
162162
*
163163
* @return self
164164
*
@@ -485,7 +485,7 @@ public function setLenient($lenient)
485485
/**
486486
* Set the formatter's pattern.
487487
*
488-
* @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
488+
* @param string|null $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
489489
*
490490
* @return bool true on success or false on failure
491491
*
@@ -506,9 +506,9 @@ public function setPattern($pattern)
506506
/**
507507
* Set the formatter's timezone identifier.
508508
*
509-
* @param string $timeZoneId The time zone ID string of the time zone to use.
510-
* If NULL or the empty string, the default time zone for the
511-
* runtime is used.
509+
* @param string|null $timeZoneId The time zone ID string of the time zone to use.
510+
* If NULL or the empty string, the default time zone for the
511+
* runtime is used.
512512
*
513513
* @return bool true on success or false on failure
514514
*
@@ -552,7 +552,7 @@ public function setTimeZoneId($timeZoneId)
552552
/**
553553
* This method was added in PHP 5.5 as replacement for `setTimeZoneId()`.
554554
*
555-
* @param mixed $timeZone
555+
* @param \IntlTimeZone|\DateTimeZone|string|null $timeZone
556556
*
557557
* @return bool true on success or false on failure
558558
*

‎src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ public function testConstructorDefaultTimeZone()
4646
);
4747
}
4848

49+
public function testConstructorWithoutDateType()
50+
{
51+
$formatter = new IntlDateFormatter('en', null, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN);
52+
53+
$this->assertSame('EEEE, LLLL d, y, h:mm a', $formatter->getPattern());
54+
}
55+
56+
public function testConstructorWithoutTimeType()
57+
{
58+
$formatter = new IntlDateFormatter('en', IntlDateFormatter::SHORT, null, 'UTC', IntlDateFormatter::GREGORIAN);
59+
60+
$this->assertSame('M/d/yy, h:mm:ss a zzzz', $formatter->getPattern());
61+
}
62+
4963
/**
5064
* @dataProvider formatProvider
5165
*/

‎src/Symfony/Component/Process/Tests/KillableProcessWithOutput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/KillableProcessWithOutput.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
'Second iteration output',
1515
'One more iteration output',
1616
'This took more time',
17-
'This one was sooooo slow',
1817
);
1918

2019
$iterationTime = 10000;

0 commit comments

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