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 f7010ce

Browse filesBrowse files
Merge branch '2.7' into 2.8
* 2.7: [Process] Fix stream_select priority when writing to stdin [Form] NumberToLocalizedStringTransformer should return floats when possible [Form] remove useless code in ChoiceType [DependencyInjection] Enabled alias for service_container Conflicts: src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php
2 parents 8ca43b0 + 2f2ce3e commit f7010ce
Copy full SHA for f7010ce

File tree

Expand file treeCollapse file tree

9 files changed

+49
-35
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+49
-35
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function process(ContainerBuilder $container)
4242
foreach ($container->getAliases() as $id => $alias) {
4343
$aliasId = (string) $alias;
4444

45+
if ('service_container' === $aliasId) {
46+
continue;
47+
}
48+
4549
try {
4650
$definition = $container->getDefinition($aliasId);
4751
} catch (InvalidArgumentException $e) {

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function testProcess()
3636
$container->setAlias('a_alias', 'a');
3737
$container->setAlias('b_alias', 'b');
3838

39+
$container->setAlias('container', 'service_container');
40+
3941
$this->process($container);
4042

4143
$this->assertTrue($container->has('a'), '->process() does nothing to public definitions.');
@@ -47,6 +49,7 @@ public function testProcess()
4749
);
4850

4951
$this->assertSame('b_alias', $aDefinition->getFactoryService(false));
52+
$this->assertTrue($container->has('container'));
5053

5154
$resolvedFactory = $aDefinition->getFactory(false);
5255
$this->assertSame('b_alias', (string) $resolvedFactory[0]);

‎src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ public function reverseTransform($value)
205205
throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like');
206206
}
207207

208+
if (is_int($result) && $result === (int) $float = (float) $result) {
209+
$result = $float;
210+
}
211+
208212
if (false !== $encoding = mb_detect_encoding($value, null, true)) {
209213
$length = mb_strlen($value, $encoding);
210214
$remainder = mb_substr($value, $position, $length, $encoding);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+1-24Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public function configureOptions(OptionsResolver $resolver)
429429
$resolver->setAllowedTypes('choice_value', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
430430
$resolver->setAllowedTypes('choice_attr', array('null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
431431
$resolver->setAllowedTypes('preferred_choices', array('array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
432-
$resolver->setAllowedTypes('group_by', array('null', 'array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
432+
$resolver->setAllowedTypes('group_by', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
433433
}
434434

435435
/**
@@ -448,21 +448,6 @@ public function getBlockPrefix()
448448
return 'choice';
449449
}
450450

451-
private static function flipRecursive($choices, &$output = array())
452-
{
453-
foreach ($choices as $key => $value) {
454-
if (is_array($value)) {
455-
$output[$key] = array();
456-
self::flipRecursive($value, $output[$key]);
457-
continue;
458-
}
459-
460-
$output[$value] = $key;
461-
}
462-
463-
return $output;
464-
}
465-
466451
/**
467452
* Adds the sub fields for an expanded choice field.
468453
*
@@ -520,14 +505,6 @@ private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $ch
520505

521506
private function createChoiceListView(ChoiceListInterface $choiceList, array $options)
522507
{
523-
// If no explicit grouping information is given, use the structural
524-
// information from the "choices" option for creating groups
525-
if (!$options['group_by'] && $options['choices']) {
526-
$options['group_by'] = !$options['choices_as_values']
527-
? self::flipRecursive($options['choices'])
528-
: $options['choices'];
529-
}
530-
531508
return $this->choiceListFactory->createView(
532509
$choiceList,
533510
$options['preferred_choices'],

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,17 @@ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
637637
$transformer->reverseTransform("12\xc2\xa0345,678foo");
638638
}
639639

640-
public function testReverseTransformBigint()
640+
public function testReverseTransformBigInt()
641641
{
642642
$transformer = new NumberToLocalizedStringTransformer(null, true);
643643

644644
$this->assertEquals(PHP_INT_MAX - 1, (int) $transformer->reverseTransform((string) (PHP_INT_MAX - 1)));
645645
}
646+
647+
public function testReverseTransformSmallInt()
648+
{
649+
$transformer = new NumberToLocalizedStringTransformer(null, true);
650+
651+
$this->assertSame(1.0, $transformer->reverseTransform('1'));
652+
}
646653
}

‎src/Symfony/Component/Process/Pipes/AbstractPipes.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Pipes/AbstractPipes.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ abstract class AbstractPipes implements PipesInterface
2222
public $pipes = array();
2323

2424
/** @var string */
25-
protected $inputBuffer = '';
25+
private $inputBuffer = '';
2626
/** @var resource|null */
27-
protected $input;
28-
27+
private $input;
2928
/** @var bool */
3029
private $blocked = true;
3130

@@ -91,9 +90,8 @@ protected function write()
9190
if (!isset($this->pipes[0])) {
9291
return;
9392
}
94-
95-
$e = array();
96-
$r = null !== $this->input ? array($this->input) : $e;
93+
$input = $this->input;
94+
$r = $e = array();
9795
$w = array($this->pipes[0]);
9896

9997
// let's have a look if something changed in streams
@@ -110,7 +108,7 @@ protected function write()
110108
}
111109
}
112110

113-
foreach ($r as $input) {
111+
if ($input) {
114112
for (;;) {
115113
$data = fread($input, self::CHUNK_SIZE);
116114
if (!isset($data[0])) {
@@ -124,7 +122,7 @@ protected function write()
124122
return array($this->pipes[0]);
125123
}
126124
}
127-
if (!isset($data[0]) && feof($input)) {
125+
if (feof($input)) {
128126
// no more data to read on input resource
129127
// use an empty buffer in the next reads
130128
$this->input = null;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
158158
$this->setEnv($env);
159159
}
160160

161-
$this->input = $input;
161+
$this->setInput($input);
162162
$this->setTimeout($timeout);
163163
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
164164
$this->pty = false;

‎src/Symfony/Component/Process/ProcessUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/ProcessUtils.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function escapeArgument($argument)
8080
* @param string $caller The name of method call that validates the input
8181
* @param mixed $input The input to validate
8282
*
83-
* @return string The validated input
83+
* @return mixed The validated input
8484
*
8585
* @throws InvalidArgumentException In case the input is not valid
8686
*
@@ -92,6 +92,9 @@ public static function validateInput($caller, $input)
9292
if (is_resource($input)) {
9393
return $input;
9494
}
95+
if (is_string($input)) {
96+
return $input;
97+
}
9598
if (is_scalar($input)) {
9699
return (string) $input;
97100
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/ProcessTest.php
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,24 @@ public function testSetStreamAsInput($code, $size)
209209
$this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
210210
}
211211

212+
public function testLiveStreamAsInput()
213+
{
214+
$stream = fopen('php://memory', 'r+');
215+
fwrite($stream, 'hello');
216+
rewind($stream);
217+
218+
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('stream_copy_to_stream(STDIN, STDOUT);')));
219+
$p->setInput($stream);
220+
$p->start(function ($type, $data) use ($stream) {
221+
if ('hello' === $data) {
222+
fclose($stream);
223+
}
224+
});
225+
$p->wait();
226+
227+
$this->assertSame('hello', $p->getOutput());
228+
}
229+
212230
/**
213231
* @expectedException \Symfony\Component\Process\Exception\LogicException
214232
* @expectedExceptionMessage Input can not be set while the process is running.

0 commit comments

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