Skip to content

Commit 8b45bd0

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: ordered use statements in code examples
2 parents f83b88a + 93be6df commit 8b45bd0

File tree

154 files changed

+316
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+316
-314
lines changed

best_practices/business-logic.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ looking for mapping information::
163163

164164
namespace App\Entity;
165165

166-
use Doctrine\ORM\Mapping as ORM;
167166
use Doctrine\Common\Collections\ArrayCollection;
167+
use Doctrine\ORM\Mapping as ORM;
168168

169169
/**
170170
* @ORM\Entity

best_practices/forms.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ PHP class::
2121

2222
use App\Entity\Post;
2323
use Symfony\Component\Form\AbstractType;
24+
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
25+
use Symfony\Component\Form\Extension\Core\Type\EmailType;
26+
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
2427
use Symfony\Component\Form\FormBuilderInterface;
2528
use Symfony\Component\OptionsResolver\OptionsResolver;
26-
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
27-
use Symfony\Component\Form\Extension\Core\Type\EmailType;
28-
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
2929

3030
class PostType extends AbstractType
3131
{
@@ -103,9 +103,9 @@ some developers configure form buttons in the controller::
103103

104104
use App\Entity\Post;
105105
use App\Form\PostType;
106-
use Symfony\Component\HttpFoundation\Request;
107106
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
108107
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
108+
use Symfony\Component\HttpFoundation\Request;
109109

110110
class PostController extends AbstractController
111111
{

bundles/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ In your extension, you can load this and dynamically set its arguments::
255255
// src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php
256256
// ...
257257

258-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
259258
use Symfony\Component\Config\FileLocator;
259+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
260260

261261
public function load(array $configs, ContainerBuilder $container)
262262
{

bundles/extension.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ but it is more common if you put these definitions in a configuration file
8888
For instance, assume you have a file called ``services.xml`` in the
8989
``Resources/config/`` directory of your bundle, your ``load()`` method looks like::
9090

91-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9291
use Symfony\Component\Config\FileLocator;
92+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9393

9494
// ...
9595
public function load(array $configs, ContainerBuilder $container)

bundles/prepend_extension.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ To give an Extension the power to do this, it needs to implement
2727
// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php
2828
namespace Acme\HelloBundle\DependencyInjection;
2929

30-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
31-
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
3230
use Symfony\Component\DependencyInjection\ContainerBuilder;
31+
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
32+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
3333

3434
class AcmeHelloExtension extends Extension implements PrependExtensionInterface
3535
{

components/asset.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ If you are also using the :doc:`HttpFoundation </components/http_foundation>`
223223
component in your project (for instance, in a Symfony application), the ``PathPackage``
224224
class can take into account the context of the current request::
225225

226-
use Symfony\Component\Asset\PathPackage;
227226
use Symfony\Component\Asset\Context\RequestStackContext;
227+
use Symfony\Component\Asset\PathPackage;
228228
// ...
229229

230230
$pathPackage = new PathPackage(
@@ -313,8 +313,8 @@ account the context of the current request. In this case, only the request
313313
scheme is considered, in order to select the appropriate base URL (HTTPs or
314314
protocol-relative URLs for HTTPs requests, any base URL for HTTP requests)::
315315

316-
use Symfony\Component\Asset\UrlPackage;
317316
use Symfony\Component\Asset\Context\RequestStackContext;
317+
use Symfony\Component\Asset\UrlPackage;
318318
// ...
319319

320320
$urlPackage = new UrlPackage(
@@ -339,9 +339,9 @@ In the following example, all packages use the same versioning strategy, but
339339
they all have different base paths::
340340

341341
use Symfony\Component\Asset\Package;
342+
use Symfony\Component\Asset\Packages;
342343
use Symfony\Component\Asset\PathPackage;
343344
use Symfony\Component\Asset\UrlPackage;
344-
use Symfony\Component\Asset\Packages;
345345
// ...
346346

347347
$versionStrategy = new StaticVersionStrategy('v1');

components/cache/adapters/php_array_cache_adapter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Php Array Cache Adapter
88
This adapter is a high performance cache for static data (e.g. application configuration)
99
that is optimized and preloaded into OPcache memory storage::
1010

11-
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
1211
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
12+
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
1313

1414
// somehow, decide it's time to warm up the cache!
1515
if ($needsWarmup) {

components/cache/cache_invalidation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ in the same place. By using two adapters, you can e.g. store some big cached ite
6969
on the filesystem or in the database and keep tags in a Redis database to sync all
7070
your fronts and have very fast invalidation checks::
7171

72-
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
7372
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
7473
use Symfony\Component\Cache\Adapter\RedisAdapter;
74+
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
7575

7676
$cache = new TagAwareAdapter(
7777
// Adapter for cached items

components/cache/psr6_psr16_adapters.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ instead. No problem! The Cache component provides the
3636
:class:`Symfony\\Component\\Cache\\Adapter\\SimpleCacheAdapter` class for exactly
3737
this use-case::
3838

39-
use Symfony\Component\Cache\Simple\FilesystemCache;
4039
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
40+
use Symfony\Component\Cache\Simple\FilesystemCache;
4141

4242
// the PSR-16 cache object that you want to use
4343
$psr16Cache = new FilesystemCache();

components/config/definition.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ implements the :class:`Symfony\\Component\\Config\\Definition\\ConfigurationInte
5252

5353
namespace Acme\DatabaseConfiguration;
5454

55-
use Symfony\Component\Config\Definition\ConfigurationInterface;
5655
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
56+
use Symfony\Component\Config\Definition\ConfigurationInterface;
5757

5858
class DatabaseConfiguration implements ConfigurationInterface
5959
{
@@ -838,9 +838,9 @@ any value is not of the expected type, is mandatory and yet undefined, or
838838
could not be validated in some other way, an exception will be thrown.
839839
Otherwise the result is a clean array of configuration values::
840840

841-
use Symfony\Component\Yaml\Yaml;
842-
use Symfony\Component\Config\Definition\Processor;
843841
use Acme\DatabaseConfiguration;
842+
use Symfony\Component\Config\Definition\Processor;
843+
use Symfony\Component\Yaml\Yaml;
844844

845845
$config = Yaml::parse(
846846
file_get_contents(__DIR__.'/src/Matthias/config/config.yaml')

components/console/events.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Just before executing any command, the ``ConsoleEvents::COMMAND`` event is
3333
dispatched. Listeners receive a
3434
:class:`Symfony\\Component\\Console\\Event\\ConsoleCommandEvent` event::
3535

36-
use Symfony\Component\Console\Event\ConsoleCommandEvent;
3736
use Symfony\Component\Console\ConsoleEvents;
37+
use Symfony\Component\Console\Event\ConsoleCommandEvent;
3838

3939
$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
4040
// gets the input instance
@@ -64,8 +64,8 @@ will then *not* execute the command, but instead will return the code ``113``
6464
of the `reserved exit codes`_ for console commands that conform with the
6565
C/C++ standard::
6666

67-
use Symfony\Component\Console\Event\ConsoleCommandEvent;
6867
use Symfony\Component\Console\ConsoleEvents;
68+
use Symfony\Component\Console\Event\ConsoleCommandEvent;
6969

7070
$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
7171
// gets the command to be executed
@@ -97,8 +97,8 @@ thrown by the application.
9797
Listeners receive a
9898
:class:`Symfony\\Component\\Console\\Event\\ConsoleErrorEvent` event::
9999

100-
use Symfony\Component\Console\Event\ConsoleErrorEvent;
101100
use Symfony\Component\Console\ConsoleEvents;
101+
use Symfony\Component\Console\Event\ConsoleErrorEvent;
102102

103103
$dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) {
104104
$output = $event->getOutput();
@@ -131,8 +131,8 @@ listener (like sending logs, closing a database connection, sending emails,
131131
Listeners receive a
132132
:class:`Symfony\\Component\\Console\\Event\\ConsoleTerminateEvent` event::
133133

134-
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
135134
use Symfony\Component\Console\ConsoleEvents;
135+
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
136136

137137
$dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) {
138138
// gets the output

components/console/helpers/questionhelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ Testing a Command that Expects Input
340340
If you want to write a unit test for a command which expects some kind of input
341341
from the command line, you need to set the inputs that the command expects::
342342

343-
use Symfony\Component\Console\Helper\QuestionHelper;
344343
use Symfony\Component\Console\Helper\HelperSet;
344+
use Symfony\Component\Console\Helper\QuestionHelper;
345345
use Symfony\Component\Console\Tester\CommandTester;
346346

347347
// ...

components/console/helpers/table.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ Spanning Multiple Columns and Rows
271271
To make a table cell that spans multiple columns you can use a :class:`Symfony\\Component\\Console\\Helper\\TableCell`::
272272

273273
use Symfony\Component\Console\Helper\Table;
274-
use Symfony\Component\Console\Helper\TableSeparator;
275274
use Symfony\Component\Console\Helper\TableCell;
275+
use Symfony\Component\Console\Helper\TableSeparator;
276276

277277
$table = new Table($output);
278278
$table

components/console/logger.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ You can rely on the logger to use this dependency inside a command::
3939
use Acme\MyDependency;
4040
use Symfony\Component\Console\Command\Command;
4141
use Symfony\Component\Console\Input\InputInterface;
42-
use Symfony\Component\Console\Output\OutputInterface;
4342
use Symfony\Component\Console\Logger\ConsoleLogger;
43+
use Symfony\Component\Console\Output\OutputInterface;
4444

4545
class MyCommand extends Command
4646
{

components/dependency_injection.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ files. To do this you also need to install
198198

199199
Loading an XML config file::
200200

201-
use Symfony\Component\DependencyInjection\ContainerBuilder;
202201
use Symfony\Component\Config\FileLocator;
202+
use Symfony\Component\DependencyInjection\ContainerBuilder;
203203
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
204204

205205
$containerBuilder = new ContainerBuilder();
@@ -208,8 +208,8 @@ Loading an XML config file::
208208

209209
Loading a YAML config file::
210210

211-
use Symfony\Component\DependencyInjection\ContainerBuilder;
212211
use Symfony\Component\Config\FileLocator;
212+
use Symfony\Component\DependencyInjection\ContainerBuilder;
213213
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
214214

215215
$containerBuilder = new ContainerBuilder();
@@ -233,8 +233,8 @@ Loading a YAML config file::
233233
If you *do* want to use PHP to create the services then you can move this
234234
into a separate config file and load it in a similar way::
235235

236-
use Symfony\Component\DependencyInjection\ContainerBuilder;
237236
use Symfony\Component\Config\FileLocator;
237+
use Symfony\Component\DependencyInjection\ContainerBuilder;
238238
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
239239

240240
$containerBuilder = new ContainerBuilder();

components/dependency_injection/compilation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ added but are processed when the container's ``compile()`` method is called.
5757

5858
A very simple extension may just load configuration files into the container::
5959

60+
use Symfony\Component\Config\FileLocator;
6061
use Symfony\Component\DependencyInjection\ContainerBuilder;
61-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
6262
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
63-
use Symfony\Component\Config\FileLocator;
63+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
6464

6565
class AcmeDemoExtension implements ExtensionInterface
6666
{
@@ -113,8 +113,8 @@ If this file is loaded into the configuration then the values in it are
113113
only processed when the container is compiled at which point the Extensions
114114
are loaded::
115115

116-
use Symfony\Component\DependencyInjection\ContainerBuilder;
117116
use Symfony\Component\Config\FileLocator;
117+
use Symfony\Component\DependencyInjection\ContainerBuilder;
118118
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
119119

120120
$containerBuilder = new ContainerBuilder();

components/event_dispatcher.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ determine which instance is passed.
199199
use Symfony\Component\DependencyInjection\ContainerBuilder;
200200
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
201201
use Symfony\Component\DependencyInjection\Reference;
202-
use Symfony\Component\EventDispatcher\EventDispatcher;
203202
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
203+
use Symfony\Component\EventDispatcher\EventDispatcher;
204204

205205
$containerBuilder = new ContainerBuilder(new ParameterBag());
206206
// register the compiler pass that handles the 'kernel.event_listener'
@@ -251,8 +251,8 @@ order. Start by creating this custom event class and documenting it::
251251

252252
namespace Acme\Store\Event;
253253

254-
use Symfony\Component\EventDispatcher\Event;
255254
use Acme\Store\Order;
255+
use Symfony\Component\EventDispatcher\Event;
256256

257257
/**
258258
* The order.placed event is dispatched each time an order is created
@@ -294,8 +294,8 @@ method notifies all listeners of the given event. It takes two arguments:
294294
the name of the event to dispatch and the ``Event`` instance to pass to
295295
each listener of that event::
296296

297-
use Acme\Store\Order;
298297
use Acme\Store\Event\OrderPlacedEvent;
298+
use Acme\Store\Order;
299299

300300
// the order is somehow created or retrieved
301301
$order = new Order();
@@ -332,10 +332,10 @@ Take the following example of a subscriber that subscribes to the
332332

333333
namespace Acme\Store\Event;
334334

335+
use Acme\Store\Event\OrderPlacedEvent;
335336
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
336337
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
337338
use Symfony\Component\HttpKernel\KernelEvents;
338-
use Acme\Store\Event\OrderPlacedEvent;
339339

340340
class StoreSubscriber implements EventSubscriberInterface
341341
{

components/expression_language/caching.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ uses an :class:`Symfony\\Component\\Cache\\Adapter\\ArrayAdapter`). You can
3131
customize this by creating a custom cache pool or using one of the available
3232
ones and injecting this using the constructor::
3333

34-
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3534
use Symfony\Component\Cache\Adapter\RedisAdapter;
35+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3636

3737
$cache = new RedisAdapter(...);
3838
$expressionLanguage = new ExpressionLanguage($cache);

components/filesystem.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Usage
2121
The :class:`Symfony\\Component\\Filesystem\\Filesystem` class is the unique
2222
endpoint for filesystem operations::
2323

24-
use Symfony\Component\Filesystem\Filesystem;
2524
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
25+
use Symfony\Component\Filesystem\Filesystem;
2626

2727
$filesystem = new Filesystem();
2828

components/form.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ object to read data off of the correct PHP superglobals (i.e. ``$_POST`` or
8989
:class:`Symfony\\Component\\Form\\Extension\\HttpFoundation\\HttpFoundationExtension`
9090
to your form factory::
9191

92-
use Symfony\Component\Form\Forms;
9392
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
93+
use Symfony\Component\Form\Forms;
9494

9595
$formFactory = Forms::createFormFactoryBuilder()
9696
->addExtension(new HttpFoundationExtension())
@@ -119,12 +119,12 @@ use the built-in support, first install the Security CSRF component:
119119
120120
The following snippet adds CSRF protection to the form factory::
121121

122+
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
122123
use Symfony\Component\Form\Forms;
123124
use Symfony\Component\HttpFoundation\Session\Session;
124-
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
125-
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
126-
use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator;
127125
use Symfony\Component\Security\Csrf\CsrfTokenManager;
126+
use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator;
127+
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
128128

129129
// creates a Session object from the HttpFoundation component
130130
$session = new Session();
@@ -181,10 +181,10 @@ that help you render the HTML widget, label, help and errors for each field
181181
(as well as a few other things). To configure the integration, you'll need
182182
to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension\\FormExtension`::
183183

184-
use Symfony\Component\Form\Forms;
185184
use Symfony\Bridge\Twig\Extension\FormExtension;
186-
use Symfony\Component\Form\FormRenderer;
187185
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
186+
use Symfony\Component\Form\FormRenderer;
187+
use Symfony\Component\Form\Forms;
188188
use Twig\Environment;
189189
use Twig\Loader\FilesystemLoader;
190190
use Twig\RuntimeLoader\FactoryRuntimeLoader;
@@ -266,10 +266,10 @@ installed:
266266
Next, add the :class:`Symfony\\Bridge\\Twig\\Extension\\TranslationExtension`
267267
to your ``Twig\\Environment`` instance::
268268

269+
use Symfony\Bridge\Twig\Extension\TranslationExtension;
269270
use Symfony\Component\Form\Forms;
270-
use Symfony\Component\Translation\Translator;
271271
use Symfony\Component\Translation\Loader\XliffFileLoader;
272-
use Symfony\Bridge\Twig\Extension\TranslationExtension;
272+
use Symfony\Component\Translation\Translator;
273273

274274
// creates the Translator
275275
$translator = new Translator('en');
@@ -316,8 +316,8 @@ errors are then mapped to the correct field and rendered.
316316

317317
Your integration with the Validation component will look something like this::
318318

319-
use Symfony\Component\Form\Forms;
320319
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
320+
use Symfony\Component\Form\Forms;
321321
use Symfony\Component\Validator\Validation;
322322

323323
$vendorDirectory = realpath(__DIR__.'/../vendor');

0 commit comments

Comments
 (0)