From d37b9e699df01fdff46646fedb18f1231aa019c5 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 22 Oct 2015 02:46:43 +0200 Subject: [PATCH 1/4] [Form] remove validation of FormRegistry::getType as FormRegistry::hasType does not validate either also developers do not work with the registry directly anyway but through the factory. and the factory already validates the value. --- src/Symfony/Component/Form/FormRegistry.php | 4 ---- .../Component/Form/FormRegistryInterface.php | 1 - .../Component/Form/Tests/FormRegistryTest.php | 20 ------------------- 3 files changed, 25 deletions(-) diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index 0dc21df2bc..67cfca06aa 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -69,10 +69,6 @@ class FormRegistry implements FormRegistryInterface */ public function getType($name) { - if (!is_string($name)) { - throw new UnexpectedTypeException($name, 'string'); - } - if (!isset($this->types[$name])) { $type = null; diff --git a/src/Symfony/Component/Form/FormRegistryInterface.php b/src/Symfony/Component/Form/FormRegistryInterface.php index b42b2b5818..f16c0cb8fb 100644 --- a/src/Symfony/Component/Form/FormRegistryInterface.php +++ b/src/Symfony/Component/Form/FormRegistryInterface.php @@ -27,7 +27,6 @@ interface FormRegistryInterface * * @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 */ public function getType($name); diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php index 0c8bb6b441..c99e45edf0 100644 --- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php +++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php @@ -172,18 +172,6 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase $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 */ @@ -192,14 +180,6 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase $this->registry->getType('bar'); } - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testGetTypeThrowsExceptionIfNoString() - { - $this->registry->getType(array()); - } - public function testHasTypeAfterLoadingFromExtension() { $type = new FooType(); From 47b8c3ef3ef6439e48d3305db0cbdd873eb769ee Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Fri, 23 Oct 2015 09:43:05 +0000 Subject: [PATCH 2/4] [Translation][Csv file] remove unnecessary statements, for better readability. --- .../Component/Translation/Loader/CsvFileLoader.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php index ee9224d2ba..22401797ac 100644 --- a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php @@ -51,18 +51,8 @@ class CsvFileLoader extends ArrayLoader $file->setCsvControl($this->delimiter, $this->enclosure, $this->escape); foreach ($file as $data) { - if (substr($data[0], 0, 1) === '#') { - continue; - } - - if (!isset($data[1])) { - continue; - } - - if (count($data) == 2) { + if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === count($data)) { $messages[$data[0]] = $data[1]; - } else { - continue; } } From f1d3e87a1239af2b5b215f95dcdd53979f80cd91 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 24 Oct 2015 14:07:54 +0200 Subject: [PATCH 3/4] [Routing] mark internal classes --- .../Component/Routing/Matcher/Dumper/DumperCollection.php | 2 ++ .../Component/Routing/Matcher/Dumper/DumperPrefixCollection.php | 2 ++ src/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php index f91df98476..e7dea88ed3 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php @@ -15,6 +15,8 @@ namespace Symfony\Component\Routing\Matcher\Dumper; * Collection of routes. * * @author Arnaud Le Blanc + * + * @internal */ class DumperCollection implements \IteratorAggregate { diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php index 6a615f21ad..dd1a0d90e1 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php @@ -15,6 +15,8 @@ namespace Symfony\Component\Routing\Matcher\Dumper; * Prefix tree of routes preserving routes order. * * @author Arnaud Le Blanc + * + * @internal */ class DumperPrefixCollection extends DumperCollection { diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php index 2928cdcc0b..3ad08c2006 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php @@ -17,6 +17,8 @@ use Symfony\Component\Routing\Route; * Container for a Route. * * @author Arnaud Le Blanc + * + * @internal */ class DumperRoute { From e36fea8a633169947e7b0ef7d57d8afe04c18a1f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 26 Oct 2015 13:56:51 +0100 Subject: [PATCH 4/4] fixed YAML files missing quotes when a string starts with @ --- .../Tests/Functional/app/Fragment/routing.yml | 2 +- .../Tests/Functional/app/Profiler/routing.yml | 2 +- .../Tests/Functional/app/Session/routing.yml | 2 +- .../Tests/Functional/app/CsrfFormLogin/config.yml | 2 +- .../Tests/Functional/app/CsrfFormLogin/routing.yml | 2 +- .../Tests/Functional/app/StandardFormLogin/routing.yml | 4 ++-- .../Component/DependencyInjection/Dumper/YamlDumper.php | 6 +++--- .../DependencyInjection/Tests/Fixtures/yaml/services2.yml | 4 ++-- .../DependencyInjection/Tests/Fixtures/yaml/services6.yml | 6 +++--- .../DependencyInjection/Tests/Fixtures/yaml/services9.yml | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/routing.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/routing.yml index c119432a48..8a9bd84b14 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/routing.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/routing.yml @@ -1,2 +1,2 @@ _fragmenttest_bundle: - resource: @TestBundle/Resources/config/routing.yml + resource: '@TestBundle/Resources/config/routing.yml' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/routing.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/routing.yml index 508a6b2f5c..d4b77c3f70 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/routing.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/routing.yml @@ -1,2 +1,2 @@ _sessiontest_bundle: - resource: @TestBundle/Resources/config/routing.yml + resource: '@TestBundle/Resources/config/routing.yml' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/routing.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/routing.yml index 508a6b2f5c..d4b77c3f70 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/routing.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/routing.yml @@ -1,2 +1,2 @@ _sessiontest_bundle: - resource: @TestBundle/Resources/config/routing.yml + resource: '@TestBundle/Resources/config/routing.yml' diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml index e0347e1dc4..d77013a219 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml @@ -6,7 +6,7 @@ services: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType scope: request arguments: - - @request + - '@request' tags: - { name: form.type, alias: user_login } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/routing.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/routing.yml index e2e84d9fe5..ecfae00918 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/routing.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/routing.yml @@ -1,2 +1,2 @@ _csrf_form_login_bundle: - resource: @CsrfFormLoginBundle/Resources/config/routing.yml + resource: '@CsrfFormLoginBundle/Resources/config/routing.yml' diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/routing.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/routing.yml index 6c408c150d..0920ea1d70 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/routing.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/routing.yml @@ -1,5 +1,5 @@ _form_login_bundle: - resource: @FormLoginBundle/Resources/config/routing.yml + resource: '@FormLoginBundle/Resources/config/routing.yml' _form_login_localized: - resource: @FormLoginBundle/Resources/config/localized_routing.yml + resource: '@FormLoginBundle/Resources/config/localized_routing.yml' diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index c5f98b6202..eca056dea1 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -157,10 +157,10 @@ class YamlDumper extends Dumper private function addServiceAlias($alias, $id) { if ($id->isPublic()) { - return sprintf(" %s: @%s\n", $alias, $id); - } else { - return sprintf(" %s:\n alias: %s\n public: false", $alias, $id); + return sprintf(" %s: '@%s'\n", $alias, $id); } + + return sprintf(" %s:\n alias: %s\n public: false", $alias, $id); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml index 3c127466af..b62d5ccfb5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml @@ -6,7 +6,7 @@ parameters: - 0 - 1000.3 bar: foo - escape: @@escapeme - foo_bar: @foo_bar + escape: '@@escapeme' + foo_bar: '@foo_bar' MixedCase: MixedCaseKey: value diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index 7ba9453bdd..d9dc85265f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -6,7 +6,7 @@ services: scope.prototype: { class: FooClass, scope: prototype } constructor: { class: FooClass, factory_method: getInstance } 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 } configurator2: { class: FooClass, configurator: [@baz, configure] } configurator3: { class: FooClass, configurator: [BazClass, configureStatic] } @@ -18,8 +18,8 @@ services: method_call2: class: FooClass calls: - - [ setBar, [ foo, @foo, [true, false] ] ] - alias_for_foo: @foo + - [ setBar, [ foo, '@foo', [true, false] ] ] + alias_for_foo: '@foo' another_alias_for_foo: alias: foo public: false diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index cda41b2cce..c6181ed549 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -69,5 +69,5 @@ services: calls: - [setRequest, ['@?request']] - alias_for_foo: @foo - alias_for_alias: @foo + alias_for_foo: '@foo' + alias_for_alias: '@foo'