diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php
index 1a09609b28..2dc8c2cb2b 100644
--- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php
+++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php
@@ -146,7 +146,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
// Optimize performance in case we have an object loader and
// a single-field identifier
- if (!$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
+ if (null === $value && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
$objectsById = array();
$objects = array();
diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
index 0303c355c0..5b12c5bdca 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
@@ -753,6 +753,55 @@ class EntityTypeTest extends TypeTestCase
$this->assertSame('2', $field->getViewData());
}
+ public function testOverrideChoicesValues()
+ {
+ $entity1 = new SingleIntIdEntity(1, 'Foo');
+ $entity2 = new SingleIntIdEntity(2, 'Bar');
+
+ $this->persist(array($entity1, $entity2));
+
+ $field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
+ 'em' => 'default',
+ 'class' => self::SINGLE_IDENT_CLASS,
+ 'choice_label' => 'name',
+ 'choice_value' => 'name',
+ ));
+
+ $field->submit('Bar');
+
+ $this->assertEquals(array('Foo' => new ChoiceView($entity1, 'Foo', 'Foo'), 'Bar' => new ChoiceView($entity2, 'Bar', 'Bar')), $field->createView()->vars['choices']);
+ $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.');
+ $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.');
+ $this->assertSame('Bar', $field->getViewData());
+ }
+
+ public function testOverrideChoicesValuesWithCallable()
+ {
+ $entity1 = new GroupableEntity(1, 'Foo', 'BazGroup');
+ $entity2 = new GroupableEntity(2, 'Bar', 'BooGroup');
+
+ $this->persist(array($entity1, $entity2));
+
+ $field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
+ 'em' => 'default',
+ 'class' => self::ITEM_GROUP_CLASS,
+ 'choice_label' => 'name',
+ 'choice_value' => function (GroupableEntity $entity) {
+ return $entity->groupName.'/'.$entity->name;
+ },
+ ));
+
+ $field->submit('BooGroup/Bar');
+
+ $this->assertEquals(array(
+ 'BazGroup/Foo' => new ChoiceView($entity1, 'BazGroup/Foo', 'Foo'),
+ 'BooGroup/Bar' => new ChoiceView($entity2, 'BooGroup/Bar', 'Bar'),
+ ), $field->createView()->vars['choices']);
+ $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.');
+ $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.');
+ $this->assertSame('BooGroup/Bar', $field->getViewData());
+ }
+
public function testGroupByChoices()
{
$item1 = new GroupableEntity(1, 'Foo', 'Group1');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
index 1a93459074..93fe6f1b31 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -411,17 +411,6 @@ class TextDescriptor extends Descriptor
return trim($configAsString);
}
- /**
- * @param string $section
- * @param string $message
- *
- * @return string
- */
- private function formatSection($section, $message)
- {
- return sprintf('[%s] %s', $section, $message);
- }
-
/**
* @param callable $callable
*
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml
index ec74f1beb8..73cd9234e7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml
@@ -1,7 +1,7 @@
framework:
assets:
version: SomeVersionScheme
- version_format: %%s?version=%%s
+ version_format: '%%s?version=%%s'
base_urls: http://cdn.example.com
packages:
images_path:
@@ -11,7 +11,7 @@ framework:
base_urls: ["http://images1.example.com", "http://images2.example.com"]
foo:
version: 1.0.0
- version_format: %%s-%%s
+ version_format: '%%s-%%s'
bar:
base_urls: ["https://bar2.example.com"]
bar_version_strategy:
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
index 1c49d145f1..64bb38cb44 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
@@ -13,7 +13,7 @@ framework:
only_exceptions: true
enabled: false
router:
- resource: %kernel.root_dir%/config/routing.xml
+ resource: '%kernel.root_dir%/config/routing.xml'
type: xml
session:
storage_id: session.storage.native
@@ -48,7 +48,7 @@ framework:
annotations:
cache: file
debug: true
- file_cache_dir: %kernel.cache_dir%/annotations
+ file_cache_dir: '%kernel.cache_dir%/annotations'
serializer:
enabled: true
enable_annotations: true
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml
index 861b1e709f..61c1a54d99 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml
@@ -3,5 +3,5 @@ framework:
# Twig Configuration
twig:
- debug: %kernel.debug%
- strict_variables: %kernel.debug%
+ debug: '%kernel.debug%'
+ strict_variables: '%kernel.debug%'
diff --git a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
index dc25fcbd26..5d3ff014f1 100644
--- a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
+++ b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
@@ -31,8 +31,8 @@ class EnumNodeDefinition extends ScalarNodeDefinition
{
$values = array_unique($values);
- if (count($values) <= 1) {
- throw new \InvalidArgumentException('->values() must be called with at least two distinct values.');
+ if (empty($values)) {
+ throw new \InvalidArgumentException('->values() must be called with at least one value.');
}
$this->values = $values;
diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php
index 69f7fcfb22..8d7ab2f7f0 100644
--- a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php
+++ b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php
@@ -15,14 +15,22 @@ use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
class EnumNodeDefinitionTest extends \PHPUnit_Framework_TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage ->values() must be called with at least two distinct values.
- */
- public function testNoDistinctValues()
+ public function testWithOneValue()
+ {
+ $def = new EnumNodeDefinition('foo');
+ $def->values(array('foo'));
+
+ $node = $def->getNode();
+ $this->assertEquals(array('foo'), $node->getValues());
+ }
+
+ public function testWithOneDistinctValue()
{
$def = new EnumNodeDefinition('foo');
$def->values(array('foo', 'foo'));
+
+ $node = $def->getNode();
+ $this->assertEquals(array('foo'), $node->getValues());
}
/**
@@ -35,6 +43,16 @@ class EnumNodeDefinitionTest extends \PHPUnit_Framework_TestCase
$def->getNode();
}
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage ->values() must be called with at least one value.
+ */
+ public function testWithNoValues()
+ {
+ $def = new EnumNodeDefinition('foo');
+ $def->values(array());
+ }
+
public function testGetNode()
{
$def = new EnumNodeDefinition('foo');
diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php
index cb870939b1..c8429845a2 100644
--- a/src/Symfony/Component/Console/Command/Command.php
+++ b/src/Symfony/Component/Console/Command/Command.php
@@ -383,7 +383,7 @@ class Command
* @param string $shortcut The shortcut (can be null)
* @param int $mode The option mode: One of the InputOption::VALUE_* constants
* @param string $description A description text
- * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE)
+ * @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
*
* @return Command The current instance
*/
diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php
index 3a752cb700..f08c5f26c1 100644
--- a/src/Symfony/Component/Console/Input/InputOption.php
+++ b/src/Symfony/Component/Console/Input/InputOption.php
@@ -39,7 +39,7 @@ class InputOption
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int $mode The option mode: One of the VALUE_* constants
* @param string $description A description text
- * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)
+ * @param mixed $default The default value (must be null for self::VALUE_NONE)
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*/
diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
index b206bd26ef..aae5460ace 100644
--- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
@@ -18,6 +18,8 @@ use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
+use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\Resource\ResourceInterface;
@@ -398,8 +400,9 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*
* @return object The associated service
*
- * @throws InvalidArgumentException when no definitions are available
- * @throws LogicException when a circular dependency is detected
+ * @throws InvalidArgumentException when no definitions are available
+ * @throws ServiceCircularReferenceException When a circular reference is detected
+ * @throws ServiceNotFoundException When the service is not defined
* @throws \Exception
*
* @see Reference
@@ -418,7 +421,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
try {
$definition = $this->getDefinition($id);
- } catch (InvalidArgumentException $e) {
+ } catch (ServiceNotFoundException $e) {
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
return;
}
@@ -758,14 +761,14 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*
* @return Definition A Definition instance
*
- * @throws InvalidArgumentException if the service definition does not exist
+ * @throws ServiceNotFoundException if the service definition does not exist
*/
public function getDefinition($id)
{
$id = strtolower($id);
if (!array_key_exists($id, $this->definitions)) {
- throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id));
+ throw new ServiceNotFoundException($id);
}
return $this->definitions[$id];
@@ -780,7 +783,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*
* @return Definition A Definition instance
*
- * @throws InvalidArgumentException if the service definition does not exist
+ * @throws ServiceNotFoundException if the service definition does not exist
*/
public function findDefinition($id)
{
diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
index 14c7022cfb..a4569622e6 100644
--- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
@@ -65,7 +65,7 @@ class YamlDumper extends Dumper
$class = substr($class, 1);
}
- $code .= sprintf(" class: %s\n", $class);
+ $code .= sprintf(" class: %s\n", $this->dumper->dump($class));
}
if (!$definition->isPublic()) {
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 927ab1b7dd..87bfd012b3 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -20,6 +20,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
+use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
+use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -49,9 +52,9 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
try {
$builder->getDefinition('baz');
- $this->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
- } catch (\InvalidArgumentException $e) {
- $this->assertEquals('The service definition "baz" does not exist.', $e->getMessage(), '->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
+ $this->fail('->getDefinition() throws a ServiceNotFoundException if the service definition does not exist');
+ } catch (ServiceNotFoundException $e) {
+ $this->assertEquals('You have requested a non-existent service "baz".', $e->getMessage(), '->getDefinition() throws a ServiceNotFoundException if the service definition does not exist');
}
}
@@ -101,9 +104,9 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$builder = new ContainerBuilder();
try {
$builder->get('foo');
- $this->fail('->get() throws an InvalidArgumentException if the service does not exist');
- } catch (\InvalidArgumentException $e) {
- $this->assertEquals('The service definition "foo" does not exist.', $e->getMessage(), '->get() throws an InvalidArgumentException if the service does not exist');
+ $this->fail('->get() throws a ServiceNotFoundException if the service does not exist');
+ } catch (ServiceNotFoundException $e) {
+ $this->assertEquals('You have requested a non-existent service "foo".', $e->getMessage(), '->get() throws a ServiceNotFoundException if the service does not exist');
}
$this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service does not exist and NULL_ON_INVALID_REFERENCE is passed as a second argument');
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
index a2ed68cd0b..321b90a5b5 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
+use Symfony\Component\Yaml\Yaml;
class YamlDumperTest extends \PHPUnit_Framework_TestCase
{
@@ -27,24 +28,21 @@ class YamlDumperTest extends \PHPUnit_Framework_TestCase
{
$dumper = new YamlDumper($container = new ContainerBuilder());
- $this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
-
- $container = new ContainerBuilder();
- $dumper = new YamlDumper($container);
+ $this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
}
public function testAddParameters()
{
$container = include self::$fixturesPath.'/containers/container8.php';
$dumper = new YamlDumper($container);
- $this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters');
+ $this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters');
}
public function testAddService()
{
$container = include self::$fixturesPath.'/containers/container9.php';
$dumper = new YamlDumper($container);
- $this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services');
+ $this->assertEqualYamlStructure(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services');
$dumper = new YamlDumper($container = new ContainerBuilder());
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
@@ -63,4 +61,9 @@ class YamlDumperTest extends \PHPUnit_Framework_TestCase
$dumper = new YamlDumper($container);
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services24.yml', $dumper->dump());
}
+
+ private function assertEqualYamlStructure($yaml, $expected, $message = '')
+ {
+ $this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message);
+ }
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml
index f2f8d953d5..c66084cdbe 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml
@@ -6,4 +6,4 @@ services:
class: BAR
project:
- test: %project.parameter.foo%
+ test: '%project.parameter.foo%'
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml
index db554d7f5f..08a1df1e6b 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml
@@ -2,7 +2,7 @@ services:
foo: { class: FooClass }
baz: { class: BazClass }
not_shared: { class: FooClass, shared: false }
- file: { class: FooClass, file: %path%/foo.php }
+ file: { class: FooClass, file: '%path%/foo.php' }
arguments: { class: FooClass, arguments: [foo, '@foo', [true, false]] }
configurator1: { class: FooClass, configurator: sc_configure }
configurator2: { class: FooClass, configurator: ['@baz', configure] }
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
index 37f7e19516..6efeb37e74 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml
@@ -18,7 +18,7 @@ services:
factory: [Bar\FooClass, getInstance]
configurator: sc_configure
foo.baz:
- class: %baz_class%
+ class: '%baz_class%'
factory: ['%baz_class%', getInstance]
configurator: ['%baz_class%', configureStatic1]
bar:
@@ -26,11 +26,11 @@ services:
arguments: [foo, '@foo.baz', '%foo_bar%']
configurator: ['@foo.baz', configure]
foo_bar:
- class: %foo_class%
+ class: '%foo_class%'
shared: false
method_call1:
class: Bar\FooClass
- file: %path%foo.php
+ file: '%path%foo.php'
calls:
- [setBar, ['@foo']]
- [setBar, ['@?foo2']]
diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
index 197f556308..d8369abfd4 100644
--- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
+++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
@@ -102,10 +102,6 @@ class ResizeFormListener implements EventSubscriberInterface
$form = $event->getForm();
$data = $event->getData();
- if (null === $data || '' === $data) {
- $data = array();
- }
-
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
$data = array();
}
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
index 055391f533..ee56f058cc 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
@@ -210,9 +210,6 @@ class ChoiceType extends AbstractType
$view->vars['placeholder'] = $options['placeholder'];
}
- // BC
- $view->vars['empty_value_in_choices'] = $view->vars['placeholder_in_choices'];
-
if ($options['multiple'] && !$options['expanded']) {
// Add "[]" to the name in case a select tag with multiple options is
// displayed. Otherwise only one of the selected options is sent in the
diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php
index 8ea37bff7a..d3ba9cf7bf 100644
--- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php
+++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php
@@ -148,12 +148,9 @@ class ViolationMapper implements ViolationMapperInterface
*/
private function matchChild(FormInterface $form, PropertyPathIteratorInterface $it)
{
- // Remember at what property path underneath "data"
- // we are looking. Check if there is a child with that
- // path, otherwise increase path by one more piece
+ $target = null;
$chunk = '';
- $foundChild = null;
- $foundAtIndex = 0;
+ $foundAtIndex = null;
// Construct mapping rules for the given form
$rules = array();
@@ -165,17 +162,11 @@ class ViolationMapper implements ViolationMapperInterface
}
}
- // Skip forms inheriting their parent data when iterating the children
- $childIterator = new \RecursiveIteratorIterator(
+ $children = iterator_to_array(new \RecursiveIteratorIterator(
new InheritDataAwareIterator($form)
- );
-
- // Make the path longer until we find a matching child
- while (true) {
- if (!$it->valid()) {
- return;
- }
+ ));
+ while ($it->valid()) {
if ($it->isIndex()) {
$chunk .= '['.$it->current().']';
} else {
@@ -197,33 +188,27 @@ class ViolationMapper implements ViolationMapperInterface
}
}
- // Test children unless we already found one
- if (null === $foundChild) {
- foreach ($childIterator as $child) {
- /* @var FormInterface $child */
- $childPath = (string) $child->getPropertyPath();
-
- // Child found, mark as return value
- if ($chunk === $childPath) {
- $foundChild = $child;
- $foundAtIndex = $it->key();
- }
+ /** @var FormInterface $child */
+ foreach ($children as $key => $child) {
+ $childPath = (string) $child->getPropertyPath();
+ if ($childPath === $chunk) {
+ $target = $child;
+ $foundAtIndex = $it->key();
+ } elseif (0 === strpos($childPath, $chunk)) {
+ continue;
}
+
+ unset($children[$key]);
}
- // Add element to the chunk
$it->next();
-
- // If we reached the end of the path or if there are no
- // more matching mapping rules, return the found child
- if (null !== $foundChild && (!$it->valid() || count($rules) === 0)) {
- // Reset index in case we tried to find mapping
- // rules further down the path
- $it->seek($foundAtIndex);
-
- return $foundChild;
- }
}
+
+ if (null !== $foundAtIndex) {
+ $it->seek($foundAtIndex);
+ }
+
+ return $target;
}
/**
diff --git a/src/Symfony/Component/Form/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Form/Resources/translations/validators.no.xlf
similarity index 100%
rename from src/Symfony/Component/Form/Resources/translations/validators.nb.xlf
rename to src/Symfony/Component/Form/Resources/translations/validators.no.xlf
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
index 0934ef6b36..1dc90e85da 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
@@ -1539,4 +1539,25 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array($this->getFormError($violation, $grandChild)), iterator_to_array($grandChild->getErrors()), $grandChildName.' should have an error, but has none');
}
}
+
+ public function testBacktrackIfSeveralSubFormsWithSamePropertyPath()
+ {
+ $violation = $this->getConstraintViolation('data.address[street]');
+ $parent = $this->getForm('parent');
+ $child1 = $this->getForm('subform1', 'address');
+ $child2 = $this->getForm('subform2', 'address');
+ $grandChild = $this->getForm('street');
+
+ $parent->add($child1);
+ $parent->add($child2);
+ $child2->add($grandChild);
+
+ $this->mapper->mapViolation($violation, $parent);
+
+ // The error occurred on the child of the second form with the same path
+ $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
+ $this->assertCount(0, $child1->getErrors(), $child1->getName().' should not have an error, but has one');
+ $this->assertCount(0, $child2->getErrors(), $child2->getName().' should not have an error, but has one');
+ $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChild->getName().' should have an error, but has none');
+ }
}
diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
index c58270a69a..6d08fdfc68 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
@@ -182,12 +182,7 @@ class NativeSessionStorage implements SessionStorageInterface
public function regenerate($destroy = false, $lifetime = null)
{
// Cannot regenerate the session ID for non-active sessions.
- if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE !== session_status()) {
- return false;
- }
-
- // Check if session ID exists in PHP 5.3
- if (PHP_VERSION_ID < 50400 && '' === session_id()) {
+ if (\PHP_SESSION_ACTIVE !== session_status()) {
return false;
}
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf
deleted file mode 100644
index a8b790c7d8..0000000000
--- a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
-
-
-
-
- Verdien skal være falsk.
-
-
-
- Verdien skal være sann.
-
-
-
- Verdien skal være av typen {{ type }}.
-
-
-
- Verdien skal være blank.
-
-
-
- Verdien skal være en av de gitte valg.
-
-
-
- Du skal velge minst {{ limit }} valg.
-
-
-
- Du kan maks velge {{ limit }} valg.
-
-
-
- En eller flere av de oppgitte verdier er ugyldige.
-
-
-
- Dette feltet ikke var forventet.
-
-
-
- Dette feltet mangler.
-
-
-
- Verdien er ikke en gyldig dato.
-
-
-
- Verdien er ikke en gyldig dato og tid.
-
-
-
- Verdien er ikke en gyldig e-mail adresse.
-
-
-
- Filen kunne ikke finnes.
-
-
-
- Filen kan ikke leses.
-
-
-
- Filen er for stor ({{ size }} {{ suffix }}). Tilatte maksimale størrelse {{ limit }} {{ suffix }}.
-
-
-
- Mimetypen av filen er ugyldig ({{ type }}). Tilatte mimetyper er {{ types }}.
-
-
-
- Verdien skal være {{ limit }} eller mindre.
-
-
-
- Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre.
-
-
-
- Verdien skal være {{ limit }} eller mer.
-
-
-
- Verdien er for kort. Den skal ha {{ limit }} tegn eller flere.
-
-
-
- Verdien må ikke være blank.
-
-
-
- Verdien må ikke være tom (null).
-
-
-
- Verdien skal være tom (null).
-
-
-
- Verdien er ikke gyldig.
-
-
-
- Verdien er ikke en gyldig tid.
-
-
-
- Verdien er ikke en gyldig URL.
-
-
-
- De to verdier skal være ens.
-
-
-
- Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}.
-
-
-
- Filen er for stor.
-
-
-
- Filen kunne ikke lastes opp.
-
-
-
- Denne verdi skal være et gyldig tall.
-
-
-
- Denne filen er ikke et gyldig bilde.
-
-
-
- Dette er ikke en gyldig IP adresse.
-
-
-
- Denne verdi er ikke et gyldig språk.
-
-
-
- Denne verdi er ikke en gyldig lokalitet.
-
-
-
- Denne verdi er ikke et gyldig land.
-
-
-
-
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf
new file mode 100644
index 0000000000..ea01c63ee4
--- /dev/null
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf
@@ -0,0 +1,227 @@
+
+
+
+
+
+
+ Verdien skulle ha vore tom/nei.
+
+
+
+ Verdien skulla ha vore satt/ja.
+
+
+
+ Verdien må vere av typen {{ type }}.
+
+
+
+ Verdien skal vere blank.
+
+
+
+ Verdien du valgte er ikkje gyldig.
+
+
+
+ Du må velge minst {{ limit }} valg.
+
+
+
+ Du kan maksimalt gjere {{ limit }} valg.
+
+
+
+ Ein eller fleire av dei opplyste verdiane er ugyldige.
+
+
+
+ Dette feltet var ikke forventet.
+
+
+
+ Dette feltet mangler.
+
+
+
+ Verdien er ikkje ein gyldig dato.
+
+
+
+ Verdien er ikkje ein gyldig dato og tid.
+
+
+
+ Verdien er ikkje ei gyldig e-postadresse.
+
+
+
+ Fila kunne ikkje finnes.
+
+
+
+ Fila kan ikkje lesast.
+
+
+
+ Fila er for stor ({{ size }} {{ suffix }}). Tillatt maksimal størrelse er {{ limit }} {{ suffix }}.
+
+
+
+ Mime-typen av fila er ugyldig ({{ type }}). Tillatte mime-typar er {{ types }}.
+
+
+
+ Verdien må vere {{ limit }} eller mindre.
+
+
+
+ Verdien er for lang. Den må vere {{ limit }} bokstavar eller mindre.
+
+
+
+ Verdien må vere {{ limit }} eller meir.
+
+
+
+ Verdien er for kort. Den må ha {{ limit }} teikn eller fleire.
+
+
+
+ Verdien må ikkje vere blank.
+
+
+
+ Verdien må ikkje vere tom (null).
+
+
+
+ Verdien må vere tom (null).
+
+
+
+ Verdien er ikkje gyldig.
+
+
+
+ Verdien er ikkje gyldig tidseining.
+
+
+
+ Verdien er ikkje ein gyldig URL.
+
+
+
+ Dei to verdiane må vere like.
+
+
+
+ Fila er for stor. Den maksimale storleik er {{ limit }} {{ suffix }}.
+
+
+
+ Fila er for stor.
+
+
+
+ Fila kunne ikkje bli lasta opp.
+
+
+
+ Verdien må vere eit gyldig tal.
+
+
+
+ Fila er ikkje eit gyldig bilete.
+
+
+
+ Dette er ikkje ei gyldig IP-adresse.
+
+
+
+ Verdien er ikkje eit gyldig språk.
+
+
+
+ Verdien er ikkje ein gyldig lokalitet (språk/region).
+
+
+
+ Verdien er ikkje eit gyldig land.
+
+
+
+ Verdien er allereie i bruk.
+
+
+
+ Storleiken på biletet kunne ikkje oppdagast.
+
+
+
+ Biletbreidda er for stor, ({{ width }} pikslar). Tillatt maksimumsbreidde er {{ max_width }} pikslar.
+
+
+
+ Biletbreidda er for liten, ({{ width }} pikslar). Forventa minimumsbreidde er {{ min_width }} pikslar.
+
+
+
+ Bilethøgda er for stor, ({{ height }} pikslar). Tillatt maksimumshøgde er {{ max_height }} pikslar.
+
+
+
+ Billethøgda er for låg, ({{ height }} pikslar). Forventa minimumshøgde er {{ min_height }} pikslar.
+
+
+
+ Verdien må vere brukaren sitt noverande passord.
+
+
+
+ Verdien må vere nøyaktig {{ limit }} teikn.
+
+
+
+ Fila vart kun delvis opplasta.
+
+
+
+ Inga fil vart lasta opp.
+
+
+
+ Førebels mappe (tmp) er ikkje konfigurert i php.ini.
+
+
+
+ Kan ikkje skrive førebels fil til disk.
+
+
+
+ Ei PHP-udviding forårsaka feil under opplasting.
+
+
+
+ Denne samlinga må innehalde {{ limit }} element eller meir.|Denne samlinga må innehalde {{ limit }} element eller meir.
+
+
+
+ Denne samlinga må innehalde {{ limit }} element eller færre.|Denne samlinga må innehalde {{ limit }} element eller færre.
+
+
+
+ Denne samlinga må innehalde nøyaktig {{ limit }} element.|Denne samlinga må innehalde nøyaktig {{ limit }} element.
+
+
+
+ Ugyldig kortnummer.
+
+
+
+ Korttypen er ikkje støtta eller ugyldig kortnummer.
+
+
+
+
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf
index ea01c63ee4..a8b790c7d8 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf
@@ -4,39 +4,39 @@
- Verdien skulle ha vore tom/nei.
+ Verdien skal være falsk.
- Verdien skulla ha vore satt/ja.
+ Verdien skal være sann.
- Verdien må vere av typen {{ type }}.
+ Verdien skal være av typen {{ type }}.
- Verdien skal vere blank.
+ Verdien skal være blank.
- Verdien du valgte er ikkje gyldig.
+ Verdien skal være en av de gitte valg.
- Du må velge minst {{ limit }} valg.
+ Du skal velge minst {{ limit }} valg.
- Du kan maksimalt gjere {{ limit }} valg.
+ Du kan maks velge {{ limit }} valg.
- Ein eller fleire av dei opplyste verdiane er ugyldige.
+ En eller flere av de oppgitte verdier er ugyldige.
- Dette feltet var ikke forventet.
+ Dette feltet ikke var forventet.
@@ -44,183 +44,111 @@
- Verdien er ikkje ein gyldig dato.
+ Verdien er ikke en gyldig dato.
- Verdien er ikkje ein gyldig dato og tid.
+ Verdien er ikke en gyldig dato og tid.
- Verdien er ikkje ei gyldig e-postadresse.
+ Verdien er ikke en gyldig e-mail adresse.
- Fila kunne ikkje finnes.
+ Filen kunne ikke finnes.
- Fila kan ikkje lesast.
+ Filen kan ikke leses.
- Fila er for stor ({{ size }} {{ suffix }}). Tillatt maksimal størrelse er {{ limit }} {{ suffix }}.
+ Filen er for stor ({{ size }} {{ suffix }}). Tilatte maksimale størrelse {{ limit }} {{ suffix }}.
- Mime-typen av fila er ugyldig ({{ type }}). Tillatte mime-typar er {{ types }}.
+ Mimetypen av filen er ugyldig ({{ type }}). Tilatte mimetyper er {{ types }}.
- Verdien må vere {{ limit }} eller mindre.
+ Verdien skal være {{ limit }} eller mindre.
- Verdien er for lang. Den må vere {{ limit }} bokstavar eller mindre.
+ Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre.
- Verdien må vere {{ limit }} eller meir.
+ Verdien skal være {{ limit }} eller mer.
- Verdien er for kort. Den må ha {{ limit }} teikn eller fleire.
+ Verdien er for kort. Den skal ha {{ limit }} tegn eller flere.
- Verdien må ikkje vere blank.
+ Verdien må ikke være blank.
- Verdien må ikkje vere tom (null).
+ Verdien må ikke være tom (null).
- Verdien må vere tom (null).
+ Verdien skal være tom (null).
- Verdien er ikkje gyldig.
+ Verdien er ikke gyldig.
- Verdien er ikkje gyldig tidseining.
+ Verdien er ikke en gyldig tid.
- Verdien er ikkje ein gyldig URL.
+ Verdien er ikke en gyldig URL.
- Dei to verdiane må vere like.
+ De to verdier skal være ens.
- Fila er for stor. Den maksimale storleik er {{ limit }} {{ suffix }}.
+ Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}.
- Fila er for stor.
+ Filen er for stor.
- Fila kunne ikkje bli lasta opp.
+ Filen kunne ikke lastes opp.
- Verdien må vere eit gyldig tal.
+ Denne verdi skal være et gyldig tall.
- Fila er ikkje eit gyldig bilete.
+ Denne filen er ikke et gyldig bilde.
- Dette er ikkje ei gyldig IP-adresse.
+ Dette er ikke en gyldig IP adresse.
- Verdien er ikkje eit gyldig språk.
+ Denne verdi er ikke et gyldig språk.
- Verdien er ikkje ein gyldig lokalitet (språk/region).
+ Denne verdi er ikke en gyldig lokalitet.
- Verdien er ikkje eit gyldig land.
-
-
-
- Verdien er allereie i bruk.
-
-
-
- Storleiken på biletet kunne ikkje oppdagast.
-
-
-
- Biletbreidda er for stor, ({{ width }} pikslar). Tillatt maksimumsbreidde er {{ max_width }} pikslar.
-
-
-
- Biletbreidda er for liten, ({{ width }} pikslar). Forventa minimumsbreidde er {{ min_width }} pikslar.
-
-
-
- Bilethøgda er for stor, ({{ height }} pikslar). Tillatt maksimumshøgde er {{ max_height }} pikslar.
-
-
-
- Billethøgda er for låg, ({{ height }} pikslar). Forventa minimumshøgde er {{ min_height }} pikslar.
-
-
-
- Verdien må vere brukaren sitt noverande passord.
-
-
-
- Verdien må vere nøyaktig {{ limit }} teikn.
-
-
-
- Fila vart kun delvis opplasta.
-
-
-
- Inga fil vart lasta opp.
-
-
-
- Førebels mappe (tmp) er ikkje konfigurert i php.ini.
-
-
-
- Kan ikkje skrive førebels fil til disk.
-
-
-
- Ei PHP-udviding forårsaka feil under opplasting.
-
-
-
- Denne samlinga må innehalde {{ limit }} element eller meir.|Denne samlinga må innehalde {{ limit }} element eller meir.
-
-
-
- Denne samlinga må innehalde {{ limit }} element eller færre.|Denne samlinga må innehalde {{ limit }} element eller færre.
-
-
-
- Denne samlinga må innehalde nøyaktig {{ limit }} element.|Denne samlinga må innehalde nøyaktig {{ limit }} element.
-
-
-
- Ugyldig kortnummer.
-
-
-
- Korttypen er ikkje støtta eller ugyldig kortnummer.
+ Denne verdi er ikke et gyldig land.
diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php
index bdc30ba92d..45eaffbb3a 100644
--- a/src/Symfony/Component/Yaml/Parser.php
+++ b/src/Symfony/Component/Yaml/Parser.php
@@ -325,8 +325,14 @@ class Parser
mb_internal_encoding($mbEncoding);
}
- if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !is_object($data)) {
- $data = (object) $data;
+ if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !is_object($data) && 'mapping' === $context) {
+ $object = new \stdClass();
+
+ foreach ($data as $key => $value) {
+ $object->$key = $value;
+ }
+
+ $data = $object;
}
return empty($data) ? null : $data;
diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php
index f32fca13e5..3bbe02d851 100644
--- a/src/Symfony/Component/Yaml/Tests/ParserTest.php
+++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -460,75 +460,84 @@ EOF;
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
}
- public function testObjectForMapEnabledWithMapping()
+ /**
+ * @dataProvider getObjectForMapTests
+ */
+ public function testObjectForMap($yaml, $expected)
{
+ $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider getObjectForMapTests
+ */
+ public function testObjectForMapEnabledWithMappingUsingBooleanToggles($yaml, $expected)
+ {
+ $this->assertEquals($expected, $this->parser->parse($yaml, false, false, true));
+ }
+
+ public function getObjectForMapTests()
+ {
+ $tests = array();
+
$yaml = <<parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP);
+ $expected = new \stdClass();
+ $expected->foo = new \stdClass();
+ $expected->foo->fiz = array('cat');
+ $tests['mapping'] = array($yaml, $expected);
- $this->assertInstanceOf('stdClass', $result);
- $this->assertInstanceOf('stdClass', $result->foo);
- $this->assertEquals(array('cat'), $result->foo->fiz);
- }
+ $yaml = '{ "foo": "bar", "fiz": "cat" }';
+ $expected = new \stdClass();
+ $expected->foo = 'bar';
+ $expected->fiz = 'cat';
+ $tests['inline-mapping'] = array($yaml, $expected);
- /**
- * @group legacy
- */
- public function testObjectForMapEnabledWithMappingUsingBooleanToggles()
- {
- $yaml = <<parser->parse($yaml, false, false, true);
-
- $this->assertInstanceOf('stdClass', $result);
- $this->assertInstanceOf('stdClass', $result->foo);
- $this->assertEquals(array('cat'), $result->foo->fiz);
- }
-
- public function testObjectForMapEnabledWithInlineMapping()
- {
- $result = $this->parser->parse('{ "foo": "bar", "fiz": "cat" }', Yaml::PARSE_OBJECT_FOR_MAP);
-
- $this->assertInstanceOf('stdClass', $result);
- $this->assertEquals('bar', $result->foo);
- $this->assertEquals('cat', $result->fiz);
- }
-
- /**
- * @group legacy
- */
- public function testObjectForMapEnabledWithInlineMappingUsingBooleanToggles()
- {
- $result = $this->parser->parse('{ "foo": "bar", "fiz": "cat" }', false, false, true);
-
- $this->assertInstanceOf('stdClass', $result);
- $this->assertEquals('bar', $result->foo);
- $this->assertEquals('cat', $result->fiz);
- }
-
- public function testObjectForMapIsAppliedAfterParsing()
- {
+ $yaml = "foo: bar\nbaz: foobar";
$expected = new \stdClass();
$expected->foo = 'bar';
$expected->baz = 'foobar';
+ $tests['object-for-map-is-applied-after-parsing'] = array($yaml, $expected);
- $this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", Yaml::PARSE_OBJECT_FOR_MAP));
- }
-
- /**
- * @group legacy
- */
- public function testObjectForMapIsAppliedAfterParsingUsingBooleanToggles()
- {
+ $yaml = <<foo = 'bar';
- $expected->baz = 'foobar';
+ $expected->array = array();
+ $expected->array[0] = new \stdClass();
+ $expected->array[0]->key = 'one';
+ $expected->array[1] = new \stdClass();
+ $expected->array[1]->key = 'two';
+ $tests['nest-map-and-sequence'] = array($yaml, $expected);
- $this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", false, false, true));
+ $yaml = <<map = new \stdClass();
+ $expected->map->{1} = 'one';
+ $expected->map->{2} = 'two';
+ $tests['numeric-keys'] = array($yaml, $expected);
+
+ $yaml = <<map = new \stdClass();
+ $expected->map->{0} = 'one';
+ $expected->map->{1} = 'two';
+ $tests['zero-indexed-numeric-keys'] = array($yaml, $expected);
+
+ return $tests;
}
/**