From 3506a7e8ca6f3fa58f05e1fcfc5c1552094007d1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 2 Apr 2019 15:46:07 +0200 Subject: [PATCH] ordered use statements in code examples --- best_practices/business-logic.rst | 2 +- best_practices/configuration.rst | 2 +- best_practices/forms.rst | 12 +++++----- best_practices/security.rst | 2 +- bundles/configuration.rst | 2 +- bundles/extension.rst | 2 +- bundles/prepend_extension.rst | 4 ++-- components/asset.rst | 6 ++--- .../adapters/php_array_cache_adapter.rst | 2 +- components/cache/cache_invalidation.rst | 2 +- components/cache/psr6_psr16_adapters.rst | 2 +- components/config/definition.rst | 6 ++--- components/console/events.rst | 8 +++---- components/console/helpers/questionhelper.rst | 2 +- components/console/helpers/table.rst | 2 +- components/console/logger.rst | 2 +- components/dependency_injection.rst | 6 ++--- .../dependency_injection/compilation.rst | 6 ++--- components/event_dispatcher.rst | 8 +++---- components/expression_language/caching.rst | 2 +- components/filesystem.rst | 2 +- components/form.rst | 19 ++++++++-------- .../http_foundation/session_configuration.rst | 4 ++-- .../http_foundation/session_testing.rst | 2 +- components/http_kernel.rst | 4 ++-- components/intl.rst | 2 +- components/ldap.rst | 2 +- components/lock.rst | 2 +- components/process.rst | 2 +- components/property_info.rst | 4 ++-- components/routing.rst | 6 ++--- components/security/authentication.rst | 10 ++++----- components/security/authorization.rst | 2 +- components/security/firewall.rst | 4 ++-- components/serializer.rst | 13 ++++++----- components/templating.rst | 4 ++-- components/translation/custom_formats.rst | 4 ++-- components/translation/usage.rst | 4 ++-- components/validator.rst | 2 +- components/validator/metadata.rst | 6 ++--- components/validator/resources.rst | 2 +- components/var_dumper/advanced.rst | 2 +- components/workflow.rst | 4 ++-- configuration/configuration_organization.rst | 6 ++--- configuration/micro_kernel_trait.rst | 2 +- configuration/multiple_kernels.rst | 2 +- console.rst | 2 +- console/style.rst | 2 +- controller/soap_web_service.rst | 2 +- controller/upload_file.rst | 16 +++++++------- create_framework/dependency_injection.rst | 4 ++-- create_framework/event_dispatcher.rst | 2 +- .../http_kernel_controller_resolver.rst | 2 +- .../http_kernel_httpkernel_class.rst | 4 ++-- create_framework/routing.rst | 2 +- create_framework/separation_of_concerns.rst | 2 +- create_framework/templating.rst | 2 +- create_framework/unit_testing.rst | 6 ++--- doctrine.rst | 2 +- doctrine/custom_dql_functions.rst | 6 ++--- doctrine/event_listeners_subscribers.rst | 4 ++-- doctrine/mapping_model_classes.rst | 4 ++-- doctrine/registration_form.rst | 17 +++++++------- doctrine/resolve_target_entity.rst | 4 ++-- event_dispatcher.rst | 2 +- event_dispatcher/before_after_filters.rst | 4 ++-- event_dispatcher/method_behavior.rst | 2 +- form/create_custom_field_type.rst | 4 ++-- form/create_form_type_extension.rst | 10 ++++----- form/data_transformers.rst | 5 +++-- form/dynamic_form_modification.rst | 22 +++++++++---------- form/embedded.rst | 2 +- form/events.rst | 12 +++++----- form/form_collections.rst | 6 ++--- form/form_customization.rst | 2 +- form/inherit_data_option.rst | 8 +++---- form/type_guesser.rst | 10 ++++----- form/use_empty_data.rst | 4 ++-- form/without_class.rst | 4 ++-- forms.rst | 8 +++---- frontend/custom_version_strategy.rst | 2 +- http_cache/validation.rst | 6 ++--- profiler/data_collector.rst | 2 +- reference/constraints/All.rst | 2 +- reference/constraints/Bic.rst | 2 +- reference/constraints/Blank.rst | 2 +- reference/constraints/Callback.rst | 7 +++--- reference/constraints/CardScheme.rst | 2 +- reference/constraints/Choice.rst | 6 ++--- reference/constraints/Collection.rst | 4 ++-- reference/constraints/Count.rst | 2 +- reference/constraints/Country.rst | 2 +- reference/constraints/Currency.rst | 2 +- reference/constraints/Date.rst | 2 +- reference/constraints/DateTime.rst | 2 +- reference/constraints/Email.rst | 2 +- reference/constraints/EqualTo.rst | 2 +- reference/constraints/Expression.rst | 2 +- reference/constraints/File.rst | 2 +- reference/constraints/GreaterThan.rst | 8 +++---- reference/constraints/GreaterThanOrEqual.rst | 8 +++---- reference/constraints/Iban.rst | 2 +- reference/constraints/IdenticalTo.rst | 2 +- reference/constraints/Image.rst | 4 ++-- reference/constraints/Ip.rst | 2 +- reference/constraints/IsFalse.rst | 2 +- reference/constraints/IsNull.rst | 2 +- reference/constraints/IsTrue.rst | 2 +- reference/constraints/Isbn.rst | 2 +- reference/constraints/Issn.rst | 2 +- reference/constraints/Language.rst | 2 +- reference/constraints/Length.rst | 2 +- reference/constraints/LessThan.rst | 8 +++---- reference/constraints/LessThanOrEqual.rst | 8 +++---- reference/constraints/Locale.rst | 2 +- reference/constraints/Luhn.rst | 2 +- reference/constraints/NotBlank.rst | 2 +- reference/constraints/NotEqualTo.rst | 2 +- reference/constraints/NotIdenticalTo.rst | 2 +- reference/constraints/NotNull.rst | 2 +- reference/constraints/Range.rst | 8 +++---- reference/constraints/Regex.rst | 6 ++--- reference/constraints/Time.rst | 2 +- reference/constraints/Traverse.rst | 2 +- reference/constraints/Type.rst | 2 +- reference/constraints/UniqueEntity.rst | 13 ++++++----- reference/constraints/Url.rst | 10 ++++----- reference/constraints/UserPassword.rst | 2 +- reference/constraints/Uuid.rst | 2 +- reference/constraints/Valid.rst | 6 ++--- reference/events.rst | 4 ++-- reference/forms/types/choice.rst | 2 +- reference/forms/types/collection.rst | 2 +- .../forms/types/options/by_reference.rst.inc | 2 +- .../types/options/validation_groups.rst.inc | 2 +- reference/forms/types/repeated.rst | 2 +- routing.rst | 8 +++---- routing/conditions.rst | 2 +- routing/custom_route_loader.rst | 2 +- routing/extra_information.rst | 2 +- routing/hostname_pattern.rst | 8 +++---- routing/optional_placeholders.rst | 6 ++--- routing/redirect_in_config.rst | 4 ++-- routing/redirect_trailing_slash.rst | 2 +- routing/requirements.rst | 6 ++--- routing/scheme.rst | 2 +- routing/service_container_parameters.rst | 4 ++-- routing/slash_in_parameter.rst | 2 +- security.rst | 2 +- security/acl.rst | 2 +- security/api_key_authentication.rst | 12 +++++----- security/custom_authentication_provider.rst | 18 +++++++-------- security/custom_provider.rst | 8 +++---- security/entity_provider.rst | 2 +- security/form_login_setup.rst | 2 +- security/guard_authentication.rst | 12 +++++----- security/impersonating_user.rst | 2 +- security/json_login_setup.rst | 2 +- security/ldap.rst | 2 +- security/multiple_guard_authenticators.rst | 2 +- security/named_encoders.rst | 2 +- serializer/encoders.rst | 4 ++-- serializer/normalizers.rst | 2 +- service_container.rst | 4 ++-- service_container/autowiring.rst | 4 ++-- service_container/compiler_passes.rst | 4 ++-- service_container/definitions.rst | 2 +- service_container/optional_dependencies.rst | 4 ++-- service_container/parent_services.rst | 8 +++---- .../service_subscribers_locators.rst | 2 +- service_container/tags.rst | 8 +++---- session/locale_sticky_session.rst | 2 +- templating/render_without_controller.rst | 4 ++-- translation/locale.rst | 2 +- validation.rst | 12 +++++----- validation/custom_constraint.rst | 6 ++--- validation/groups.rst | 2 +- validation/raw_values.rst | 2 +- validation/sequence_provider.rst | 2 +- validation/severity.rst | 2 +- validation/translations.rst | 2 +- workflow.rst | 3 ++- 182 files changed, 387 insertions(+), 382 deletions(-) diff --git a/best_practices/business-logic.rst b/best_practices/business-logic.rst index a3ee57a8f69..aa99546fed2 100644 --- a/best_practices/business-logic.rst +++ b/best_practices/business-logic.rst @@ -238,8 +238,8 @@ looking for mapping information:: namespace AppBundle\Entity; - use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; + use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity diff --git a/best_practices/configuration.rst b/best_practices/configuration.rst index 677d79bdbc2..0938eaa4561 100644 --- a/best_practices/configuration.rst +++ b/best_practices/configuration.rst @@ -137,8 +137,8 @@ whereas they cannot access the container parameters:: namespace AppBundle\Repository; - use Doctrine\ORM\EntityRepository; use AppBundle\Entity\Post; + use Doctrine\ORM\EntityRepository; class PostRepository extends EntityRepository { diff --git a/best_practices/forms.rst b/best_practices/forms.rst index 32723af64c6..7a44b11ce20 100644 --- a/best_practices/forms.rst +++ b/best_practices/forms.rst @@ -21,11 +21,11 @@ form in its own PHP class:: use AppBundle\Entity\Post; use Symfony\Component\Form\AbstractType; + use Symfony\Component\Form\Extension\Core\Type\DateTimeType; + use Symfony\Component\Form\Extension\Core\Type\EmailType; + use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - use Symfony\Component\Form\Extension\Core\Type\TextareaType; - use Symfony\Component\Form\Extension\Core\Type\EmailType; - use Symfony\Component\Form\Extension\Core\Type\DateTimeType; class PostType extends AbstractType { @@ -109,11 +109,11 @@ some developers configure form buttons in the controller:: namespace AppBundle\Controller\Admin; - use Symfony\Component\HttpFoundation\Request; - use Symfony\Bundle\FrameworkBundle\Controller\Controller; - use Symfony\Component\Form\Extension\Core\Type\SubmitType; use AppBundle\Entity\Post; use AppBundle\Form\PostType; + use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Symfony\Component\Form\Extension\Core\Type\SubmitType; + use Symfony\Component\HttpFoundation\Request; class PostController extends Controller { diff --git a/best_practices/security.rst b/best_practices/security.rst index 7eb094ef791..f709d4f8d29 100644 --- a/best_practices/security.rst +++ b/best_practices/security.rst @@ -259,11 +259,11 @@ the same ``getAuthorEmail()`` logic you used above:: namespace AppBundle\Security; + use AppBundle\Entity\Post; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\User\UserInterface; - use AppBundle\Entity\Post; class PostVoter extends Voter { diff --git a/bundles/configuration.rst b/bundles/configuration.rst index 8e1ba5bc811..915544c0fa2 100644 --- a/bundles/configuration.rst +++ b/bundles/configuration.rst @@ -262,8 +262,8 @@ In your extension, you can load this and dynamically set its arguments:: // src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php // ... - use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; public function load(array $configs, ContainerBuilder $container) { diff --git a/bundles/extension.rst b/bundles/extension.rst index 5b8c3e4cd50..dc5e5bc4c73 100644 --- a/bundles/extension.rst +++ b/bundles/extension.rst @@ -93,8 +93,8 @@ the extension! For instance, assume you have a file called ``services.xml`` in the ``Resources/config`` directory of your bundle, your ``load()`` method looks like:: - use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; // ... public function load(array $configs, ContainerBuilder $container) diff --git a/bundles/prepend_extension.rst b/bundles/prepend_extension.rst index b9f2d7adc0b..923796fc42e 100644 --- a/bundles/prepend_extension.rst +++ b/bundles/prepend_extension.rst @@ -28,9 +28,9 @@ To give an Extension the power to do this, it needs to implement // src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php namespace Acme\HelloBundle\DependencyInjection; - use Symfony\Component\HttpKernel\DependencyInjection\Extension; - use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; + use Symfony\Component\HttpKernel\DependencyInjection\Extension; class AcmeHelloExtension extends Extension implements PrependExtensionInterface { diff --git a/components/asset.rst b/components/asset.rst index cf1706ef486..ca11f502641 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -223,8 +223,8 @@ If you are also using the :doc:`HttpFoundation ` component in your project (for instance, in a Symfony application), the ``PathPackage`` class can take into account the context of the current request:: - use Symfony\Component\Asset\PathPackage; use Symfony\Component\Asset\Context\RequestStackContext; + use Symfony\Component\Asset\PathPackage; // ... $pathPackage = new PathPackage( @@ -313,8 +313,8 @@ account the context of the current request. In this case, only the request scheme is considered, in order to select the appropriate base URL (HTTPs or protocol-relative URLs for HTTPs requests, any base URL for HTTP requests):: - use Symfony\Component\Asset\UrlPackage; use Symfony\Component\Asset\Context\RequestStackContext; + use Symfony\Component\Asset\UrlPackage; // ... $urlPackage = new UrlPackage( @@ -339,9 +339,9 @@ In the following example, all packages use the same versioning strategy, but they all have different base paths:: use Symfony\Component\Asset\Package; + use Symfony\Component\Asset\Packages; use Symfony\Component\Asset\PathPackage; use Symfony\Component\Asset\UrlPackage; - use Symfony\Component\Asset\Packages; // ... $versionStrategy = new StaticVersionStrategy('v1'); diff --git a/components/cache/adapters/php_array_cache_adapter.rst b/components/cache/adapters/php_array_cache_adapter.rst index dfc29f62002..e6da6b0f2e3 100644 --- a/components/cache/adapters/php_array_cache_adapter.rst +++ b/components/cache/adapters/php_array_cache_adapter.rst @@ -8,8 +8,8 @@ Php Array Cache Adapter This adapter is a high performance cache for static data (e.g. application configuration) that is optimized and preloaded into OPcache memory storage:: - use Symfony\Component\Cache\Adapter\PhpArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; + use Symfony\Component\Cache\Adapter\PhpArrayAdapter; // somehow, decide it's time to warm up the cache! if ($needsWarmup) { diff --git a/components/cache/cache_invalidation.rst b/components/cache/cache_invalidation.rst index ab78d8e5b49..e2bb8a8ce0c 100644 --- a/components/cache/cache_invalidation.rst +++ b/components/cache/cache_invalidation.rst @@ -73,9 +73,9 @@ in the same place. By using two adapters, you can e.g. store some big cached ite on the filesystem or in the database and keep tags in a Redis database to sync all your fronts and have very fast invalidation checks:: - use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; + use Symfony\Component\Cache\Adapter\TagAwareAdapter; $cache = new TagAwareAdapter( // Adapter for cached items diff --git a/components/cache/psr6_psr16_adapters.rst b/components/cache/psr6_psr16_adapters.rst index 88f1e7c93e2..55014b9faba 100644 --- a/components/cache/psr6_psr16_adapters.rst +++ b/components/cache/psr6_psr16_adapters.rst @@ -36,8 +36,8 @@ instead. No problem! The Cache component provides the :class:`Symfony\\Component\\Cache\\Adapter\\SimpleCacheAdapter` class for exactly this use-case:: - use Symfony\Component\Cache\Simple\FilesystemCache; use Symfony\Component\Cache\Adapter\SimpleCacheAdapter; + use Symfony\Component\Cache\Simple\FilesystemCache; // the PSR-16 cache object that you want to use $psr16Cache = new FilesystemCache(); diff --git a/components/config/definition.rst b/components/config/definition.rst index fe392215795..ce426801c2d 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -52,8 +52,8 @@ implements the :class:`Symfony\\Component\\Config\\Definition\\ConfigurationInte namespace Acme\DatabaseConfiguration; - use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; + use Symfony\Component\Config\Definition\ConfigurationInterface; class DatabaseConfiguration implements ConfigurationInterface { @@ -809,9 +809,9 @@ any value is not of the expected type, is mandatory and yet undefined, or could not be validated in some other way, an exception will be thrown. Otherwise the result is a clean array of configuration values:: - use Symfony\Component\Yaml\Yaml; - use Symfony\Component\Config\Definition\Processor; use Acme\DatabaseConfiguration; + use Symfony\Component\Config\Definition\Processor; + use Symfony\Component\Yaml\Yaml; $config = Yaml::parse( file_get_contents(__DIR__.'/src/Matthias/config/config.yml') diff --git a/components/console/events.rst b/components/console/events.rst index dc662c9b00d..34e9eaa6ba7 100644 --- a/components/console/events.rst +++ b/components/console/events.rst @@ -33,8 +33,8 @@ Just before executing any command, the ``ConsoleEvents::COMMAND`` event is dispatched. Listeners receive a :class:`Symfony\\Component\\Console\\Event\\ConsoleCommandEvent` event:: - use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\ConsoleEvents; + use Symfony\Component\Console\Event\ConsoleCommandEvent; $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) { // gets the input instance @@ -64,8 +64,8 @@ will then *not* execute the command, but instead will return the code ``113`` of the `reserved exit codes`_ for console commands that conform with the C/C++ standard:: - use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\ConsoleEvents; + use Symfony\Component\Console\Event\ConsoleCommandEvent; $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) { // gets the command to be executed @@ -112,8 +112,8 @@ thrown by the application. Listeners receive a :class:`Symfony\\Component\\Console\\Event\\ConsoleErrorEvent` event:: - use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\ConsoleEvents; + use Symfony\Component\Console\Event\ConsoleErrorEvent; $dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) { $output = $event->getOutput(); @@ -146,8 +146,8 @@ listener (like sending logs, closing a database connection, sending emails, Listeners receive a :class:`Symfony\\Component\\Console\\Event\\ConsoleTerminateEvent` event:: - use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\ConsoleEvents; + use Symfony\Component\Console\Event\ConsoleTerminateEvent; $dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) { // gets the output diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 279bd53c601..1c405d9e313 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -344,8 +344,8 @@ Testing a Command that Expects Input If you want to write a unit test for a command which expects some kind of input from the command line, you need to set the inputs that the command expects:: - use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Helper\HelperSet; + use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Tester\CommandTester; // ... diff --git a/components/console/helpers/table.rst b/components/console/helpers/table.rst index 7af9e25e746..59fc63f5992 100644 --- a/components/console/helpers/table.rst +++ b/components/console/helpers/table.rst @@ -192,8 +192,8 @@ Spanning Multiple Columns and Rows To make a table cell that spans multiple columns you can use a :class:`Symfony\\Component\\Console\\Helper\\TableCell`:: use Symfony\Component\Console\Helper\Table; - use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Console\Helper\TableCell; + use Symfony\Component\Console\Helper\TableSeparator; $table = new Table($output); $table diff --git a/components/console/logger.rst b/components/console/logger.rst index 3d129f7aa3b..642f791a4d3 100644 --- a/components/console/logger.rst +++ b/components/console/logger.rst @@ -39,8 +39,8 @@ You can rely on the logger to use this dependency inside a command:: use Acme\MyDependency; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Logger\ConsoleLogger; + use Symfony\Component\Console\Output\OutputInterface; class MyCommand extends Command { diff --git a/components/dependency_injection.rst b/components/dependency_injection.rst index c9fd30979b1..d6b981827ec 100644 --- a/components/dependency_injection.rst +++ b/components/dependency_injection.rst @@ -198,8 +198,8 @@ files. To do this you also need to install Loading an XML config file:: - use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; $containerBuilder = new ContainerBuilder(); @@ -208,8 +208,8 @@ Loading an XML config file:: Loading a YAML config file:: - use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; $containerBuilder = new ContainerBuilder(); @@ -233,8 +233,8 @@ Loading a YAML config file:: If you *do* want to use PHP to create the services then you can move this into a separate config file and load it in a similar way:: - use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; $containerBuilder = new ContainerBuilder(); diff --git a/components/dependency_injection/compilation.rst b/components/dependency_injection/compilation.rst index a48711652af..ca2761d2293 100644 --- a/components/dependency_injection/compilation.rst +++ b/components/dependency_injection/compilation.rst @@ -57,10 +57,10 @@ added but are processed when the container's ``compile()`` method is called. A very simple extension may just load configuration files into the container:: + use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; - use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; - use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; class AcmeDemoExtension implements ExtensionInterface { @@ -113,8 +113,8 @@ If this file is loaded into the configuration then the values in it are only processed when the container is compiled at which point the Extensions are loaded:: - use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; + use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; $containerBuilder = new ContainerBuilder(); diff --git a/components/event_dispatcher.rst b/components/event_dispatcher.rst index 19f9e1a29e8..3221612dbb8 100644 --- a/components/event_dispatcher.rst +++ b/components/event_dispatcher.rst @@ -200,8 +200,8 @@ determine which instance is passed. use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; - use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; + use Symfony\Component\EventDispatcher\EventDispatcher; $containerBuilder = new ContainerBuilder(new ParameterBag()); // register the compiler pass that handles the 'kernel.event_listener' @@ -252,8 +252,8 @@ order. Start by creating this custom event class and documenting it:: namespace Acme\Store\Event; - use Symfony\Component\EventDispatcher\Event; use Acme\Store\Order; + use Symfony\Component\EventDispatcher\Event; /** * The order.placed event is dispatched each time an order is created @@ -295,8 +295,8 @@ method notifies all listeners of the given event. It takes two arguments: the name of the event to dispatch and the ``Event`` instance to pass to each listener of that event:: - use Acme\Store\Order; use Acme\Store\Event\OrderPlacedEvent; + use Acme\Store\Order; // the order is somehow created or retrieved $order = new Order(); @@ -333,10 +333,10 @@ Take the following example of a subscriber that subscribes to the namespace Acme\Store\Event; + use Acme\Store\Event\OrderPlacedEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; - use Acme\Store\Event\OrderPlacedEvent; class StoreSubscriber implements EventSubscriberInterface { diff --git a/components/expression_language/caching.rst b/components/expression_language/caching.rst index 361446a0645..4f24942a559 100644 --- a/components/expression_language/caching.rst +++ b/components/expression_language/caching.rst @@ -31,8 +31,8 @@ uses an :class:`Symfony\\Component\\Cache\\Adapter\\ArrayAdapter`). You can customize this by creating a custom cache pool or using one of the available ones and injecting this using the constructor:: - use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Cache\Adapter\RedisAdapter; + use Symfony\Component\ExpressionLanguage\ExpressionLanguage; $cache = new RedisAdapter(...); $expressionLanguage = new ExpressionLanguage($cache); diff --git a/components/filesystem.rst b/components/filesystem.rst index 15875b3e680..431c9939392 100644 --- a/components/filesystem.rst +++ b/components/filesystem.rst @@ -21,8 +21,8 @@ Usage The :class:`Symfony\\Component\\Filesystem\\Filesystem` class is the unique endpoint for filesystem operations:: - use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; + use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); diff --git a/components/form.rst b/components/form.rst index 828853b5291..dc3fbd77573 100644 --- a/components/form.rst +++ b/components/form.rst @@ -88,8 +88,8 @@ object to read data off of the correct PHP superglobals (i.e. ``$_POST`` or :class:`Symfony\\Component\\Form\\Extension\\HttpFoundation\\HttpFoundationExtension` to your form factory:: - use Symfony\Component\Form\Forms; use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; + use Symfony\Component\Form\Forms; $formFactory = Forms::createFormFactoryBuilder() ->addExtension(new HttpFoundationExtension()) @@ -118,12 +118,12 @@ use the built-in support, first install the Security CSRF component: The following snippet adds CSRF protection to the form factory:: + use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Forms; use Symfony\Component\HttpFoundation\Session\Session; - use Symfony\Component\Form\Extension\Csrf\CsrfExtension; - use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage; - use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator; use Symfony\Component\Security\Csrf\CsrfTokenManager; + use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator; + use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage; // creates a Session object from the HttpFoundation component $session = new Session(); @@ -179,10 +179,11 @@ that help you render the HTML widget, label and error for each field (as well as a few other things). To configure the integration, you'll need to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension\\FormExtension`:: - use Symfony\Component\Form\Forms; + use Symfony\Bridge\Twig\Extension\FormExtension; - use Symfony\Component\Form\FormRenderer; use Symfony\Bridge\Twig\Form\TwigRendererEngine; + use Symfony\Component\Form\FormRenderer; + use Symfony\Component\Form\Forms; use Twig\Environment; use Twig\Loader\FilesystemLoader; use Twig\RuntimeLoader\FactoryRuntimeLoader; @@ -264,10 +265,10 @@ installed: Next, add the :class:`Symfony\\Bridge\\Twig\\Extension\\TranslationExtension` to your ``Twig\\Environment`` instance:: + use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Component\Form\Forms; - use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Loader\XliffFileLoader; - use Symfony\Bridge\Twig\Extension\TranslationExtension; + use Symfony\Component\Translation\Translator; // creates the Translator $translator = new Translator('en'); @@ -314,8 +315,8 @@ errors are then mapped to the correct field and rendered. Your integration with the Validation component will look something like this:: - use Symfony\Component\Form\Forms; use Symfony\Component\Form\Extension\Validator\ValidatorExtension; + use Symfony\Component\Form\Forms; use Symfony\Component\Validator\Validation; $vendorDirectory = realpath(__DIR__.'/../vendor'); diff --git a/components/http_foundation/session_configuration.rst b/components/http_foundation/session_configuration.rst index f78afca76ee..be941fd85a1 100644 --- a/components/http_foundation/session_configuration.rst +++ b/components/http_foundation/session_configuration.rst @@ -42,8 +42,8 @@ Symfony provides drivers for the following native save handler as an example: Example usage:: use Symfony\Component\HttpFoundation\Session\Session; - use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; + use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; $sessionStorage = new NativeSessionStorage([], new NativeFileSessionHandler()); $session = new Session($sessionStorage); @@ -80,8 +80,8 @@ easily serve as examples if you wish to write your own. Example usage:: use Symfony\Component\HttpFoundation\Session\Session; - use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; + use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; $pdo = new \PDO(...); $sessionStorage = new NativeSessionStorage([], new PdoSessionHandler($pdo)); diff --git a/components/http_foundation/session_testing.rst b/components/http_foundation/session_testing.rst index f6c290fa132..ff6d1f3bd01 100644 --- a/components/http_foundation/session_testing.rst +++ b/components/http_foundation/session_testing.rst @@ -40,8 +40,8 @@ For unit testing where it is not necessary to persist the session, you should simply swap out the default storage engine with :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage`:: - use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Session; + use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; $session = new Session(new MockArraySessionStorage()); diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 5061fe39a5e..9bc5056cfe0 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -101,12 +101,12 @@ is really simple and involves creating an (explained below). To complete your working kernel, you'll add more event listeners to the events discussed below:: - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\EventDispatcher\EventDispatcher; + use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Controller\ArgumentResolver; use Symfony\Component\HttpKernel\Controller\ControllerResolver; + use Symfony\Component\HttpKernel\HttpKernel; // create the Request object $request = Request::createFromGlobals(); diff --git a/components/intl.rst b/components/intl.rst index bc30c85499a..13462b9aa48 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -90,8 +90,8 @@ resulting .txt file can be converted to a binary .res file with the :class:`Symfony\\Component\\Intl\\ResourceBundle\\Compiler\\BundleCompiler` class:: - use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter; use Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompiler; + use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter; $writer = new TextBundleWriter(); $writer->write('/path/to/bundle', 'en', [ diff --git a/components/ldap.rst b/components/ldap.rst index 85c40219ec1..44d4b79a776 100644 --- a/components/ldap.rst +++ b/components/ldap.rst @@ -117,8 +117,8 @@ Creating or Updating Entries The Ldap component provides means to create new LDAP entries, update or even delete existing ones:: - use Symfony\Component\Ldap\Ldap; use Symfony\Component\Ldap\Entry; + use Symfony\Component\Ldap\Ldap; // ... $entry = new Entry('cn=Fabien Potencier,dc=symfony,dc=com', [ diff --git a/components/lock.rst b/components/lock.rst index 529696e082c..9cf85d64cd6 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -245,9 +245,9 @@ is being acquired, it forwards the call to all the managed stores, and it collects their responses. If a simple majority of stores have acquired the lock, then the lock is considered as acquired; otherwise as not acquired:: - use Symfony\Component\Lock\Strategy\ConsensusStrategy; use Symfony\Component\Lock\Store\CombinedStore; use Symfony\Component\Lock\Store\RedisStore; + use Symfony\Component\Lock\Strategy\ConsensusStrategy; $stores = []; foreach (['server1', 'server2', 'server3'] as $server) { diff --git a/components/process.rst b/components/process.rst index ee536512846..c9273fe51a8 100644 --- a/components/process.rst +++ b/components/process.rst @@ -23,8 +23,8 @@ Usage The :class:`Symfony\\Component\\Process\\Process` class allows you to execute a command in a sub-process:: - use Symfony\Component\Process\Process; use Symfony\Component\Process\Exception\ProcessFailedException; + use Symfony\Component\Process\Process; $process = new Process(['ls', '-lsa']); $process->run(); diff --git a/components/property_info.rst b/components/property_info.rst index d00365dcedb..ee20b52c45c 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -37,10 +37,10 @@ To use this component, create a new :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor` instance and provide it with a set of information extractors:: - use Symfony\Component\PropertyInfo\PropertyInfoExtractor; + use Example\Namespace\YourAwesomeCoolClass; use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; - use Example\Namespace\YourAwesomeCoolClass; + use Symfony\Component\PropertyInfo\PropertyInfoExtractor; // a full list of extractors is shown further below $phpDocExtractor = new PhpDocExtractor(); diff --git a/components/routing.rst b/components/routing.rst index c833ae5cf5c..617fc5a8a24 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -316,8 +316,8 @@ If you use the :class:`Symfony\\Component\\Routing\\Loader\\PhpFileLoader` you have to provide the name of a PHP file which returns a :class:`Symfony\\Component\\Routing\\RouteCollection`:: // RouteProvider.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add( @@ -453,8 +453,8 @@ routes with UTF-8 characters: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('route1', new Route('/category/{name}', @@ -534,8 +534,8 @@ You can also include UTF-8 strings as routing requirements: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('route2', new Route('/default/{default}', diff --git a/components/security/authentication.rst b/components/security/authentication.rst index 9430808c825..4b79671ecf8 100644 --- a/components/security/authentication.rst +++ b/components/security/authentication.rst @@ -13,11 +13,11 @@ an *authenticated* token if the supplied credentials were found to be valid. The listener should then store the authenticated token using :class:`the token storage `:: - use Symfony\Component\Security\Http\Firewall\ListenerInterface; - use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; - use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; + use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; + use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; + use Symfony\Component\Security\Http\Firewall\ListenerInterface; class SomeAuthenticationListener implements ListenerInterface { @@ -127,9 +127,9 @@ to create a hash of the password and returns an authenticated token if the password was valid:: use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider; - use Symfony\Component\Security\Core\User\UserChecker; - use Symfony\Component\Security\Core\User\InMemoryUserProvider; use Symfony\Component\Security\Core\Encoder\EncoderFactory; + use Symfony\Component\Security\Core\User\InMemoryUserProvider; + use Symfony\Component\Security\Core\User\UserChecker; $userProvider = new InMemoryUserProvider( [ diff --git a/components/security/authorization.rst b/components/security/authorization.rst index 2f335346d01..eae8872baa0 100644 --- a/components/security/authorization.rst +++ b/components/security/authorization.rst @@ -201,8 +201,8 @@ It uses an access map (which should be an instance of :class:`Symfony\\Component which contains request matchers and a corresponding set of attributes that are required for the current user to get access to the application:: - use Symfony\Component\Security\Http\AccessMap; use Symfony\Component\HttpFoundation\RequestMatcher; + use Symfony\Component\Security\Http\AccessMap; use Symfony\Component\Security\Http\Firewall\AccessListener; $accessMap = new AccessMap(); diff --git a/components/security/firewall.rst b/components/security/firewall.rst index 72000b4cb18..53bd823ad3f 100644 --- a/components/security/firewall.rst +++ b/components/security/firewall.rst @@ -52,9 +52,9 @@ ability to find out if the current request points to a secured area. The listeners are then asked if the current request can be used to authenticate the user:: - use Symfony\Component\Security\Http\FirewallMap; use Symfony\Component\HttpFoundation\RequestMatcher; use Symfony\Component\Security\Http\Firewall\ExceptionListener; + use Symfony\Component\Security\Http\FirewallMap; $firewallMap = new FirewallMap(); @@ -70,8 +70,8 @@ the user:: The firewall map will be given to the firewall as its first argument, together with the event dispatcher that is used by the :class:`Symfony\\Component\\HttpKernel\\HttpKernel`:: - use Symfony\Component\Security\Http\Firewall; use Symfony\Component\HttpKernel\KernelEvents; + use Symfony\Component\Security\Http\Firewall; // the EventDispatcher used by the HttpKernel $dispatcher = ...; diff --git a/components/serializer.rst b/components/serializer.rst index 3dae4cf048b..8838882f7d3 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -48,10 +48,11 @@ Using the Serializer component is really simple. You just need to set up the :class:`Symfony\\Component\\Serializer\\Serializer` specifying which encoders and normalizer are going to be available:: - use Symfony\Component\Serializer\Serializer; - use Symfony\Component\Serializer\Encoder\XmlEncoder; + use Symfony\Component\Serializer\Encoder\JsonEncoder; + use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; $encoders = [new XmlEncoder(), new JsonEncoder()]; $normalizers = [new ObjectNormalizer()]; @@ -335,8 +336,8 @@ Then, create your groups definition: You are now able to serialize only attributes in the groups you want:: - use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; $obj = new MyObj(); $obj->foo = 'foo'; @@ -365,8 +366,8 @@ Selecting Specific Attributes It is also possible to serialize only a set of specific attributes:: - use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; class User { @@ -413,9 +414,9 @@ those attributes use the :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setIgnoredAttributes` method on the normalizer definition:: - use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; $normalizer = new ObjectNormalizer(); $normalizer->setIgnoredAttributes(['age']); @@ -989,9 +990,9 @@ parameter of the ``ObjectNormalizer``:: namespace Acme; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; - use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; class ObjectOuter { diff --git a/components/templating.rst b/components/templating.rst index b667985cdc1..bb052c17285 100644 --- a/components/templating.rst +++ b/components/templating.rst @@ -39,9 +39,9 @@ template reference (:class:`Symfony\\Component\\Templating\\TemplateReferenceInt It also needs a template loader (:class:`Symfony\\Component\\Templating\\Loader\\LoaderInterface`) which uses the template reference to actually find and load the template:: + use Symfony\Component\Templating\Loader\FilesystemLoader; use Symfony\Component\Templating\PhpEngine; use Symfony\Component\Templating\TemplateNameParser; - use Symfony\Component\Templating\Loader\FilesystemLoader; $filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%'); @@ -194,8 +194,8 @@ choose which one to use for the template, the method is used:: use Acme\Templating\CustomEngine; - use Symfony\Component\Templating\PhpEngine; use Symfony\Component\Templating\DelegatingEngine; + use Symfony\Component\Templating\PhpEngine; $templating = new DelegatingEngine([ new PhpEngine(...), diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index 8856b41c006..faa305f49f2 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -30,8 +30,8 @@ new class that implements the method will get a filename and parse it into an array. Then, it will create the catalog that will be returned:: - use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Loader\LoaderInterface; + use Symfony\Component\Translation\MessageCatalogue; class MyFormatLoader implements LoaderInterface { @@ -80,8 +80,8 @@ must be created. To write the dump contents into a file, extending the :class:`Symfony\\Component\\Translation\\Dumper\\FileDumper` class will save a few lines:: - use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Dumper\FileDumper; + use Symfony\Component\Translation\MessageCatalogue; class MyFormatDumper extends FileDumper { diff --git a/components/translation/usage.rst b/components/translation/usage.rst index f0c0cbcf723..fdc0f77eaef 100644 --- a/components/translation/usage.rst +++ b/components/translation/usage.rst @@ -6,8 +6,8 @@ Using the Translator Imagine you want to translate the string *"Symfony is great"* into French:: - use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Loader\ArrayLoader; + use Symfony\Component\Translation\Translator; $translator = new Translator('fr_FR'); $translator->addLoader('array', new ArrayLoader()); @@ -472,8 +472,8 @@ When using the standalone Translation component, call the ``setMetadata()`` method of the catalogue and pass the notes as arrays. This is for example the code needed to generate the previous XLIFF file:: - use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Dumper\XliffFileDumper; + use Symfony\Component\Translation\MessageCatalogue; $catalogue = new MessageCatalogue('en_US'); $catalogue->add([ diff --git a/components/validator.rst b/components/validator.rst index 0b2c8e09a91..4ca9dd38cac 100644 --- a/components/validator.rst +++ b/components/validator.rst @@ -34,9 +34,9 @@ The Validator component behavior is based on two concepts: The following example shows how to validate that a string is at least 10 characters long:: - use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\Validation; $validator = Validation::createValidator(); $violations = $validator->validate('Bernhard', [ diff --git a/components/validator/metadata.rst b/components/validator/metadata.rst index 77c4037cc48..f5df3fa68de 100755 --- a/components/validator/metadata.rst +++ b/components/validator/metadata.rst @@ -15,8 +15,8 @@ The following example shows how to validate that the ``$firstName`` property of the ``Author`` class has at least 3 characters:: // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -51,8 +51,8 @@ doesn't match the first name of the user. First, create a public method called Then, add the Validator component configuration to the class:: // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -85,8 +85,8 @@ validation logic:: Then, add the Validator component configuration to the class:: // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 83b4f47efa9..e6cc02227d1 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -35,8 +35,8 @@ method of the validator builder:: In this example, the validation metadata is retrieved executing the ``loadValidatorMetadata()`` method of the class:: - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/components/var_dumper/advanced.rst b/components/var_dumper/advanced.rst index 3f2d7aeafe7..31d015793ca 100644 --- a/components/var_dumper/advanced.rst +++ b/components/var_dumper/advanced.rst @@ -15,10 +15,10 @@ By adding a handler, you can customize the `Cloners`_, `Dumpers`_ and `Casters`_ as explained below. A simple implementation of a handler function might look like this:: - use Symfony\Component\VarDumper\VarDumper; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; use Symfony\Component\VarDumper\Dumper\HtmlDumper; + use Symfony\Component\VarDumper\VarDumper; VarDumper::setHandler(function ($var) { $cloner = new VarCloner(); diff --git a/components/workflow.rst b/components/workflow.rst index cafd1351b93..e54e01d8683 100644 --- a/components/workflow.rst +++ b/components/workflow.rst @@ -40,9 +40,9 @@ of predefined statuses (`draft`, `review`, `rejected`, `published`). In a workfl these statuses are called **places**. You can define the workflow like this:: use Symfony\Component\Workflow\DefinitionBuilder; + use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore; use Symfony\Component\Workflow\Transition; use Symfony\Component\Workflow\Workflow; - use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore; $definitionBuilder = new DefinitionBuilder(); $definition = $definitionBuilder->addPlaces(['draft', 'review', 'rejected', 'published']) @@ -71,9 +71,9 @@ which is an object that stores and provides access to different workflows. A registry will also help you to decide if a workflow supports the object you are trying to use it with:: - use Symfony\Component\Workflow\Registry; use Acme\Entity\BlogPost; use Acme\Entity\Newsletter; + use Symfony\Component\Workflow\Registry; $blogWorkflow = ... $newsletterWorkflow = ... diff --git a/configuration/configuration_organization.rst b/configuration/configuration_organization.rst index c8574e905be..5b662023ee7 100644 --- a/configuration/configuration_organization.rst +++ b/configuration/configuration_organization.rst @@ -14,8 +14,8 @@ executes the ``registerContainerConfiguration()`` method of the ``AppKernel`` class:: // app/AppKernel.php - use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; + use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { @@ -90,8 +90,8 @@ To make this work, change the code of the method:: // app/AppKernel.php - use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; + use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { @@ -187,8 +187,8 @@ Again, change the code of the ``registerContainerConfiguration()`` method to make Symfony aware of the new file organization:: // app/AppKernel.php - use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; + use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 70f88d4e3f8..f4d7cd5183d 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -133,12 +133,12 @@ putting *everything* in ``index.php``, create a new ``app/AppKernel.php`` to hold the kernel. Now it looks like this:: // app/AppKernel.php + use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Routing\RouteCollectionBuilder; - use Doctrine\Common\Annotations\AnnotationRegistry; // require Composer's autoloader $loader = require __DIR__.'/../vendor/autoload.php'; diff --git a/configuration/multiple_kernels.rst b/configuration/multiple_kernels.rst index 59bf51b5103..4157e5c0372 100644 --- a/configuration/multiple_kernels.rst +++ b/configuration/multiple_kernels.rst @@ -79,8 +79,8 @@ sure to also change the location of the cache, logs and configuration files so they don't collide with the files from ``AppKernel``:: // app/ApiKernel.php - use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; + use Symfony\Component\HttpKernel\Kernel; class ApiKernel extends Kernel { diff --git a/console.rst b/console.rst index 7b862ba79d9..ee971da513b 100644 --- a/console.rst +++ b/console.rst @@ -210,8 +210,8 @@ as a service, you can use normal dependency injection. Imagine you have a ``AppBundle\Service\UserManager`` service that you want to access:: // ... - use Symfony\Component\Console\Command\Command; use AppBundle\Service\UserManager; + use Symfony\Component\Console\Command\Command; class CreateUserCommand extends Command { diff --git a/console/style.rst b/console/style.rst index ed9cacbce63..466f20ac744 100644 --- a/console/style.rst +++ b/console/style.rst @@ -54,9 +54,9 @@ title of the command:: namespace AppBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; - use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use Symfony\Component\Console\Style\SymfonyStyle; class GreetCommand extends ContainerAwareCommand { diff --git a/controller/soap_web_service.rst b/controller/soap_web_service.rst index 92d73760deb..4fd695ddff5 100644 --- a/controller/soap_web_service.rst +++ b/controller/soap_web_service.rst @@ -59,10 +59,10 @@ can be retrieved via ``/soap?wsdl``:: namespace AppBundle\Controller; + use AppBundle\Service\HelloService; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; - use AppBundle\Service\HelloService; class HelloServiceController extends Controller { diff --git a/controller/upload_file.rst b/controller/upload_file.rst index b07095de4f3..84c7c5b93c9 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -56,9 +56,9 @@ Then, add a new ``brochure`` field to the form that manages the ``Product`` enti use AppBundle\Entity\Product; use Symfony\Component\Form\AbstractType; + use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - use Symfony\Component\Form\Extension\Core\Type\FileType; class ProductType extends AbstractType { @@ -99,12 +99,12 @@ Finally, you need to update the code of the controller that handles the form:: // src/AppBundle/Controller/ProductController.php namespace AppBundle\Controller; + use AppBundle\Entity\Product; + use AppBundle\Form\ProductType; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; - use AppBundle\Entity\Product; - use AppBundle\Form\ProductType; class ProductController extends Controller { @@ -290,8 +290,8 @@ Then, define a service for this class: Now you're ready to use this service in the controller:: // src/AppBundle/Controller/ProductController.php - use Symfony\Component\HttpFoundation\Request; use AppBundle\Service\FileUploader; + use Symfony\Component\HttpFoundation\Request; // ... public function newAction(Request $request, FileUploader $fileUploader) @@ -320,12 +320,12 @@ automatically move the file when persisting the entity:: // src/AppBundle/EventListener/BrochureUploadListener.php namespace AppBundle\EventListener; - use Symfony\Component\HttpFoundation\File\UploadedFile; - use Symfony\Component\HttpFoundation\File\File; - use Doctrine\ORM\Event\LifecycleEventArgs; - use Doctrine\ORM\Event\PreUpdateEventArgs; use AppBundle\Entity\Product; use AppBundle\Service\FileUploader; + use Doctrine\ORM\Event\LifecycleEventArgs; + use Doctrine\ORM\Event\PreUpdateEventArgs; + use Symfony\Component\HttpFoundation\File\File; + use Symfony\Component\HttpFoundation\File\UploadedFile; class BrochureUploadListener { diff --git a/create_framework/dependency_injection.rst b/create_framework/dependency_injection.rst index 35d2cfb86fc..feefb0008af 100644 --- a/create_framework/dependency_injection.rst +++ b/create_framework/dependency_injection.rst @@ -97,13 +97,13 @@ container: Create a new file to host the dependency injection container configuration:: // example.com/src/container.php + use Simplex\Framework; use Symfony\Component\DependencyInjection; use Symfony\Component\DependencyInjection\Reference; + use Symfony\Component\EventDispatcher; use Symfony\Component\HttpFoundation; use Symfony\Component\HttpKernel; use Symfony\Component\Routing; - use Symfony\Component\EventDispatcher; - use Simplex\Framework; $containerBuilder = new DependencyInjection\ContainerBuilder(); $containerBuilder->register('context', Routing\RequestContext::class); diff --git a/create_framework/event_dispatcher.rst b/create_framework/event_dispatcher.rst index 4345bbaa2ef..ec7cf1dec28 100644 --- a/create_framework/event_dispatcher.rst +++ b/create_framework/event_dispatcher.rst @@ -88,9 +88,9 @@ now dispatched:: // example.com/src/Simplex/ResponseEvent.php namespace Simplex; + use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\EventDispatcher\Event; class ResponseEvent extends Event { diff --git a/create_framework/http_kernel_controller_resolver.rst b/create_framework/http_kernel_controller_resolver.rst index 48a331ed36d..90d9efa582a 100644 --- a/create_framework/http_kernel_controller_resolver.rst +++ b/create_framework/http_kernel_controller_resolver.rst @@ -163,8 +163,8 @@ Let's conclude with the new version of our framework:: use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Routing; use Symfony\Component\HttpKernel; + use Symfony\Component\Routing; function render_template(Request $request) { diff --git a/create_framework/http_kernel_httpkernel_class.rst b/create_framework/http_kernel_httpkernel_class.rst index a607cf1ae86..a7c90a45e2a 100644 --- a/create_framework/http_kernel_httpkernel_class.rst +++ b/create_framework/http_kernel_httpkernel_class.rst @@ -91,8 +91,8 @@ The error controller reads as follows:: // example.com/src/Calendar/Controller/ErrorController.php namespace Calendar\Controller; - use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Debug\Exception\FlattenException; + use Symfony\Component\HttpFoundation\Response; class ErrorController { @@ -153,8 +153,8 @@ only if needed:: namespace Simplex; use Symfony\Component\EventDispatcher\EventSubscriberInterface; - use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; class StringResponseListener implements EventSubscriberInterface { diff --git a/create_framework/routing.rst b/create_framework/routing.rst index de06ebcbddc..f4d3a5db57e 100644 --- a/create_framework/routing.rst +++ b/create_framework/routing.rst @@ -80,8 +80,8 @@ of default values for route attributes (``['name' => 'World']``). Based on the information stored in the ``RouteCollection`` instance, a ``UrlMatcher`` instance can match URL paths:: - use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\Matcher\UrlMatcher; + use Symfony\Component\Routing\RequestContext; $context = new RequestContext(); $context->fromRequest($request); diff --git a/create_framework/separation_of_concerns.rst b/create_framework/separation_of_concerns.rst index 1811ec2e813..c318d2da459 100644 --- a/create_framework/separation_of_concerns.rst +++ b/create_framework/separation_of_concerns.rst @@ -100,9 +100,9 @@ Move the controller to ``Calendar\Controller\LeapYearController``:: // example.com/src/Calendar/Controller/LeapYearController.php namespace Calendar\Controller; + use Calendar\Model\LeapYear; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Calendar\Model\LeapYear; class LeapYearController { diff --git a/create_framework/templating.rst b/create_framework/templating.rst index 8b2801c8e5a..86eea7d7c20 100644 --- a/create_framework/templating.rst +++ b/create_framework/templating.rst @@ -142,8 +142,8 @@ framework does not need to be modified in any way, just create a new ``app.php`` file:: // example.com/src/app.php - use Symfony\Component\Routing; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\Routing; function is_leap_year($year = null) { if (null === $year) { diff --git a/create_framework/unit_testing.rst b/create_framework/unit_testing.rst index af279a126cc..ca406e1365f 100644 --- a/create_framework/unit_testing.rst +++ b/create_framework/unit_testing.rst @@ -50,9 +50,9 @@ resolver. Modify the framework to make use of them:: // ... - use Symfony\Component\Routing\Matcher\UrlMatcherInterface; - use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; + use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; + use Symfony\Component\Routing\Matcher\UrlMatcherInterface; class Framework { @@ -151,8 +151,8 @@ Last, but not the least, let's write a test for when we actually have a proper Response:: use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\HttpKernel\Controller\ControllerResolver; use Symfony\Component\HttpKernel\Controller\ArgumentResolver; + use Symfony\Component\HttpKernel\Controller\ControllerResolver; // ... public function testControllerResponse() diff --git a/doctrine.rst b/doctrine.rst index 4fe4a4873fa..9ff5a497620 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -520,8 +520,8 @@ a controller, this is pretty easy. Add the following method to the // ... use AppBundle\Entity\Product; - use Symfony\Component\HttpFoundation\Response; use Doctrine\ORM\EntityManagerInterface; + use Symfony\Component\HttpFoundation\Response; public function createAction() { diff --git a/doctrine/custom_dql_functions.rst b/doctrine/custom_dql_functions.rst index 3c573330cd0..ad3a9bfc7e7 100644 --- a/doctrine/custom_dql_functions.rst +++ b/doctrine/custom_dql_functions.rst @@ -53,10 +53,10 @@ In Symfony, you can register your custom DQL functions as follows: .. code-block:: php // app/config/config.php - use AppBundle\DQL\StringFunction; - use AppBundle\DQL\SecondStringFunction; - use AppBundle\DQL\NumericFunction; use AppBundle\DQL\DatetimeFunction; + use AppBundle\DQL\NumericFunction; + use AppBundle\DQL\SecondStringFunction; + use AppBundle\DQL\StringFunction; $container->loadFromExtension('doctrine', [ 'orm' => [ diff --git a/doctrine/event_listeners_subscribers.rst b/doctrine/event_listeners_subscribers.rst index 2e5dc91e242..fc60d9a6e3d 100644 --- a/doctrine/event_listeners_subscribers.rst +++ b/doctrine/event_listeners_subscribers.rst @@ -95,9 +95,9 @@ a ``postPersist()`` method, which will be called when the event is dispatched:: // src/AppBundle/EventListener/SearchIndexer.php namespace AppBundle\EventListener; + use AppBundle\Entity\Product; // for Doctrine < 2.4: use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\Common\Persistence\Event\LifecycleEventArgs; - use AppBundle\Entity\Product; class SearchIndexer { @@ -140,11 +140,11 @@ interface and have an event method for each event it subscribes to:: // src/AppBundle/EventListener/SearchIndexerSubscriber.php namespace AppBundle\EventListener; + use AppBundle\Entity\Product; use Doctrine\Common\EventSubscriber; // for Doctrine < 2.4: use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use Doctrine\ORM\Events; - use AppBundle\Entity\Product; class SearchIndexerSubscriber implements EventSubscriber { diff --git a/doctrine/mapping_model_classes.rst b/doctrine/mapping_model_classes.rst index d3f2f6f46dd..10ac398e78a 100644 --- a/doctrine/mapping_model_classes.rst +++ b/doctrine/mapping_model_classes.rst @@ -20,9 +20,9 @@ In your bundle class, write the following code to register the compiler pass. This one is written for the CmfRoutingBundle, so parts of it will need to be adapted for your case:: + use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass; use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass; - use Doctrine\Bundle\CouchDBBundle\DependencyInjection\Compiler\DoctrineCouchDBMappingsPass; use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass; use Symfony\Cmf\RoutingBundle\Model; @@ -115,9 +115,9 @@ Annotations, XML, Yaml, PHP and StaticPHP. The arguments are: ``DoctrineOrmMappingsPass`` and adapted to use the ``DefaultFileLocator`` instead of the ``SymfonyFileLocator``:: + use AppBundle\Model; use Doctrine\Common\Persistence\Mapping\Driver\DefaultFileLocator; use Doctrine\ORM\Mapping\Driver\XmlDriver; - use AppBundle\Model; // ... private function buildMappingCompilerPass() diff --git a/doctrine/registration_form.rst b/doctrine/registration_form.rst index 940d01bb803..80aa8eb27e5 100644 --- a/doctrine/registration_form.rst +++ b/doctrine/registration_form.rst @@ -43,9 +43,9 @@ With some validation added, your class may look something like this:: namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; - use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; + use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -189,12 +189,12 @@ Next, create the form for the ``User`` entity:: use AppBundle\Entity\User; use Symfony\Component\Form\AbstractType; - use Symfony\Component\Form\FormBuilderInterface; - use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\EmailType; - use Symfony\Component\Form\Extension\Core\Type\TextType; - use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\PasswordType; + use Symfony\Component\Form\Extension\Core\Type\RepeatedType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; + use Symfony\Component\OptionsResolver\OptionsResolver; class UserType extends AbstractType { @@ -237,8 +237,8 @@ into the database:: // src/AppBundle/Controller/RegistrationController.php namespace AppBundle\Controller; - use AppBundle\Form\UserType; use AppBundle\Entity\User; + use AppBundle\Form\UserType; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; @@ -351,8 +351,8 @@ the :ref:`user password encoding ` article. .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('user_registration', new Route('/register', [ @@ -430,9 +430,10 @@ To do this, add a ``termsAccepted`` field to your form, but set its // src/AppBundle/Form/UserType.php // ... - use Symfony\Component\Validator\Constraints\IsTrue; + use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\EmailType; + use Symfony\Component\Validator\Constraints\IsTrue; class UserType extends AbstractType { diff --git a/doctrine/resolve_target_entity.rst b/doctrine/resolve_target_entity.rst index 0fc7bff0fe5..543f7711252 100644 --- a/doctrine/resolve_target_entity.rst +++ b/doctrine/resolve_target_entity.rst @@ -42,9 +42,9 @@ A Customer entity:: // src/AppBundle/Entity/Customer.php namespace AppBundle\Entity; - use Doctrine\ORM\Mapping as ORM; use Acme\CustomerBundle\Entity\Customer as BaseCustomer; use Acme\InvoiceBundle\Model\InvoiceSubjectInterface; + use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity @@ -61,8 +61,8 @@ An Invoice entity:: // src/Acme/InvoiceBundle/Entity/Invoice.php namespace Acme\InvoiceBundle\Entity; - use Doctrine\ORM\Mapping as ORM; use Acme\InvoiceBundle\Model\InvoiceSubjectInterface; + use Doctrine\ORM\Mapping as ORM; /** * Represents an Invoice. diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 8d0f540136f..a35e8f604f2 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -26,8 +26,8 @@ The most common way to listen to an event is to register an **event listener**:: // src/AppBundle/EventListener/ExceptionListener.php namespace AppBundle\EventListener; - use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class ExceptionListener diff --git a/event_dispatcher/before_after_filters.rst b/event_dispatcher/before_after_filters.rst index 9d07e915022..ccfa0e4f94f 100644 --- a/event_dispatcher/before_after_filters.rst +++ b/event_dispatcher/before_after_filters.rst @@ -115,9 +115,9 @@ event subscribers, you can learn more about them at :doc:`/event_dispatcher`:: namespace AppBundle\EventSubscriber; use AppBundle\Controller\TokenAuthenticatedController; - use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; - use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; + use Symfony\Component\HttpKernel\Event\FilterControllerEvent; + use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\KernelEvents; class TokenSubscriber implements EventSubscriberInterface diff --git a/event_dispatcher/method_behavior.rst b/event_dispatcher/method_behavior.rst index 2b179039c29..5ea5e74ffab 100644 --- a/event_dispatcher/method_behavior.rst +++ b/event_dispatcher/method_behavior.rst @@ -114,8 +114,8 @@ could listen to the ``mailer.post_send`` event and change the method's return va // src/AppBundle/EventSubscriber/MailPostSendSubscriber.php namespace AppBundle\EventSubscriber; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use AppBundle\Event\AfterSendMailEvent; + use Symfony\Component\EventDispatcher\EventSubscriberInterface; class MailPostSendSubscriber implements EventSubscriberInterface { diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index 46a84cbaab0..e0683d8e9c9 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -26,8 +26,8 @@ which already implements that interface and provides some utilities:: namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; - use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; + use Symfony\Component\OptionsResolver\OptionsResolver; class ShippingType extends AbstractType { @@ -255,9 +255,9 @@ of the type in one of your forms:: // src/AppBundle/Form/Type/OrderType.php namespace AppBundle\Form\Type; + use AppBundle\Form\Type\ShippingType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; - use AppBundle\Form\Type\ShippingType; class OrderType extends AbstractType { diff --git a/form/create_form_type_extension.rst b/form/create_form_type_extension.rst index 4632cd2da3a..cf5a34cf987 100644 --- a/form/create_form_type_extension.rst +++ b/form/create_form_type_extension.rst @@ -173,11 +173,11 @@ For example:: namespace AppBundle\Form\Extension; use Symfony\Component\Form\AbstractTypeExtension; - use Symfony\Component\Form\FormView; + use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\FormInterface; - use Symfony\Component\PropertyAccess\PropertyAccess; + use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; - use Symfony\Component\Form\Extension\Core\Type\FileType; + use Symfony\Component\PropertyAccess\PropertyAccess; class ImageTypeExtension extends AbstractTypeExtension { @@ -252,9 +252,9 @@ next to the file field. For example:: namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; - use Symfony\Component\Form\FormBuilderInterface; - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\FileType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; class MediaType extends AbstractType { diff --git a/form/data_transformers.rst b/form/data_transformers.rst index 880845163b9..cd70f049ccf 100644 --- a/form/data_transformers.rst +++ b/form/data_transformers.rst @@ -33,9 +33,9 @@ Suppose you have a Task form with a tags ``text`` type:: namespace AppBundle\Form\Type; use AppBundle\Entity\Task; + use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - use Symfony\Component\Form\Extension\Core\Type\TextType; // ... class TaskType extends AbstractType @@ -66,8 +66,9 @@ class:: namespace AppBundle\Form\Type; use Symfony\Component\Form\CallbackTransformer; - use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; + // ... class TaskType extends AbstractType diff --git a/form/dynamic_form_modification.rst b/form/dynamic_form_modification.rst index aea0b02d175..a0b6fee1c43 100644 --- a/form/dynamic_form_modification.rst +++ b/form/dynamic_form_modification.rst @@ -144,10 +144,10 @@ you can also move the logic for creating the ``name`` field to an // src/AppBundle/Form/EventListener/AddNameFieldSubscriber.php namespace AppBundle\Form\EventListener; - use Symfony\Component\Form\FormEvent; - use Symfony\Component\Form\FormEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormEvent; + use Symfony\Component\Form\FormEvents; class AddNameFieldSubscriber implements EventSubscriberInterface { @@ -209,11 +209,11 @@ Using an event listener, your form might look like this:: namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; + use Symfony\Component\Form\Extension\Core\Type\TextareaType; + use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; - use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; - use Symfony\Component\Form\Extension\Core\Type\TextType; - use Symfony\Component\Form\Extension\Core\Type\TextareaType; + use Symfony\Component\Form\FormEvents; class FriendMessageFormType extends AbstractType { @@ -259,8 +259,8 @@ security helper to fill in the listener logic:: use AppBundle\Entity\User; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; + use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Security\Core\Security; // ... @@ -376,11 +376,11 @@ sport like this:: // src/AppBundle/Form/Type/SportMeetupType.php namespace AppBundle\Form\Type; + use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; - use Symfony\Bridge\Doctrine\Form\Type\EntityType; // ... class SportMeetupType extends AbstractType @@ -443,9 +443,9 @@ The type would now look like:: namespace AppBundle\Form\Type; // ... - use Symfony\Component\Form\FormInterface; - use Symfony\Bridge\Doctrine\Form\Type\EntityType; use AppBundle\Entity\Sport; + use Symfony\Bridge\Doctrine\Form\Type\EntityType; + use Symfony\Component\Form\FormInterface; class SportMeetupType extends AbstractType { @@ -512,10 +512,10 @@ your application. Assume that you have a sport meetup creation controller:: // src/AppBundle/Controller/MeetupController.php namespace AppBundle\Controller; - use Symfony\Bundle\FrameworkBundle\Controller\Controller; - use Symfony\Component\HttpFoundation\Request; use AppBundle\Entity\SportMeetup; use AppBundle\Form\Type\SportMeetupType; + use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Symfony\Component\HttpFoundation\Request; // ... class MeetupController extends Controller diff --git a/form/embedded.rst b/form/embedded.rst index edc20e4a57c..7b663457e68 100644 --- a/form/embedded.rst +++ b/form/embedded.rst @@ -94,8 +94,8 @@ inside the task form itself. To accomplish this, add a ``category`` field to the ``TaskType`` object whose type is an instance of the new ``CategoryType`` class:: - use Symfony\Component\Form\FormBuilderInterface; use AppBundle\Form\CategoryType; + use Symfony\Component\Form\FormBuilderInterface; public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/form/events.rst b/form/events.rst index 0aaa2ed7b95..f9a59c7cbee 100644 --- a/form/events.rst +++ b/form/events.rst @@ -267,11 +267,11 @@ Creating and binding an event listener to the form:: // ... - use Symfony\Component\Form\FormEvent; - use Symfony\Component\Form\FormEvents; - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\EmailType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormEvent; + use Symfony\Component\Form\FormEvents; $form = $formFactory->createBuilder() ->add('username', TextType::class) @@ -304,8 +304,8 @@ callback for better readability:: // src/AppBundle/Form/SubscriptionType.php namespace AppBundle\Form; - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; + use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; @@ -345,9 +345,9 @@ Consider the following example of a form event subscriber:: namespace AppBundle\Form\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; + use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; - use Symfony\Component\Form\Extension\Core\Type\EmailType; class AddEmailFieldListener implements EventSubscriberInterface { @@ -395,8 +395,8 @@ Consider the following example of a form event subscriber:: To register the event subscriber, use the ``addEventSubscriber()`` method:: use AppBundle\Form\EventListener\AddEmailFieldListener; - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; + use Symfony\Component\Form\Extension\Core\Type\TextType; // ... diff --git a/form/form_collections.rst b/form/form_collections.rst index 7861121fee9..f3806f4ab45 100644 --- a/form/form_collections.rst +++ b/form/form_collections.rst @@ -119,9 +119,9 @@ Notice that you embed a collection of ``TagType`` forms using the use AppBundle\Entity\Task; use Symfony\Component\Form\AbstractType; + use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - use Symfony\Component\Form\Extension\Core\Type\CollectionType; class TaskType extends AbstractType { @@ -148,11 +148,11 @@ In your controller, you'll create a new form from the ``TaskType``:: // src/AppBundle/Controller/TaskController.php namespace AppBundle\Controller; - use AppBundle\Entity\Task; use AppBundle\Entity\Tag; + use AppBundle\Entity\Task; use AppBundle\Form\Type\TaskType; - use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Symfony\Component\HttpFoundation\Request; class TaskController extends Controller { diff --git a/form/form_customization.rst b/form/form_customization.rst index 9f37c3d90e8..0be0be98b69 100644 --- a/form/form_customization.rst +++ b/form/form_customization.rst @@ -547,8 +547,8 @@ field whose *id* is ``product_name`` (and name is ``product[name]``). name ``_product_name_widget`` you can set the ``block_name`` option in your form type:: - use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/form/inherit_data_option.rst b/form/inherit_data_option.rst index 07f53826529..9669c1b44ad 100644 --- a/form/inherit_data_option.rst +++ b/form/inherit_data_option.rst @@ -47,8 +47,8 @@ Start with building two forms for these entities, ``CompanyType`` and ``Customer namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; - use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; class CompanyType extends AbstractType { @@ -65,9 +65,9 @@ Start with building two forms for these entities, ``CompanyType`` and ``Customer // src/AppBundle/Form/Type/CustomerType.php namespace AppBundle\Form\Type; - use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; class CustomerType extends AbstractType { @@ -87,10 +87,10 @@ for that:: namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; - use Symfony\Component\Form\FormBuilderInterface; - use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; + use Symfony\Component\OptionsResolver\OptionsResolver; class LocationType extends AbstractType { diff --git a/form/type_guesser.rst b/form/type_guesser.rst index 9838e635c42..985235ecd04 100644 --- a/form/type_guesser.rst +++ b/form/type_guesser.rst @@ -86,12 +86,12 @@ With this knowledge, you can implement the ``guessType()`` method of the namespace AppBundle\Form\TypeGuesser; - use Symfony\Component\Form\Guess\Guess; - use Symfony\Component\Form\Guess\TypeGuess; - use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\NumberType; - use Symfony\Component\Form\Extension\Core\Type\CheckboxType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\Guess\Guess; + use Symfony\Component\Form\Guess\TypeGuess; class PHPDocTypeGuesser implements FormTypeGuesserInterface { @@ -228,8 +228,8 @@ and tag it with ``form.type_guesser``: :method:`Symfony\\Component\\Form\\FormFactoryBuilder::addTypeGuessers` of the ``FormFactoryBuilder`` to register new type guessers:: - use Symfony\Component\Form\Forms; use Acme\Form\PHPDocTypeGuesser; + use Symfony\Component\Form\Forms; $formFactory = Forms::createFormFactoryBuilder() // ... diff --git a/form/use_empty_data.rst b/form/use_empty_data.rst index 284dd12c863..a3da113d6e2 100644 --- a/form/use_empty_data.rst +++ b/form/use_empty_data.rst @@ -46,8 +46,8 @@ that constructor with no arguments:: // src/AppBundle/Form/Type/BlogType.php // ... - use Symfony\Component\Form\AbstractType; use AppBundle\Entity\Blog; + use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; class BlogType extends AbstractType @@ -87,8 +87,8 @@ if it is needed. The closure must accept a ``FormInterface`` instance as the first argument:: - use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\FormInterface; + use Symfony\Component\OptionsResolver\OptionsResolver; // ... public function configureOptions(OptionsResolver $resolver) diff --git a/form/without_class.rst b/form/without_class.rst index 48fcb86e157..ae5fa3e9ddf 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -79,10 +79,10 @@ The answer is to setup the constraints yourself, and attach them to the individu fields. The overall approach is covered a bit more in :doc:`this validation article `, but here's a short example:: - use Symfony\Component\Validator\Constraints\Length; - use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; + use Symfony\Component\Validator\Constraints\Length; + use Symfony\Component\Validator\Constraints\NotBlank; public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/forms.rst b/forms.rst index b68b775ddf0..908acf238d9 100644 --- a/forms.rst +++ b/forms.rst @@ -83,10 +83,10 @@ from inside a controller:: use AppBundle\Entity\Task; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\HttpFoundation\Request; class DefaultController extends Controller { @@ -365,9 +365,9 @@ object. .. code-block:: php // src/AppBundle/Entity/Task.php - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Type; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Task { @@ -582,8 +582,8 @@ that will house the logic for building the task form:: namespace AppBundle\Form; use Symfony\Component\Form\AbstractType; - use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\SubmitType; + use Symfony\Component\Form\FormBuilderInterface; class TaskType extends AbstractType { diff --git a/frontend/custom_version_strategy.rst b/frontend/custom_version_strategy.rst index 6c8cbcc6c0d..10bb4c3dfcf 100644 --- a/frontend/custom_version_strategy.rst +++ b/frontend/custom_version_strategy.rst @@ -146,8 +146,8 @@ After creating the strategy PHP class, register it as a Symfony service. .. code-block:: php // app/config/services.php - use Symfony\Component\DependencyInjection\Definition; use AppBundle\Asset\VersionStrategy\GulpBusterVersionStrategy; + use Symfony\Component\DependencyInjection\Definition; $container->autowire(GulpBusterVersionStrategy::class) ->setArguments( diff --git a/http_cache/validation.rst b/http_cache/validation.rst index 64fdf370579..44cc8cc30d6 100644 --- a/http_cache/validation.rst +++ b/http_cache/validation.rst @@ -115,9 +115,9 @@ header value:: namespace AppBundle\Controller; // ... - use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\HttpFoundation\Request; use AppBundle\Entity\Article; + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\HttpFoundation\Response; class ArticleController extends Controller { @@ -175,8 +175,8 @@ exposing a simple and efficient pattern:: namespace AppBundle\Controller; // ... - use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\HttpFoundation\Response; class ArticleController extends Controller { diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 8ec9f4822b1..55ae1e42ec3 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -24,9 +24,9 @@ request:: // src/AppBundle/DataCollector/RequestCollector.php namespace AppBundle\DataCollector; - use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\DataCollector\DataCollector; class RequestCollector extends DataCollector { diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index 0a95103d62e..bdbb58add3e 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -80,8 +80,8 @@ entry in that array: // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst index 7995431e7d8..efc56dd965c 100644 --- a/reference/constraints/Bic.rst +++ b/reference/constraints/Bic.rst @@ -68,8 +68,8 @@ will contain a Business Identifier Code (BIC). // src/AppBundle/Entity/Transaction.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Transaction { diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 0622cbf500c..20dedfe5444 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -76,8 +76,8 @@ of an ``Author`` class were blank, you could do the following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index 95ab8a6a2ac..1331631cb26 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -78,8 +78,8 @@ Configuration // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -210,8 +210,8 @@ You can then use the following configuration to invoke this validator: namespace AppBundle\Entity; use Acme\Validator; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -238,10 +238,9 @@ constructor of the Callback constraint:: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; + use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; - use Symfony\Component\Validator\Mapping\ClassMetadata; - use Symfony\Component\Validator\Constraints as Assert; class Author { diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 1a68b413865..b186d9245fe 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -79,8 +79,8 @@ on an object that will contain a credit card number. // src/AppBundle/Entity/Transaction.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Transaction { diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 231f2acba8f..65378aec8c3 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -107,8 +107,8 @@ If your valid choice list is simple, you can pass them in directly via the // src/AppBundle/EntityAuthor.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -198,8 +198,8 @@ constraint. // src/AppBundle/EntityAuthor.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -267,8 +267,8 @@ you can pass the class name and the method as an array. namespace AppBundle\Entity; use AppBundle\Entity\Genre; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 94db7909dea..a5bfe840860 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -136,8 +136,8 @@ following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -259,8 +259,8 @@ you can do the following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index 6308aeba33a..82c77f5031d 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -85,8 +85,8 @@ you might add the following: // src/AppBundle/Entity/Participant.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Participant { diff --git a/reference/constraints/Country.rst b/reference/constraints/Country.rst index 7c52723953a..5f33ced3ce4 100644 --- a/reference/constraints/Country.rst +++ b/reference/constraints/Country.rst @@ -63,8 +63,8 @@ Basic Usage // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 0292cc8100c..33b635a85c9 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -66,8 +66,8 @@ a valid currency, you could do the following: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { diff --git a/reference/constraints/Date.rst b/reference/constraints/Date.rst index b9816764cea..3fb06f7944b 100644 --- a/reference/constraints/Date.rst +++ b/reference/constraints/Date.rst @@ -65,8 +65,8 @@ Basic Usage // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index c81c04f8626..777b7e083bb 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -66,8 +66,8 @@ Basic Usage // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index e196150bb52..9158966f16e 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -75,8 +75,8 @@ Basic Usage // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index 09abe728c24..fc076f7a0cf 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -92,8 +92,8 @@ and that the ``age`` is ``20``, you could do the following: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { diff --git a/reference/constraints/Expression.rst b/reference/constraints/Expression.rst index 679d30fb269..a02dc3f4926 100644 --- a/reference/constraints/Expression.rst +++ b/reference/constraints/Expression.rst @@ -112,8 +112,8 @@ One way to accomplish this is with the Expression constraint: // src/AppBundle/Model/BlogPost.php namespace AppBundle\Model; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class BlogPost { diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 773ecb24128..4ee5015e7e2 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -134,8 +134,8 @@ below a certain file size and a valid PDF, add the following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index f7485cad66d..478c06fb1b4 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -90,8 +90,8 @@ The following constraints ensure that: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -157,8 +157,8 @@ that a date must at least be the next day: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { @@ -216,8 +216,8 @@ dates. If you want to fix the timezone, append it to the date string: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { @@ -276,8 +276,8 @@ current time: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index e3d1d0074be..f23567771b3 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -89,8 +89,8 @@ The following constraints ensure that: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -156,8 +156,8 @@ that a date must at least be the current day: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { @@ -215,8 +215,8 @@ dates. If you want to fix the timezone, append it to the date string: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { @@ -275,8 +275,8 @@ current time: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index 9f32cb81ea0..cc074fb327d 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -76,8 +76,8 @@ will contain an International Bank Account Number. // src/AppBundle/Entity/Transaction.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Transaction { diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index 12700a2e5ea..dd1e6bb96f7 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -95,8 +95,8 @@ The following constraints ensure that: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index 4f5529186dd..d3f2f434a0f 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -136,8 +136,8 @@ that it is between a certain size, add the following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -206,8 +206,8 @@ following code: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index c16a94d6df3..2db8fca81bd 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -66,8 +66,8 @@ Basic Usage // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 10148287e9d..ceac8598252 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -92,8 +92,8 @@ method returns **false**: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/IsNull.rst b/reference/constraints/IsNull.rst index f3a368fde20..0948aa56ca5 100644 --- a/reference/constraints/IsNull.rst +++ b/reference/constraints/IsNull.rst @@ -70,8 +70,8 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index 6ea7f30037d..f4237a6c483 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -95,8 +95,8 @@ Then you can constrain this method with ``IsTrue``. // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\IsTrue; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index 4c543496084..2d4b68addc7 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -79,8 +79,8 @@ on an object that will contain an ISBN. // src/AppBundle/Entity/Book.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Book { diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index f409a17b94e..b252ec24106 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -66,8 +66,8 @@ Basic Usage // src/AppBundle/Entity/Journal.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Journal { diff --git a/reference/constraints/Language.rst b/reference/constraints/Language.rst index 29eace137db..f06918e4cf6 100644 --- a/reference/constraints/Language.rst +++ b/reference/constraints/Language.rst @@ -64,8 +64,8 @@ Basic Usage // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index fb825c45a75..1a349b99449 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -96,8 +96,8 @@ and "50", you might add the following: // src/AppBundle/Entity/Participant.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Participant { diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index 6cc005adffa..f0b38f6c3b4 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -90,8 +90,8 @@ The following constraints ensure that: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -157,8 +157,8 @@ that a date must be in the past like this: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -216,8 +216,8 @@ dates. If you want to fix the timezone, append it to the date string: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -275,8 +275,8 @@ can check that a person must be at least 18 years old like this: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index 0dde8b21c5b..c006d763b28 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -89,8 +89,8 @@ The following constraints ensure that: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -156,8 +156,8 @@ that a date must be today or in the past like this: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -215,8 +215,8 @@ dates. If you want to fix the timezone, append it to the date string: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { @@ -274,8 +274,8 @@ can check that a person must be at least 18 years old like this: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index 932bae1b5a3..bb56a9ba6f1 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -68,8 +68,8 @@ Basic Usage // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index bb4b5c9184d..9db926b76ce 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -71,8 +71,8 @@ will contain a credit card number. // src/AppBundle/Entity/Transaction.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Transaction { diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index eda4b75b4ba..5c94706f1aa 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -74,8 +74,8 @@ class were not blank, you could do the following: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index fc1ccde96cc..590778229af 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -94,8 +94,8 @@ the following: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index 536fa117967..f53e4fceb1c 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -95,8 +95,8 @@ The following constraints ensure that: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Person { diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 60eab0a250d..b5e743fb873 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -68,8 +68,8 @@ class were not strictly equal to ``null``, you would: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index cfb4e166d55..39bf8148ca7 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -84,8 +84,8 @@ you might add the following: // src/AppBundle/Entity/Participant.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Participant { @@ -161,8 +161,8 @@ date must lie within the current year like this: // src/AppBundle/Entity/Event.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Event { @@ -231,8 +231,8 @@ dates. If you want to fix the timezone, append it to the date string: // src/AppBundle/Entity/Person.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Event { @@ -301,8 +301,8 @@ can check that a delivery date starts within the next five hours like this: // src/AppBundle/Entity/Order.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Order { diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index 830684cd030..8808ce51a96 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -73,8 +73,8 @@ more word characters at the beginning of your string: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -147,8 +147,8 @@ it a custom message: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -249,8 +249,8 @@ need to specify the HTML5 compatible pattern in the ``htmlPattern`` option: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/Time.rst b/reference/constraints/Time.rst index 7a57cc1b507..d044527463b 100644 --- a/reference/constraints/Time.rst +++ b/reference/constraints/Time.rst @@ -68,8 +68,8 @@ of the day when the event starts: // src/AppBundle/Entity/Event.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Event { diff --git a/reference/constraints/Traverse.rst b/reference/constraints/Traverse.rst index f367b041085..2d51c7548af 100644 --- a/reference/constraints/Traverse.rst +++ b/reference/constraints/Traverse.rst @@ -30,8 +30,8 @@ configure the ``Traverse`` constraint on the ``Book`` class. // src/AppBundle/Entity/Book.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Constraints as Assert; use Doctrine\ORM\Mapping as ORM; + use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 08a8f5e7471..5a23f2f3c95 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -90,8 +90,8 @@ This will check if ``firstName`` is of type ``string`` and that ``age`` is an // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 1628d9997d6..6e1145a818a 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -38,12 +38,13 @@ your user table: // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Constraints as Assert; use Doctrine\ORM\Mapping as ORM; - // DON'T forget this use statement!!! + // DON'T forget the following use statement!!! use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + use Symfony\Component\Validator\Constraints as Assert; + /** * @ORM\Entity * @UniqueEntity("email") @@ -90,11 +91,11 @@ your user table: // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Constraints as Assert; - - // DON'T forget this use statement!!! + // DON'T forget the following use statement!!! use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + use Symfony\Component\Validator\Constraints as Assert; + class User { public static function loadValidatorMetadata(ClassMetadata $metadata) @@ -276,8 +277,8 @@ Consider this example: // src/AppBundle/Entity/Service.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Service { diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 9e8e48a1aa9..5dbee2ecca2 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -66,8 +66,8 @@ Basic Usage // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -149,8 +149,8 @@ You can use the following parameters in this message: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -224,8 +224,8 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -298,8 +298,8 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -371,8 +371,8 @@ DNS check failed. // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index dd853e779ab..7ebdda483f3 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -82,8 +82,8 @@ the user's current password: // src/AppBundle/Form/Model/ChangePassword.php namespace AppBundle\Form\Model; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Security\Core\Validator\Constraints as SecurityAssert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class ChangePassword { diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index f89ed1e271c..f961beb9ac8 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -68,8 +68,8 @@ Basic Usage // src/AppBundle/Entity/File.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class File { diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 97dc22c093d..c5bb19fa89f 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -148,8 +148,8 @@ stores an ``Address`` instance in the ``$address`` property:: // src/AppBundle/Entity/Address.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Address { @@ -164,8 +164,8 @@ stores an ``Address`` instance in the ``$address`` property:: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -226,8 +226,8 @@ an invalid address. To prevent that, add the ``Valid`` constraint to the // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/reference/events.rst b/reference/events.rst index a19cb5b8cfa..dfb67ba4131 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -116,8 +116,8 @@ the controller does *not* return a :class:`Symfony\\Component\\HttpFoundation\\R object. It's useful to transform the returned value (e.g. a string with some HTML contents) into the ``Response`` object needed by Symfony:: - use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; public function onKernelView(GetResponseForControllerResultEvent $event) { @@ -225,8 +225,8 @@ This event is dispatched as soon as an error occurs during the handling of the HTTP request. It's useful to recover from errors or modify the exception details sent as response:: - use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; public function onKernelException(GetResponseForExceptionEvent $event) { diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 00680ffaee8..2f28c06016c 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -83,8 +83,8 @@ This field has a *lot* of options and most control how the field is displayed. I this example, the underlying data is some ``Category`` object that has a ``getName()`` method:: - use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use AppBundle\Entity\Category; + use Symfony\Component\Form\Extension\Core\Type\ChoiceType; // ... $builder->add('category', ChoiceType::class, [ diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 917178cd5a3..bca32951536 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -304,8 +304,8 @@ as your `entry_type`_ option (e.g. for a collection of drop-down menus), then you'd need to at least pass the ``choices`` option to the underlying type:: - use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; + use Symfony\Component\Form\Extension\Core\Type\CollectionType; // ... $builder->add('favoriteCities', CollectionType::class, [ diff --git a/reference/forms/types/options/by_reference.rst.inc b/reference/forms/types/options/by_reference.rst.inc index c3921c58a72..257c0c5a6e4 100644 --- a/reference/forms/types/options/by_reference.rst.inc +++ b/reference/forms/types/options/by_reference.rst.inc @@ -10,9 +10,9 @@ called in all cases. To explain this further, here's a simple example:: - use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\FormType; + use Symfony\Component\Form\Extension\Core\Type\TextType; // ... $builder = $this->createFormBuilder($article); diff --git a/reference/forms/types/options/validation_groups.rst.inc b/reference/forms/types/options/validation_groups.rst.inc index 7dc2d1ca208..edff4f733f1 100644 --- a/reference/forms/types/options/validation_groups.rst.inc +++ b/reference/forms/types/options/validation_groups.rst.inc @@ -62,8 +62,8 @@ like when you pass multiple groups in an array, but with the difference that a group is only validated if the previous groups pass without errors. Here's an example:: - use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Form\AbstractType; + use Symfony\Component\Validator\Constraints\GroupSequence; // ... class MyType extends AbstractType diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index 63d99cff9a9..d1f339b8b70 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -38,8 +38,8 @@ Example Usage .. code-block:: php - use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\PasswordType; + use Symfony\Component\Form\Extension\Core\Type\RepeatedType; // ... $builder->add('password', RepeatedType::class, [ diff --git a/routing.rst b/routing.rst index b79e30c9e78..dbe514ac433 100644 --- a/routing.rst +++ b/routing.rst @@ -110,8 +110,8 @@ the same features and performance, so choose the one you prefer: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); // Matches /blog exactly @@ -248,8 +248,8 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog_list', new Route('/blog/{page}', [ @@ -340,8 +340,8 @@ So how can you make ``blog_list`` once again match when the user visits .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog_list', new Route( @@ -433,8 +433,8 @@ With all of this in mind, check out this advanced example: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add( diff --git a/routing/conditions.rst b/routing/conditions.rst index bc209b0b9aa..df0e6b47610 100644 --- a/routing/conditions.rst +++ b/routing/conditions.rst @@ -59,8 +59,8 @@ define arbitrary matching logic, use the ``condition`` routing setting: .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('contact', new Route( diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index c83a556a1fd..2ad8e7ae1df 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -180,8 +180,8 @@ of the ``AppBundle``:: // src/AppBundle/Controller/ExtraController.php namespace AppBundle\Controller; - use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Symfony\Component\HttpFoundation\Response; class ExtraController extends Controller { diff --git a/routing/extra_information.rst b/routing/extra_information.rst index 13766709e18..22a911b85c0 100644 --- a/routing/extra_information.rst +++ b/routing/extra_information.rst @@ -66,8 +66,8 @@ to your controller, and as attributes of the ``Request`` object: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog', new Route('/blog/{page}', [ diff --git a/routing/hostname_pattern.rst b/routing/hostname_pattern.rst index 76b013c5051..d176c6f4fc2 100644 --- a/routing/hostname_pattern.rst +++ b/routing/hostname_pattern.rst @@ -65,8 +65,8 @@ You can also match any route with the HTTP *host* of the incoming request. .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('mobile_homepage', new Route('/', [ @@ -147,8 +147,8 @@ you can use placeholders in your hostname: .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('project_homepage', new Route('/', [ @@ -236,8 +236,8 @@ instance, if you want to match both ``m.example.com`` and .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('mobile_homepage', new Route('/', [ @@ -329,8 +329,8 @@ instance, if you want to match both ``m.example.com`` and .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('mobile_homepage', new Route('/', [ diff --git a/routing/optional_placeholders.rst b/routing/optional_placeholders.rst index c89fb3f0fd9..a5bdbb20fcc 100644 --- a/routing/optional_placeholders.rst +++ b/routing/optional_placeholders.rst @@ -50,8 +50,8 @@ the available blog posts for this imaginary blog application: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog', new Route('/blog', [ @@ -105,8 +105,8 @@ entries? Update the route to have a new ``{page}`` placeholder: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog', new Route('/blog/{page}', [ @@ -166,8 +166,8 @@ This is done by including it in the ``defaults`` collection: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog', new Route('/blog/{page}', [ diff --git a/routing/redirect_in_config.rst b/routing/redirect_in_config.rst index 0b80b478c73..b32573d85ce 100644 --- a/routing/redirect_in_config.rst +++ b/routing/redirect_in_config.rst @@ -66,8 +66,8 @@ action to redirect to this new url: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); @@ -138,8 +138,8 @@ action: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); // ... diff --git a/routing/redirect_trailing_slash.rst b/routing/redirect_trailing_slash.rst index 0a84b1f1b9b..016cbd4ca4e 100644 --- a/routing/redirect_trailing_slash.rst +++ b/routing/redirect_trailing_slash.rst @@ -80,8 +80,8 @@ system, as explained below: .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add( diff --git a/routing/requirements.rst b/routing/requirements.rst index 519cb451c73..6a73b4b0b4f 100644 --- a/routing/requirements.rst +++ b/routing/requirements.rst @@ -58,8 +58,8 @@ a routing ``{wildcard}`` to only match some regular expression: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('blog_list', new Route('/blog/{page}', [ @@ -135,8 +135,8 @@ URL: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('homepage', new Route('/{_locale}', [ @@ -254,8 +254,8 @@ accomplished with the following route configuration: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('api_post_show', new Route('/api/posts/{id}', [ diff --git a/routing/scheme.rst b/routing/scheme.rst index a4dcf7c9c68..632e1db28d2 100644 --- a/routing/scheme.rst +++ b/routing/scheme.rst @@ -54,8 +54,8 @@ the URI scheme with the ``schemes`` setting: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('secure', new Route('/secure', [ diff --git a/routing/service_container_parameters.rst b/routing/service_container_parameters.rst index cfdd4f4d140..5f72f9a205d 100644 --- a/routing/service_container_parameters.rst +++ b/routing/service_container_parameters.rst @@ -64,8 +64,8 @@ inside your routing configuration: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('contact', new Route('/{_locale}/contact', [ @@ -154,8 +154,8 @@ path): .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('some_route', new Route('/%app.route_prefix%/contact', [ diff --git a/routing/slash_in_parameter.rst b/routing/slash_in_parameter.rst index 202284897f6..4970cef2fa4 100644 --- a/routing/slash_in_parameter.rst +++ b/routing/slash_in_parameter.rst @@ -65,8 +65,8 @@ a more permissive regular expression for it: .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('share', new Route('/share/{token}', [ diff --git a/security.rst b/security.rst index cffd3b5ce93..982c5cd47eb 100644 --- a/security.rst +++ b/security.rst @@ -1170,8 +1170,8 @@ Next, you'll need to create a route for this URL (but not a controller): .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('logout', new Route('/logout')); diff --git a/security/acl.rst b/security/acl.rst index 48ec64cd4eb..365477ec2d9 100644 --- a/security/acl.rst +++ b/security/acl.rst @@ -124,10 +124,10 @@ Creating an ACL and Adding an ACE namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Acl\Domain\ObjectIdentity; use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity; use Symfony\Component\Security\Acl\Permission\MaskBuilder; + use Symfony\Component\Security\Core\Exception\AccessDeniedException; class BlogController extends Controller { diff --git a/security/api_key_authentication.rst b/security/api_key_authentication.rst index f21255672ba..e373763ed76 100644 --- a/security/api_key_authentication.rst +++ b/security/api_key_authentication.rst @@ -32,8 +32,8 @@ value and then a User object is created:: use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; - use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; use Symfony\Component\Security\Core\Exception\BadCredentialsException; + use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface; @@ -166,10 +166,10 @@ The ``$userProvider`` might look something like this:: // src/AppBundle/Security/ApiKeyUserProvider.php namespace AppBundle\Security; - use Symfony\Component\Security\Core\User\UserProviderInterface; + use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\User\User; use Symfony\Component\Security\Core\User\UserInterface; - use Symfony\Component\Security\Core\Exception\UnsupportedUserException; + use Symfony\Component\Security\Core\User\UserProviderInterface; class ApiKeyUserProvider implements UserProviderInterface { @@ -254,11 +254,11 @@ you can use to create an error ``Response``:: // src/AppBundle/Security/ApiKeyAuthenticator.php namespace AppBundle\Security; + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface; - use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\HttpFoundation\Request; class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface { @@ -580,8 +580,8 @@ current URL is before creating the token in ``createToken()``:: // src/AppBundle/Security/ApiKeyAuthenticator.php // ... - use Symfony\Component\Security\Http\HttpUtils; use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\Security\Http\HttpUtils; class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface { diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index acb5d011374..046e2dcc371 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -108,13 +108,13 @@ set an authenticated token in the token storage if successful:: // src/AppBundle/Security/Firewall/WsseListener.php namespace AppBundle\Security\Firewall; + use AppBundle\Security\Authentication\Token\WsseUserToken; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Firewall\ListenerInterface; - use AppBundle\Security\Authentication\Token\WsseUserToken; class WsseListener implements ListenerInterface { @@ -202,13 +202,13 @@ the ``PasswordDigest`` header value matches with the user's password:: // src/AppBundle/Security/Authentication/Provider/WsseProvider.php namespace AppBundle\Security\Authentication\Provider; + use AppBundle\Security\Authentication\Token\WsseUserToken; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface; - use Symfony\Component\Security\Core\User\UserProviderInterface; + use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\NonceExpiredException; - use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; - use AppBundle\Security\Authentication\Token\WsseUserToken; + use Symfony\Component\Security\Core\User\UserProviderInterface; class WsseProvider implements AuthenticationProviderInterface { @@ -307,13 +307,13 @@ create a class which implements // src/AppBundle/DependencyInjection/Security/Factory/WsseFactory.php namespace AppBundle\DependencyInjection\Security\Factory; + use AppBundle\Security\Authentication\Provider\WsseProvider; + use AppBundle\Security\Firewall\WsseListener; + use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; + use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; - use Symfony\Component\Config\Definition\Builder\NodeDefinition; - use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; - use AppBundle\Security\Authentication\Provider\WsseProvider; - use AppBundle\Security\Firewall\WsseListener; class WsseFactory implements SecurityFactoryInterface { @@ -461,8 +461,8 @@ factory in your bundle class:: namespace AppBundle; use AppBundle\DependencyInjection\Security\Factory\WsseFactory; - use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\HttpKernel\Bundle\Bundle; class AppBundle extends Bundle { diff --git a/security/custom_provider.rst b/security/custom_provider.rst index 9969f8f1ecf..211e677f532 100644 --- a/security/custom_provider.rst +++ b/security/custom_provider.rst @@ -38,8 +38,8 @@ This is how your ``WebserviceUser`` class looks in action:: // src/AppBundle/Security/User/WebserviceUser.php namespace AppBundle\Security\User; - use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\EquatableInterface; + use Symfony\Component\Security\Core\User\UserInterface; class WebserviceUser implements UserInterface, EquatableInterface { @@ -124,10 +124,10 @@ Here's an example of how this might look:: namespace AppBundle\Security\User; use AppBundle\Security\User\WebserviceUser; - use Symfony\Component\Security\Core\User\UserProviderInterface; - use Symfony\Component\Security\Core\User\UserInterface; - use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; + use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; + use Symfony\Component\Security\Core\User\UserInterface; + use Symfony\Component\Security\Core\User\UserProviderInterface; class WebserviceUserProvider implements UserProviderInterface { diff --git a/security/entity_provider.rst b/security/entity_provider.rst index 0c410226829..cb9a135b34f 100644 --- a/security/entity_provider.rst +++ b/security/entity_provider.rst @@ -436,8 +436,8 @@ interface only requires one method: ``loadUserByUsername($username)``:: // src/AppBundle/Repository/UserRepository.php namespace AppBundle\Repository; - use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface; use Doctrine\ORM\EntityRepository; + use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface; class UserRepository extends EntityRepository implements UserLoaderInterface { diff --git a/security/form_login_setup.rst b/security/form_login_setup.rst index b83799a2be0..7c1c2b44281 100644 --- a/security/form_login_setup.rst +++ b/security/form_login_setup.rst @@ -127,8 +127,8 @@ configuration (``login``): .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('login', new Route('/login', [ diff --git a/security/guard_authentication.rst b/security/guard_authentication.rst index 67a35e8fe44..c342e8ed0d5 100644 --- a/security/guard_authentication.rst +++ b/security/guard_authentication.rst @@ -22,8 +22,8 @@ property they use to access their account via the API:: // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Security\Core\User\UserInterface; use Doctrine\ORM\Mapping as ORM; + use Symfony\Component\Security\Core\User\UserInterface; /** * @ORM\Entity @@ -160,14 +160,14 @@ This requires you to implement several methods:: // src/AppBundle/Security/TokenAuthenticator.php namespace AppBundle\Security; - use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; + use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\Security\Core\User\UserInterface; - use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; + use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; + use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; class TokenAuthenticator extends AbstractGuardAuthenticator { @@ -510,9 +510,9 @@ and add the following logic:: // src/AppBundle/Security/ExampleFormAuthenticator.php // ... - use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; - use Symfony\Component\Security\Csrf\CsrfToken; use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException; + use Symfony\Component\Security\Csrf\CsrfToken; + use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator; class ExampleFormAuthenticator extends AbstractFormLoginAuthenticator diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 5cb0a40690c..d708ab6ca6d 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -195,8 +195,8 @@ you switch users, add an event subscriber on this event:: // src/AppBundle/EventListener/SwitchUserSubscriber.php namespace AppBundle\EventListener; - use Symfony\Component\Security\Http\Event\SwitchUserEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; + use Symfony\Component\Security\Http\Event\SwitchUserEvent; use Symfony\Component\Security\Http\SecurityEvents; class SwitchUserSubscriber implements EventSubscriberInterface diff --git a/security/json_login_setup.rst b/security/json_login_setup.rst index d2c8eae82a4..64f80981dfd 100644 --- a/security/json_login_setup.rst +++ b/security/json_login_setup.rst @@ -111,8 +111,8 @@ The next step is to configure a route in your app matching this path: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('login', new Route('/login', [ diff --git a/security/ldap.rst b/security/ldap.rst index 24d63346ecf..e1894940e48 100644 --- a/security/ldap.rst +++ b/security/ldap.rst @@ -98,8 +98,8 @@ An LDAP client can be simply configured using the built-in .. code-block:: php // app/config/services.php - use Symfony\Component\Ldap\Ldap; use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter; + use Symfony\Component\Ldap\Ldap; $container->register(Ldap::class) ->addArgument(new Reference(Adapter::class); diff --git a/security/multiple_guard_authenticators.rst b/security/multiple_guard_authenticators.rst index 0c98d130861..25cfab79ad3 100644 --- a/security/multiple_guard_authenticators.rst +++ b/security/multiple_guard_authenticators.rst @@ -59,8 +59,8 @@ This is how your security configuration can look in action: .. code-block:: php // app/config/security.php - use AppBundle\Security\LoginFormAuthenticator; use AppBundle\Security\FacebookConnectAuthenticator; + use AppBundle\Security\LoginFormAuthenticator; $container->loadFromExtension('security', [ // ... diff --git a/security/named_encoders.rst b/security/named_encoders.rst index 78c31332dcd..803f3d16992 100644 --- a/security/named_encoders.rst +++ b/security/named_encoders.rst @@ -116,8 +116,8 @@ the name of the encoder to use:: // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface; + use Symfony\Component\Security\Core\User\UserInterface; class User implements UserInterface, EncoderAwareInterface { diff --git a/serializer/encoders.rst b/serializer/encoders.rst index f77c1f2c1a4..5e4dc9f8b53 100644 --- a/serializer/encoders.rst +++ b/serializer/encoders.rst @@ -13,9 +13,9 @@ decoding (format to array). You can add new encoders to a Serializer instance by using its second constructor argument:: - use Symfony\Component\Serializer\Serializer; - use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Encoder\JsonEncoder; + use Symfony\Component\Serializer\Encoder\XmlEncoder; + use Symfony\Component\Serializer\Serializer; $encoders = [new XmlEncoder(), new JsonEncoder()]; $serializer = new Serializer([], $encoders); diff --git a/serializer/normalizers.rst b/serializer/normalizers.rst index e38d29578ae..19f5bb91852 100644 --- a/serializer/normalizers.rst +++ b/serializer/normalizers.rst @@ -12,8 +12,8 @@ denormalizing (array to object). Normalizers are enabled in the serializer passing them as its first argument:: - use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; $normalizers = [new ObjectNormalizer()]; $serializer = new Serializer($normalizers); diff --git a/service_container.rst b/service_container.rst index f64b8e64bd5..bb3c19d2396 100644 --- a/service_container.rst +++ b/service_container.rst @@ -755,8 +755,8 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type // config/services.php use App\Controller\LuckyController; - use Symfony\Component\DependencyInjection\Reference; use Psr\Log\LoggerInterface; + use Symfony\Component\DependencyInjection\Reference; $container->register(LuckyController::class) ->setPublic(true) @@ -1144,8 +1144,8 @@ admin email. In this case, each needs to have a unique service id: .. code-block:: php // app/config/services.php - use AppBundle\Updates\SiteUpdateManager; use AppBundle\Service\MessageGenerator; + use AppBundle\Updates\SiteUpdateManager; use Symfony\Component\DependencyInjection\Reference; $container->register('site_update_manager.superadmin', SiteUpdateManager::class) diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index fceda9868ac..90a6316a821 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -419,10 +419,10 @@ that alias: .. code-block:: php + use AppBundle\Service\TwitterClient; use AppBundle\Util\Rot13Transformer; - use AppBundle\Util\UppercaseTransformer; use AppBundle\Util\TransformerInterface; - use AppBundle\Service\TwitterClient; + use AppBundle\Util\UppercaseTransformer; // ... $container->autowire(Rot13Transformer::class); diff --git a/service_container/compiler_passes.rst b/service_container/compiler_passes.rst index b43527c27b5..c76c4f3d5a8 100644 --- a/service_container/compiler_passes.rst +++ b/service_container/compiler_passes.rst @@ -17,9 +17,9 @@ is not needed when implementing the ``process()`` method in the extension):: // src/AppBundle/AppBundle.php namespace AppBundle; - use Symfony\Component\HttpKernel\Bundle\Bundle; - use Symfony\Component\DependencyInjection\ContainerBuilder; use AppBundle\DependencyInjection\Compiler\CustomPass; + use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\HttpKernel\Bundle\Bundle; class AppBundle extends Bundle { diff --git a/service_container/definitions.rst b/service_container/definitions.rst index f2987a3e054..5e74bef8ec9 100644 --- a/service_container/definitions.rst +++ b/service_container/definitions.rst @@ -56,8 +56,8 @@ Class The first optional argument of the ``Definition`` class is the fully qualified class name of the object returned when the service is fetched from the container:: - use AppBundle\Config\UserConfigManager; use AppBundle\Config\CustomConfigManager; + use AppBundle\Config\UserConfigManager; use Symfony\Component\DependencyInjection\Definition; $definition = new Definition(UserConfigManager::class); diff --git a/service_container/optional_dependencies.rst b/service_container/optional_dependencies.rst index a65c919142d..11bd4a59b35 100644 --- a/service_container/optional_dependencies.rst +++ b/service_container/optional_dependencies.rst @@ -35,8 +35,8 @@ if the service does not exist: // app/config/services.php use AppBundle\Newsletter\NewsletterManager; - use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerInterface; + use Symfony\Component\DependencyInjection\Reference; // ... @@ -93,8 +93,8 @@ call if the service exists and remove the method call if it does not: // app/config/services.php use AppBundle\Newsletter\NewsletterManager; - use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerInterface; + use Symfony\Component\DependencyInjection\Reference; $container ->register(NewsletterManager::class) diff --git a/service_container/parent_services.rst b/service_container/parent_services.rst index 0b1e40cd89c..e4bafac16b4 100644 --- a/service_container/parent_services.rst +++ b/service_container/parent_services.rst @@ -114,9 +114,9 @@ duplicated service definitions: .. code-block:: php - use AppBundle\Repository\DoctrineUserRepository; - use AppBundle\Repository\DoctrinePostRepository; use AppBundle\Repository\BaseDoctrineRepository; + use AppBundle\Repository\DoctrinePostRepository; + use AppBundle\Repository\DoctrineUserRepository; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Reference; @@ -223,9 +223,9 @@ the child class: .. code-block:: php - use AppBundle\Repository\DoctrineUserRepository; - use AppBundle\Repository\DoctrinePostRepository; use AppBundle\Repository\BaseDoctrineRepository; + use AppBundle\Repository\DoctrinePostRepository; + use AppBundle\Repository\DoctrineUserRepository; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Reference; // ... diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 31b0dbf8a1f..7aa88ec11bf 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -288,8 +288,8 @@ include as many services as needed in it. .. code-block:: php // app/config/services.php - use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\DependencyInjection\Reference; + use Symfony\Component\DependencyInjection\ServiceLocator; // ... diff --git a/service_container/tags.rst b/service_container/tags.rst index 2fb5cf304f7..0e24af1f57c 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -245,10 +245,10 @@ container for any services with the ``app.mail_transport`` tag:: // src/AppBundle/DependencyInjection/Compiler/MailTransportPass.php namespace AppBundle\DependencyInjection\Compiler; - use Symfony\Component\DependencyInjection\ContainerBuilder; + use AppBundle\Mail\TransportChain; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; - use AppBundle\Mail\TransportChain; class MailTransportPass implements CompilerPassInterface { @@ -281,8 +281,8 @@ bundle:: // src/AppBundle/AppBundle.php // ... - use Symfony\Component\DependencyInjection\ContainerBuilder; use AppBundle\DependencyInjection\Compiler\MailTransportPass; + use Symfony\Component\DependencyInjection\ContainerBuilder; class AppBundle extends Bundle { @@ -409,8 +409,8 @@ To answer this, change the service declaration: Notice that you've added a generic ``alias`` key to the tag. To actually use this, update the compiler:: - use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class TransportCompilerPass implements CompilerPassInterface diff --git a/session/locale_sticky_session.rst b/session/locale_sticky_session.rst index 882e3ab7472..a431cb9259b 100644 --- a/session/locale_sticky_session.rst +++ b/session/locale_sticky_session.rst @@ -20,9 +20,9 @@ correct locale however you want:: // src/AppBundle/EventSubscriber/LocaleSubscriber.php namespace AppBundle\EventSubscriber; + use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; class LocaleSubscriber implements EventSubscriberInterface { diff --git a/templating/render_without_controller.rst b/templating/render_without_controller.rst index edf2adca5c8..3a45667a23b 100644 --- a/templating/render_without_controller.rst +++ b/templating/render_without_controller.rst @@ -39,8 +39,8 @@ can do this without creating a controller: .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('acme_privacy', new Route('/privacy', [ @@ -101,8 +101,8 @@ other variables in your route, you can control exactly how your page is cached: .. code-block:: php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('acme_privacy', new Route('/privacy', [ diff --git a/translation/locale.rst b/translation/locale.rst index 525f11c362a..550266771d3 100644 --- a/translation/locale.rst +++ b/translation/locale.rst @@ -91,8 +91,8 @@ by the routing system using the special ``_locale`` parameter: .. code-block:: php // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; $routes = new RouteCollection(); $routes->add('contact', new Route( diff --git a/validation.rst b/validation.rst index 978873ced45..2538e2b48a0 100644 --- a/validation.rst +++ b/validation.rst @@ -86,8 +86,8 @@ following: // src/AppBundle/Entity/Author.php // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -119,8 +119,8 @@ constraints. If validation fails, a non-empty list of errors returned. Take this simple example from inside a controller:: // ... - use Symfony\Component\HttpFoundation\Response; use AppBundle\Entity\Author; + use Symfony\Component\HttpFoundation\Response; // ... public function authorAction() @@ -370,8 +370,8 @@ literature genre mostly associated with the author, which can be set to either // src/AppBundle/Entity/Author.php // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -451,8 +451,8 @@ options can be specified in this way. // src/AppBundle/Entity/Author.php // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -571,8 +571,8 @@ class to have at least 3 characters. // src/AppBundle/Entity/Author.php // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { @@ -656,8 +656,8 @@ this method must return ``true``: // src/AppBundle/Entity/Author.php // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index cfbb2392380..3842a831589 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -104,8 +104,8 @@ You can use custom validators just as the ones provided by Symfony itself: .. code-block:: php-annotations // src/AppBundle/Entity/AcmeEntity.php - use Symfony\Component\Validator\Constraints as Assert; use AppBundle\Validator\Constraints as AcmeAssert; + use Symfony\Component\Validator\Constraints as Assert; class AcmeEntity { @@ -148,9 +148,9 @@ You can use custom validators just as the ones provided by Symfony itself: .. code-block:: php // src/AppBundle/Entity/AcmeEntity.php - use Symfony\Component\Validator\Mapping\ClassMetadata; - use Symfony\Component\Validator\Constraints\NotBlank; use AppBundle\Validator\Constraints\ContainsAlphanumeric; + use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\Mapping\ClassMetadata; class AcmeEntity { diff --git a/validation/groups.rst b/validation/groups.rst index 5d9fc1c3b11..253e3e59395 100644 --- a/validation/groups.rst +++ b/validation/groups.rst @@ -103,8 +103,8 @@ user registers and when a user updates their contact information later: // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/validation/raw_values.rst b/validation/raw_values.rst index 13fb1f08f3e..c4d2efad75f 100644 --- a/validation/raw_values.rst +++ b/validation/raw_values.rst @@ -45,8 +45,8 @@ section. Validation of arrays is possible using the ``Collection`` constraint:: - use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Validation; $validator = Validation::createValidator(); diff --git a/validation/sequence_provider.rst b/validation/sequence_provider.rst index bb372f57c48..2391e4860bb 100644 --- a/validation/sequence_provider.rst +++ b/validation/sequence_provider.rst @@ -103,8 +103,8 @@ username and the password are different only if all other validation passes // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/validation/severity.rst b/validation/severity.rst index b31cdd7f7df..f1335d4bfdd 100644 --- a/validation/severity.rst +++ b/validation/severity.rst @@ -106,8 +106,8 @@ Use the ``payload`` option to configure the error level for each constraint: // src/AppBundle/Entity/User.php namespace AppBundle\Entity; - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; class User { diff --git a/validation/translations.rst b/validation/translations.rst index 502de79fff9..a7f40a75515 100644 --- a/validation/translations.rst +++ b/validation/translations.rst @@ -69,8 +69,8 @@ property is not empty, add the following: // src/AppBundle/Entity/Author.php // ... - use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\Mapping\ClassMetadata; class Author { diff --git a/workflow.rst b/workflow.rst index 530e318d609..09035d8edc5 100644 --- a/workflow.rst +++ b/workflow.rst @@ -296,6 +296,7 @@ workflow leaves a place:: use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Workflow\Event\Event; + class WorkflowLogger implements EventSubscriberInterface { public function __construct(LoggerInterface $logger) @@ -340,8 +341,8 @@ list of the guard event names. This example stops any blog post being transitioned to "reviewed" if it is missing a title:: - use Symfony\Component\Workflow\Event\GuardEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; + use Symfony\Component\Workflow\Event\GuardEvent; class BlogPostReviewListener implements EventSubscriberInterface {