Skip to content

Commit

Permalink
ordered use statements in code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Apr 24, 2019
1 parent b1c5ac1 commit 3506a7e
Show file tree
Hide file tree
Showing 182 changed files with 387 additions and 382 deletions.
2 changes: 1 addition & 1 deletion best_practices/business-logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion best_practices/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
12 changes: 6 additions & 6 deletions best_practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion bundles/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion bundles/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions bundles/prepend_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions components/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ If you are also using the :doc:`HttpFoundation </components/http_foundation>`
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(
Expand Down Expand Up @@ -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(
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion components/cache/adapters/php_array_cache_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion components/cache/cache_invalidation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/cache/psr6_psr16_adapters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions components/console/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/console/helpers/questionhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// ...
Expand Down
2 changes: 1 addition & 1 deletion components/console/helpers/table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/console/logger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions components/dependency_injection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions components/dependency_injection/compilation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions components/event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion components/expression_language/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/filesystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit 3506a7e

Please sign in to comment.