Merge branch '5.2' into 5.x
* 5.2: remove unneeded sprintf() call Fix CS Fix config merging in lock keep trailing newlines when dumping multi-line strings disable error bubbling by default when inherit_data is configured
This commit is contained in:
commit
13cfc00c77
@ -1135,6 +1135,8 @@ class Configuration implements ConfigurationInterface
|
||||
->fixXmlConfig('resource')
|
||||
->children()
|
||||
->arrayNode('resources')
|
||||
->normalizeKeys(false)
|
||||
->useAttributeAsKey('name')
|
||||
->requiresAtLeastOneElement()
|
||||
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
|
||||
->beforeNormalization()
|
||||
@ -1157,6 +1159,7 @@ class Configuration implements ConfigurationInterface
|
||||
})
|
||||
->end()
|
||||
->prototype('array')
|
||||
->performNoDeepMerging()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -232,6 +232,34 @@ class ConfigurationTest extends TestCase
|
||||
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||
}
|
||||
|
||||
public function testLockMergeConfigs()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$config = $processor->processConfiguration($configuration, [
|
||||
[
|
||||
'lock' => [
|
||||
'payload' => 'flock',
|
||||
],
|
||||
],
|
||||
[
|
||||
'lock' => [
|
||||
'payload' => 'semaphore',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'enabled' => true,
|
||||
'resources' => [
|
||||
'payload' => ['semaphore'],
|
||||
],
|
||||
],
|
||||
$config['lock']
|
||||
);
|
||||
}
|
||||
|
||||
public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus()
|
||||
{
|
||||
$expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';
|
||||
|
@ -172,7 +172,7 @@ class FormType extends BaseType
|
||||
// For any form that is not represented by a single HTML control,
|
||||
// errors should bubble up by default
|
||||
$errorBubbling = function (Options $options) {
|
||||
return $options['compound'];
|
||||
return $options['compound'] && !$options['inherit_data'];
|
||||
};
|
||||
|
||||
// If data is given, the form is locked to that data
|
||||
|
@ -518,6 +518,16 @@ class FormTypeTest extends BaseTypeTest
|
||||
$this->assertTrue($form->getConfig()->getErrorBubbling());
|
||||
}
|
||||
|
||||
public function testErrorBubblingForCompoundFieldsIsDisabledByDefaultIfInheritDataIsEnabled()
|
||||
{
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, [
|
||||
'compound' => true,
|
||||
'inherit_data' => true,
|
||||
]);
|
||||
|
||||
$this->assertFalse($form->getConfig()->getErrorBubbling());
|
||||
}
|
||||
|
||||
public function testPropertyPath()
|
||||
{
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, [
|
||||
@ -735,6 +745,28 @@ class FormTypeTest extends BaseTypeTest
|
||||
|
||||
$this->assertEquals(['%parent_param%' => 'parent_value', '%override_param%' => 'child_value'], $view['child']->vars['help_translation_parameters']);
|
||||
}
|
||||
|
||||
public function testErrorBubblingDoesNotSkipCompoundFieldsWithInheritDataConfigured()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('form', self::TESTED_TYPE)
|
||||
->add(
|
||||
$this->factory->createNamedBuilder('inherit_data_type', self::TESTED_TYPE, null, [
|
||||
'inherit_data' => true,
|
||||
])
|
||||
->add('child', self::TESTED_TYPE, [
|
||||
'compound' => false,
|
||||
'error_bubbling' => true,
|
||||
])
|
||||
)
|
||||
->getForm();
|
||||
$error = new FormError('error message');
|
||||
$form->get('inherit_data_type')->get('child')->addError($error);
|
||||
|
||||
$this->assertCount(0, $form->getErrors());
|
||||
$this->assertCount(1, $form->get('inherit_data_type')->getErrors());
|
||||
$this->assertSame($error, $form->get('inherit_data_type')->getErrors()[0]);
|
||||
$this->assertCount(0, $form->get('inherit_data_type')->get('child')->getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
class Money
|
||||
|
@ -425,7 +425,7 @@ class PropertyAccessor implements PropertyAccessorInterface
|
||||
if (__FILE__ === $trace['file']
|
||||
&& $name === $trace['function']
|
||||
&& $object instanceof $trace['class']
|
||||
&& preg_match((sprintf('/Return value (?:of .*::\w+\(\) )?must be of (?:the )?type (\w+), null returned$/')), $e->getMessage(), $matches)
|
||||
&& preg_match('/Return value (?:of .*::\w+\(\) )?must be of (?:the )?type (\w+), null returned$/', $e->getMessage(), $matches)
|
||||
) {
|
||||
throw new UninitializedPropertyException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Did you forget to initialize a property or to make the return type nullable using "?%3$s"?', false === strpos(\get_class($object), "@anonymous\0") ? \get_class($object) : (get_parent_class($object) ?: key(class_implements($object)) ?: 'class').'@anonymous', $name, $matches[1]), 0, $e);
|
||||
}
|
||||
|
@ -72,11 +72,24 @@ class Dumper
|
||||
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
||||
$blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';
|
||||
$output .= sprintf('%s%s%s |%s-', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator);
|
||||
|
||||
if (isset($value[-2]) && "\n" === $value[-2] && "\n" === $value[-1]) {
|
||||
$blockChompingIndicator = '+';
|
||||
} elseif ("\n" === $value[-1]) {
|
||||
$blockChompingIndicator = '';
|
||||
} else {
|
||||
$blockChompingIndicator = '-';
|
||||
}
|
||||
|
||||
$output .= sprintf('%s%s%s |%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator, $blockChompingIndicator);
|
||||
|
||||
foreach (explode("\n", $value) as $row) {
|
||||
if ('' === $row) {
|
||||
$output .= "\n";
|
||||
} else {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ YAML;
|
||||
], 4, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
|
||||
}
|
||||
|
||||
public function testNoTrailingNewlineWhenDumpingAsMultiLineLiteralBlock()
|
||||
public function testNoExtraTrailingNewlineWhenDumpingAsMultiLineLiteralBlock()
|
||||
{
|
||||
$data = [
|
||||
"a\nb",
|
||||
@ -579,6 +579,44 @@ YAML;
|
||||
$this->assertSame($data, Yaml::parse($yaml));
|
||||
}
|
||||
|
||||
public function testDumpTrailingNewlineInMultiLineLiteralBlocks()
|
||||
{
|
||||
$data = [
|
||||
'clip 1' => "one\ntwo\n",
|
||||
'clip 2' => "one\ntwo\n",
|
||||
'keep 1' => "one\ntwo\n",
|
||||
'keep 2' => "one\ntwo\n\n",
|
||||
'strip 1' => "one\ntwo",
|
||||
'strip 2' => "one\ntwo",
|
||||
];
|
||||
$yaml = $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
|
||||
|
||||
$expected = <<<YAML
|
||||
'clip 1': |
|
||||
one
|
||||
two
|
||||
'clip 2': |
|
||||
one
|
||||
two
|
||||
'keep 1': |
|
||||
one
|
||||
two
|
||||
'keep 2': |+
|
||||
one
|
||||
two
|
||||
|
||||
'strip 1': |-
|
||||
one
|
||||
two
|
||||
'strip 2': |-
|
||||
one
|
||||
two
|
||||
YAML;
|
||||
|
||||
$this->assertSame($expected, $yaml);
|
||||
$this->assertSame($data, Yaml::parse($yaml));
|
||||
}
|
||||
|
||||
public function testZeroIndentationThrowsException()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
|
Reference in New Issue
Block a user