Merge branch '2.3' into 2.7

* 2.3:
  fixed YAML files missing quotes when a string starts with @
  [Routing] mark internal classes
  [Translation][Csv file] remove unnecessary statements, for better readability.
  [Form] remove validation of FormRegistry::getType as FormRegistry::hasType does not validate either
This commit is contained in:
Fabien Potencier 2015-10-27 08:38:06 -07:00
commit ced865deb1
17 changed files with 24 additions and 53 deletions

View File

@ -1,2 +1,2 @@
_fragmenttest_bundle: _fragmenttest_bundle:
resource: @TestBundle/Resources/config/routing.yml resource: '@TestBundle/Resources/config/routing.yml'

View File

@ -1,2 +1,2 @@
_sessiontest_bundle: _sessiontest_bundle:
resource: @TestBundle/Resources/config/routing.yml resource: '@TestBundle/Resources/config/routing.yml'

View File

@ -1,2 +1,2 @@
_sessiontest_bundle: _sessiontest_bundle:
resource: @TestBundle/Resources/config/routing.yml resource: '@TestBundle/Resources/config/routing.yml'

View File

@ -6,7 +6,7 @@ services:
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType
scope: request scope: request
arguments: arguments:
- @request - '@request'
tags: tags:
- { name: form.type, alias: user_login } - { name: form.type, alias: user_login }

View File

@ -1,2 +1,2 @@
_csrf_form_login_bundle: _csrf_form_login_bundle:
resource: @CsrfFormLoginBundle/Resources/config/routing.yml resource: '@CsrfFormLoginBundle/Resources/config/routing.yml'

View File

@ -1,5 +1,5 @@
_form_login_bundle: _form_login_bundle:
resource: @FormLoginBundle/Resources/config/routing.yml resource: '@FormLoginBundle/Resources/config/routing.yml'
_form_login_localized: _form_login_localized:
resource: @FormLoginBundle/Resources/config/localized_routing.yml resource: '@FormLoginBundle/Resources/config/localized_routing.yml'

View File

@ -162,10 +162,10 @@ class YamlDumper extends Dumper
private function addServiceAlias($alias, $id) private function addServiceAlias($alias, $id)
{ {
if ($id->isPublic()) { if ($id->isPublic()) {
return sprintf(" %s: @%s\n", $alias, $id); return sprintf(" %s: '@%s'\n", $alias, $id);
} else {
return sprintf(" %s:\n alias: %s\n public: false", $alias, $id);
} }
return sprintf(" %s:\n alias: %s\n public: false", $alias, $id);
} }
/** /**

View File

@ -6,7 +6,7 @@ parameters:
- 0 - 0
- 1000.3 - 1000.3
bar: foo bar: foo
escape: @@escapeme escape: '@@escapeme'
foo_bar: @foo_bar foo_bar: '@foo_bar'
MixedCase: MixedCase:
MixedCaseKey: value MixedCaseKey: value

View File

@ -5,7 +5,7 @@ services:
scope.custom: { class: FooClass, scope: custom } scope.custom: { class: FooClass, scope: custom }
scope.prototype: { class: FooClass, scope: prototype } scope.prototype: { class: FooClass, scope: prototype }
file: { class: FooClass, file: %path%/foo.php } file: { class: FooClass, file: %path%/foo.php }
arguments: { class: FooClass, arguments: [foo, @foo, [true, false]] } arguments: { class: FooClass, arguments: [foo, '@foo', [true, false]] }
configurator1: { class: FooClass, configurator: sc_configure } configurator1: { class: FooClass, configurator: sc_configure }
configurator2: { class: FooClass, configurator: [@baz, configure] } configurator2: { class: FooClass, configurator: [@baz, configure] }
configurator3: { class: FooClass, configurator: [BazClass, configureStatic] } configurator3: { class: FooClass, configurator: [BazClass, configureStatic] }
@ -18,8 +18,8 @@ services:
method_call2: method_call2:
class: FooClass class: FooClass
calls: calls:
- [ setBar, [ foo, @foo, [true, false] ] ] - [ setBar, [ foo, '@foo', [true, false] ] ]
alias_for_foo: @foo alias_for_foo: '@foo'
another_alias_for_foo: another_alias_for_foo:
alias: foo alias: foo
public: false public: false

View File

@ -90,5 +90,5 @@ services:
service_from_static_method: service_from_static_method:
class: Bar\FooClass class: Bar\FooClass
factory: [Bar\FooClass, getInstance] factory: [Bar\FooClass, getInstance]
alias_for_foo: @foo alias_for_foo: '@foo'
alias_for_alias: @foo alias_for_alias: '@foo'

View File

@ -69,10 +69,6 @@ class FormRegistry implements FormRegistryInterface
*/ */
public function getType($name) public function getType($name)
{ {
if (!is_string($name)) {
throw new UnexpectedTypeException($name, 'string');
}
if (!isset($this->types[$name])) { if (!isset($this->types[$name])) {
$type = null; $type = null;

View File

@ -27,7 +27,6 @@ interface FormRegistryInterface
* *
* @return ResolvedFormTypeInterface The type * @return ResolvedFormTypeInterface The type
* *
* @throws Exception\UnexpectedTypeException if the passed name is not a string
* @throws Exception\InvalidArgumentException if the type can not be retrieved from any extension * @throws Exception\InvalidArgumentException if the type can not be retrieved from any extension
*/ */
public function getType($name); public function getType($name);

View File

@ -172,18 +172,6 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
$this->assertSame($resolvedType, $this->registry->getType('foo_sub_type_parent_instance')); $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type_parent_instance'));
} }
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testGetTypeThrowsExceptionIfParentNotFound()
{
$type = new FooSubType();
$this->extension1->addType($type);
$this->registry->getType($type);
}
/** /**
* @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
*/ */
@ -192,14 +180,6 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
$this->registry->getType('bar'); $this->registry->getType('bar');
} }
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testGetTypeThrowsExceptionIfNoString()
{
$this->registry->getType(array());
}
public function testHasTypeAfterLoadingFromExtension() public function testHasTypeAfterLoadingFromExtension()
{ {
$type = new FooType(); $type = new FooType();

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\Routing\Matcher\Dumper;
* Collection of routes. * Collection of routes.
* *
* @author Arnaud Le Blanc <arnaud.lb@gmail.com> * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
*
* @internal
*/ */
class DumperCollection implements \IteratorAggregate class DumperCollection implements \IteratorAggregate
{ {

View File

@ -15,6 +15,8 @@ namespace Symfony\Component\Routing\Matcher\Dumper;
* Prefix tree of routes preserving routes order. * Prefix tree of routes preserving routes order.
* *
* @author Arnaud Le Blanc <arnaud.lb@gmail.com> * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
*
* @internal
*/ */
class DumperPrefixCollection extends DumperCollection class DumperPrefixCollection extends DumperCollection
{ {

View File

@ -17,6 +17,8 @@ use Symfony\Component\Routing\Route;
* Container for a Route. * Container for a Route.
* *
* @author Arnaud Le Blanc <arnaud.lb@gmail.com> * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
*
* @internal
*/ */
class DumperRoute class DumperRoute
{ {

View File

@ -51,18 +51,8 @@ class CsvFileLoader extends ArrayLoader
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape); $file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
foreach ($file as $data) { foreach ($file as $data) {
if (substr($data[0], 0, 1) === '#') { if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === count($data)) {
continue;
}
if (!isset($data[1])) {
continue;
}
if (count($data) == 2) {
$messages[$data[0]] = $data[1]; $messages[$data[0]] = $data[1];
} else {
continue;
} }
} }