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 c3f0bfe

Browse filesBrowse files
Merge branch '2.8' into 3.0
* 2.8: [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/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
2 parents 2a738f1 + f7010ce commit c3f0bfe
Copy full SHA for c3f0bfe

File tree

Expand file treeCollapse file tree

9 files changed

+50
-18
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+50
-18
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
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function testProcess()
3434
$container->setAlias('a_alias', 'a');
3535
$container->setAlias('b_alias', 'b');
3636

37+
$container->setAlias('container', 'service_container');
38+
3739
$this->process($container);
3840

3941
$this->assertTrue($container->has('a'), '->process() does nothing to public definitions.');
@@ -44,6 +46,8 @@ public function testProcess()
4446
'->process() replaces alias to actual.'
4547
);
4648

49+
$this->assertTrue($container->has('container'));
50+
4751
$resolvedFactory = $aDefinition->getFactory(false);
4852
$this->assertSame('b_alias', (string) $resolvedFactory[0]);
4953
}

‎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
@@ -181,6 +181,10 @@ public function reverseTransform($value)
181181
throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like');
182182
}
183183

184+
if (is_int($result) && $result === (int) $float = (float) $result) {
185+
$result = $float;
186+
}
187+
184188
if (false !== $encoding = mb_detect_encoding($value, null, true)) {
185189
$length = mb_strlen($value, $encoding);
186190
$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-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function configureOptions(OptionsResolver $resolver)
346346
$resolver->setAllowedTypes('choice_value', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
347347
$resolver->setAllowedTypes('choice_attr', array('null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
348348
$resolver->setAllowedTypes('preferred_choices', array('array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
349-
$resolver->setAllowedTypes('group_by', array('null', 'array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
349+
$resolver->setAllowedTypes('group_by', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath'));
350350
}
351351

352352
/**
@@ -429,12 +429,6 @@ private function createChoiceList(array $options)
429429

430430
private function createChoiceListView(ChoiceListInterface $choiceList, array $options)
431431
{
432-
// If no explicit grouping information is given, use the structural
433-
// information from the "choices" option for creating groups
434-
if (!$options['group_by'] && $options['choices']) {
435-
$options['group_by'] = $options['choices'];
436-
}
437-
438432
return $this->choiceListFactory->createView(
439433
$choiceList,
440434
$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
*/
@@ -90,6 +90,9 @@ public static function validateInput($caller, $input)
9090
if (is_resource($input)) {
9191
return $input;
9292
}
93+
if (is_string($input)) {
94+
return $input;
95+
}
9396
if (is_scalar($input)) {
9497
return (string) $input;
9598
}

‎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.