Skip to content

Commit 86ac962

Browse files
committed
ordered use statements in code examples
1 parent f7089f4 commit 86ac962

File tree

133 files changed

+252
-249
lines changed

Some content is hidden

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

133 files changed

+252
-249
lines changed

best_practices/business-logic.rst

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

230230
namespace AppBundle\Entity;
231231

232-
use Doctrine\ORM\Mapping as ORM;
233232
use Doctrine\Common\Collections\ArrayCollection;
233+
use Doctrine\ORM\Mapping as ORM;
234234

235235
/**
236236
* @ORM\Entity

best_practices/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ whereas they cannot access the container parameters::
137137

138138
namespace AppBundle\Repository;
139139

140-
use Doctrine\ORM\EntityRepository;
141140
use AppBundle\Entity\Post;
141+
use Doctrine\ORM\EntityRepository;
142142

143143
class PostRepository extends EntityRepository
144144
{

best_practices/forms.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ form in its own PHP class::
2121

2222
use AppBundle\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
{
@@ -109,11 +109,11 @@ some developers configure form buttons in the controller::
109109

110110
namespace AppBundle\Controller\Admin;
111111

112-
use Symfony\Component\HttpFoundation\Request;
113-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
114-
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
115112
use AppBundle\Entity\Post;
116113
use AppBundle\Form\PostType;
114+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
115+
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
116+
use Symfony\Component\HttpFoundation\Request;
117117

118118
class PostController extends Controller
119119
{

best_practices/security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ the same ``getAuthorEmail()`` logic you used above::
259259

260260
namespace AppBundle\Security;
261261

262+
use AppBundle\Entity\Post;
262263
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
263264
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
264265
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
265266
use Symfony\Component\Security\Core\User\UserInterface;
266-
use AppBundle\Entity\Post;
267267

268268
class PostVoter extends Voter
269269
{

bundles/configuration.rst

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

266-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
267266
use Symfony\Component\Config\FileLocator;
267+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
268268

269269
public function load(array $configs, ContainerBuilder $container)
270270
{

bundles/extension.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ the extension!
9393
For instance, assume you have a file called ``services.xml`` in the
9494
``Resources/config`` directory of your bundle, your ``load()`` method looks like::
9595

96-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9796
use Symfony\Component\Config\FileLocator;
97+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9898

9999
// ...
100100
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
@@ -28,9 +28,9 @@ To give an Extension the power to do this, it needs to implement
2828
// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php
2929
namespace Acme\HelloBundle\DependencyInjection;
3030

31-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
32-
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
3331
use Symfony\Component\DependencyInjection\ContainerBuilder;
32+
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
33+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
3434

3535
class AcmeHelloExtension extends Extension implements PrependExtensionInterface
3636
{

components/asset.rst

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

228-
use Symfony\Component\Asset\PathPackage;
229228
use Symfony\Component\Asset\Context\RequestStackContext;
229+
use Symfony\Component\Asset\PathPackage;
230230
// ...
231231

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

318-
use Symfony\Component\Asset\UrlPackage;
319318
use Symfony\Component\Asset\Context\RequestStackContext;
319+
use Symfony\Component\Asset\UrlPackage;
320320
// ...
321321

322322
$urlPackage = new UrlPackage(
@@ -341,9 +341,9 @@ In the following example, all packages use the same versioning strategy, but
341341
they all have different base paths::
342342

343343
use Symfony\Component\Asset\Package;
344+
use Symfony\Component\Asset\Packages;
344345
use Symfony\Component\Asset\PathPackage;
345346
use Symfony\Component\Asset\UrlPackage;
346-
use Symfony\Component\Asset\Packages;
347347
// ...
348348

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

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
@@ -112,8 +112,8 @@ thrown by the application.
112112
Listeners receive a
113113
:class:`Symfony\\Component\\Console\\Event\\ConsoleErrorEvent` event::
114114

115-
use Symfony\Component\Console\Event\ConsoleErrorEvent;
116115
use Symfony\Component\Console\ConsoleEvents;
116+
use Symfony\Component\Console\Event\ConsoleErrorEvent;
117117

118118
$dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) {
119119
$output = $event->getOutput();
@@ -146,8 +146,8 @@ listener (like sending logs, closing a database connection, sending emails,
146146
Listeners receive a
147147
:class:`Symfony\\Component\\Console\\Event\\ConsoleTerminateEvent` event::
148148

149-
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
150149
use Symfony\Component\Console\ConsoleEvents;
150+
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
151151

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

components/console/helpers/questionhelper.rst

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

347-
use Symfony\Component\Console\Helper\QuestionHelper;
348347
use Symfony\Component\Console\Helper\HelperSet;
348+
use Symfony\Component\Console\Helper\QuestionHelper;
349349
use Symfony\Component\Console\Tester\CommandTester;
350350

351351
// ...

components/console/helpers/table.rst

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

194194
use Symfony\Component\Console\Helper\Table;
195-
use Symfony\Component\Console\Helper\TableSeparator;
196195
use Symfony\Component\Console\Helper\TableCell;
196+
use Symfony\Component\Console\Helper\TableSeparator;
197197

198198
$table = new Table($output);
199199
$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
@@ -200,8 +200,8 @@ files. To do this you also need to install
200200

201201
Loading an XML config file::
202202

203-
use Symfony\Component\DependencyInjection\ContainerBuilder;
204203
use Symfony\Component\Config\FileLocator;
204+
use Symfony\Component\DependencyInjection\ContainerBuilder;
205205
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
206206

207207
$containerBuilder = new ContainerBuilder();
@@ -210,8 +210,8 @@ Loading an XML config file::
210210

211211
Loading a YAML config file::
212212

213-
use Symfony\Component\DependencyInjection\ContainerBuilder;
214213
use Symfony\Component\Config\FileLocator;
214+
use Symfony\Component\DependencyInjection\ContainerBuilder;
215215
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
216216

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

238-
use Symfony\Component\DependencyInjection\ContainerBuilder;
239238
use Symfony\Component\Config\FileLocator;
239+
use Symfony\Component\DependencyInjection\ContainerBuilder;
240240
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
241241

242242
$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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ order. Start by creating this custom event class and documenting it::
254254

255255
namespace Acme\Store\Event;
256256

257-
use Symfony\Component\EventDispatcher\Event;
258257
use Acme\Store\Order;
258+
use Symfony\Component\EventDispatcher\Event;
259259

260260
/**
261261
* The order.placed event is dispatched each time an order is created
@@ -297,8 +297,8 @@ method notifies all listeners of the given event. It takes two arguments:
297297
the name of the event to dispatch and the ``Event`` instance to pass to
298298
each listener of that event::
299299

300-
use Acme\Store\Order;
301300
use Acme\Store\Event\OrderPlacedEvent;
301+
use Acme\Store\Order;
302302

303303
// the order is somehow created or retrieved
304304
$order = new Order();
@@ -335,10 +335,10 @@ Take the following example of a subscriber that subscribes to the
335335

336336
namespace Acme\Store\Event;
337337

338+
use Acme\Store\Event\OrderPlacedEvent;
338339
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
339340
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
340341
use Symfony\Component\HttpKernel\KernelEvents;
341-
use Acme\Store\Event\OrderPlacedEvent;
342342

343343
class StoreSubscriber implements EventSubscriberInterface
344344
{

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/form.rst

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

93-
use Symfony\Component\Form\Forms;
9493
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
94+
use Symfony\Component\Form\Forms;
9595

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

123+
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
123124
use Symfony\Component\Form\Forms;
124125
use Symfony\Component\HttpFoundation\Session\Session;
125-
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
126-
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
127-
use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator;
128126
use Symfony\Component\Security\Csrf\CsrfTokenManager;
127+
use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator;
128+
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
129129

130130
// creates a Session object from the HttpFoundation component
131131
$session = new Session();
@@ -181,10 +181,11 @@ that help you render the HTML widget, label and error 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;
184+
185185
use Symfony\Bridge\Twig\Extension\FormExtension;
186-
use Symfony\Component\Form\FormRenderer;
187186
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
187+
use Symfony\Component\Form\FormRenderer;
188+
use Symfony\Component\Form\Forms;
188189
use Twig\Environment;
189190
use Twig\Loader\FilesystemLoader;
190191
use Twig\RuntimeLoader\FactoryRuntimeLoader;
@@ -266,10 +267,10 @@ installed:
266267
Next, add the :class:`Symfony\\Bridge\\Twig\\Extension\\TranslationExtension`
267268
to your ``Twig\\Environment`` instance::
268269

270+
use Symfony\Bridge\Twig\Extension\TranslationExtension;
269271
use Symfony\Component\Form\Forms;
270-
use Symfony\Component\Translation\Translator;
271272
use Symfony\Component\Translation\Loader\XliffFileLoader;
272-
use Symfony\Bridge\Twig\Extension\TranslationExtension;
273+
use Symfony\Component\Translation\Translator;
273274

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

317318
Your integration with the Validation component will look something like this::
318319

319-
use Symfony\Component\Form\Forms;
320320
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
321+
use Symfony\Component\Form\Forms;
321322
use Symfony\Component\Validator\Validation;
322323

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

components/http_foundation/session_configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ Symfony provides drivers for the following native save handler as an example:
4242
Example usage::
4343

4444
use Symfony\Component\HttpFoundation\Session\Session;
45-
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
4645
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
46+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
4747

4848
$sessionStorage = new NativeSessionStorage([], new NativeFileSessionHandler());
4949
$session = new Session($sessionStorage);
@@ -80,8 +80,8 @@ easily serve as examples if you wish to write your own.
8080
Example usage::
8181

8282
use Symfony\Component\HttpFoundation\Session\Session;
83-
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
8483
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
84+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
8585

8686
$pdo = new \PDO(...);
8787
$sessionStorage = new NativeSessionStorage([], new PdoSessionHandler($pdo));

components/http_foundation/session_testing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ For unit testing where it is not necessary to persist the session, you should
4040
simply swap out the default storage engine with
4141
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage`::
4242

43-
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
4443
use Symfony\Component\HttpFoundation\Session\Session;
45-
44+
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
45+
s
4646
$session = new Session(new MockArraySessionStorage());
4747

4848
Functional Testing

components/ldap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ Creating or Updating Entries
119119
The Ldap component provides means to create new LDAP entries, update or even
120120
delete existing ones::
121121

122-
use Symfony\Component\Ldap\Ldap;
123122
use Symfony\Component\Ldap\Entry;
123+
use Symfony\Component\Ldap\Ldap;
124124
// ...
125125

126126
$entry = new Entry('cn=Fabien Potencier,dc=symfony,dc=com', [

0 commit comments

Comments
 (0)