Skip to content

Commit 99d4670

Browse files
committed
ordered use statements for php code examples
1 parent 8b0cc9f commit 99d4670

18 files changed

+30
-32
lines changed

components/ldap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ ______________
152152
Use the entry manager's :method:`Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\EntryManager::applyOperations`
153153
method to update multiple attributes at once::
154154

155-
use Symfony\Component\Ldap\Ldap;
156155
use Symfony\Component\Ldap\Entry;
156+
use Symfony\Component\Ldap\Ldap;
157157
// ...
158158

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

components/mercure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ The following example shows the component in action::
3131
define('HUB_URL', 'https://demo.mercure.rocks/hub');
3232
define('JWT', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.LRLvirgONK13JgacQ_VbcjySbVhkSmHy3IznH3tA9PM');
3333

34+
use Symfony\Component\Mercure\Jwt\StaticJwtProvide;
3435
use Symfony\Component\Mercure\Publisher;
3536
use Symfony\Component\Mercure\Update;
36-
use Symfony\Component\Mercure\Jwt\StaticJwtProvide;
3737

3838
$publisher = new Publisher(HUB_URL, new StaticJwtProvide(JWT));
3939
// Serialize the update, and dispatch it to the hub, that will broadcast it to the clients

components/messenger.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ are configured for you:
8282
Example::
8383

8484
use App\Message\MyMessage;
85-
use Symfony\Component\Messenger\MessageBus;
8685
use Symfony\Component\Messenger\Handler\HandlersLocator;
86+
use Symfony\Component\Messenger\MessageBus;
8787
use Symfony\Component\Messenger\Middleware\HandleMessageMiddleware;
8888

8989
$bus = new MessageBus([
@@ -155,9 +155,9 @@ Instead of dealing directly with the messages in the middleware you receive the
155155
Hence you can inspect the envelope content and its stamps, or add any::
156156

157157
use App\Message\Stamp\AnotherStamp;
158-
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
159158
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
160159
use Symfony\Component\Messenger\Middleware\StackInterface;
160+
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
161161

162162
class MyOwnMiddleware implements MiddlewareInterface
163163
{
@@ -210,8 +210,8 @@ First, create your sender::
210210
namespace App\MessageSender;
211211

212212
use App\Message\ImportantAction;
213-
use Symfony\Component\Messenger\Transport\Sender\SenderInterface;
214213
use Symfony\Component\Messenger\Envelope;
214+
use Symfony\Component\Messenger\Transport\Sender\SenderInterface;
215215

216216
class ImportantActionToEmailSender implements SenderInterface
217217
{
@@ -264,9 +264,9 @@ First, create your receiver::
264264
namespace App\MessageReceiver;
265265

266266
use App\Message\NewOrder;
267+
use Symfony\Component\Messenger\Envelope;
267268
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
268269
use Symfony\Component\Serializer\SerializerInterface;
269-
use Symfony\Component\Messenger\Envelope;
270270

271271
class NewOrdersFromCsvFileReceiver implements ReceiverInterface
272272
{

components/serializer.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,9 @@ for encoding (array to format) and
731731

732732
You can add new encoders to a Serializer instance by using its second constructor argument::
733733

734-
use Symfony\Component\Serializer\Serializer;
735-
use Symfony\Component\Serializer\Encoder\XmlEncoder;
736734
use Symfony\Component\Serializer\Encoder\JsonEncoder;
735+
use Symfony\Component\Serializer\Encoder\XmlEncoder;
736+
use Symfony\Component\Serializer\Serializer;
737737

738738
$encoders = [new XmlEncoder(), new JsonEncoder()];
739739
$serializer = new Serializer([], $encoders);
@@ -1045,11 +1045,11 @@ maximum depth is reached. This is especially useful when serializing entities
10451045
having unique identifiers::
10461046

10471047
use Doctrine\Common\Annotations\AnnotationReader;
1048-
use Symfony\Component\Serializer\Serializer;
10491048
use Symfony\Component\Serializer\Annotation\MaxDepth;
10501049
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
10511050
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
10521051
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1052+
use Symfony\Component\Serializer\Serializer;
10531053

10541054
class Foo
10551055
{
@@ -1211,8 +1211,8 @@ If the class constructor defines arguments, as usually happens with
12111211
arguments are missing. In those cases, use the ``default_constructor_arguments``
12121212
context option::
12131213

1214-
use Symfony\Component\Serializer\Serializer;
12151214
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1215+
use Symfony\Component\Serializer\Serializer;
12161216

12171217
class MyObj
12181218
{
@@ -1331,8 +1331,8 @@ this is already set up and you only need to provide the configuration. Otherwise
13311331

13321332
// ...
13331333
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1334-
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
13351334
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
1335+
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
13361336
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
13371337
use Symfony\Component\Serializer\Serializer;
13381338

components/var_dumper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ Outside a Symfony application, use the :class:`Symfony\\Component\\VarDumper\\Du
152152

153153
require __DIR__.'/vendor/autoload.php';
154154

155-
use Symfony\Component\VarDumper\VarDumper;
156155
use Symfony\Component\VarDumper\Cloner\VarCloner;
157156
use Symfony\Component\VarDumper\Dumper\CliDumper;
158157
use Symfony\Component\VarDumper\Dumper\ContextProvider\CliContextProvider;
159158
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
160159
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
161160
use Symfony\Component\VarDumper\Dumper\ServerDumper;
161+
use Symfony\Component\VarDumper\VarDumper;
162162

163163
$cloner = new VarCloner();
164164
$fallbackDumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg']) ? new CliDumper() : new HtmlDumper();

doctrine/event_listeners_subscribers.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,10 @@ interface and have an event method for each event it subscribes to::
140140
// src/EventListener/SearchIndexerSubscriber.php
141141
namespace App\EventListener;
142142

143-
use AppBundle\Entity\Product;
143+
use App\Entity\Product;
144144
use Doctrine\Common\EventSubscriber;
145145
// for Doctrine < 2.4: use Doctrine\ORM\Event\LifecycleEventArgs;
146146
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
147-
use App\Entity\Product;
148147
use Doctrine\ORM\Events;
149148

150149
class SearchIndexerSubscriber implements EventSubscriber

form/form_themes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ based on your form type name (e.g. ``ProductType`` equates to ``product``). If
260260
you're not sure what your form name is, look at the HTML code rendered for your
261261
form. You can also define this value explicitly with the ``block_name`` option::
262262

263-
use Symfony\Component\Form\FormBuilderInterface;
264263
use Symfony\Component\Form\Extension\Core\Type\TextType;
264+
use Symfony\Component\Form\FormBuilderInterface;
265265

266266
public function buildForm(FormBuilderInterface $builder, array $options)
267267
{

mercure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ it will be handled automatically::
249249
namespace App\Controller;
250250

251251
use Symfony\Component\HttpFoundation\Response;
252-
use Symfony\Component\Messenger\MessageBusInterface;
253252
use Symfony\Component\Mercure\Update;
253+
use Symfony\Component\Messenger\MessageBusInterface;
254254

255255
class PublishController
256256
{

messenger.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,10 @@ Create your Transport Factory
694694
You need to give FrameworkBundle the opportunity to create your transport from a
695695
DSN. You will need a transport factory::
696696

697-
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
698-
use Symfony\Component\Messenger\Transport\TransportInterface;
699697
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
700698
use Symfony\Component\Messenger\Transport\Sender\SenderInterface;
699+
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
700+
use Symfony\Component\Messenger\Transport\TransportInterface;
701701

702702
class YourTransportFactory implements TransportFactoryInterface
703703
{

quick_tour/flex_recipes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ Are you building an API? You can already return JSON easily from any controller:
156156
// src/Controller/DefaultController.php
157157
namespace App\Controller;
158158

159-
use Symfony\Component\Routing\Annotation\Route;
160159
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
160+
use Symfony\Component\Routing\Annotation\Route;
161161

162162
class DefaultController extends AbstractController
163163
{

quick_tour/the_architecture.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use the logger in a controller, add a new argument type-hinted with ``LoggerInte
2525
namespace App\Controller;
2626

2727
use Psr\Log\LoggerInterface;
28-
use Symfony\Component\Routing\Annotation\Route;
2928
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
29+
use Symfony\Component\Routing\Annotation\Route;
3030

3131
class DefaultController extends AbstractController
3232
{
@@ -110,8 +110,8 @@ Great! You can use this immediately in your controller::
110110

111111
use App\GreetingGenerator;
112112
use Psr\Log\LoggerInterface;
113-
use Symfony\Component\Routing\Annotation\Route;
114113
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
114+
use Symfony\Component\Routing\Annotation\Route;
115115

116116
class DefaultController extends AbstractController
117117
{

reference/configuration/swiftmailer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ alternatives based on the :ref:`service binding <services-binding>` feature:
380380
381381
// config/services.php
382382
use App\Some\Service;
383-
use Symfony\Component\DependencyInjection\Reference;
384383
use Psr\Log\LoggerInterface;
384+
use Symfony\Component\DependencyInjection\Reference;
385+
385386
386387
$container->register(Service::class)
387388
->setPublic(true)

reference/constraints/Choice.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,11 @@ you can pass the class name and the method as an array.
259259
namespace App\Entity;
260260
261261
use App\Entity\Genre;
262-
use Symfony\Component\Validator\Mapping\ClassMetadata;
263262
use Symfony\Component\Validator\Constraints as Assert;
263+
use Symfony\Component\Validator\Mapping\ClassMetadata;
264264
265265
class Author
266266
{
267-
protected $genre;
268-
269267
public static function loadValidatorMetadata(ClassMetadata $metadata)
270268
{
271269
$metadata->addPropertyConstraint('genre', new Assert\Choice([

reference/constraints/DivisibleBy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ The following constraints ensure that:
8585
// src/Entity/Item.php
8686
namespace App\Entity;
8787
88-
use Symfony\Component\Validator\Mapping\ClassMetadata;
8988
use Symfony\Component\Validator\Constraints as Assert;
89+
use Symfony\Component\Validator\Mapping\ClassMetadata;
9090
9191
class Item
9292
{

reference/constraints/Url.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the
146146
// src/Entity/Author.php
147147
namespace App\Entity;
148148
149-
use Symfony\Component\Validator\Mapping\ClassMetadata;
150149
use Symfony\Component\Validator\Constraints as Assert;
150+
use Symfony\Component\Validator\Mapping\ClassMetadata;
151151
152152
class Author
153153
{

reference/dic_tags.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,8 +1082,8 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
10821082
10831083
.. code-block:: php
10841084
1085-
use App\Twig\AppExtension;
10861085
use App\Twig\AnotherExtension;
1086+
use App\Twig\AppExtension;
10871087
10881088
$container
10891089
->register(AppExtension::class)
@@ -1224,7 +1224,6 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
12241224
.. code-block:: php
12251225
12261226
use App\Twig\AppExtension;
1227-
use App\Twig\AnotherExtension;
12281227
12291228
$container
12301229
->register(AppExtension::class)

security/form_login_setup.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ a traditional HTML form that submits to ``/login``:
168168

169169
use App\Entity\User;
170170
use Doctrine\ORM\EntityManagerInterface;
171-
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
171+
172172
use Symfony\Component\HttpFoundation\RedirectResponse;
173173
use Symfony\Component\HttpFoundation\Request;
174174
use Symfony\Component\Routing\RouterInterface;
175175
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
176176
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
177+
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
177178
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
178179
use Symfony\Component\Security\Core\Security;
179180
use Symfony\Component\Security\Core\User\UserInterface;

security/user_provider.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ interface only requires one method: ``loadUserByUsername($username)``::
128128
// src/Repository/UserRepository.php
129129
namespace App\Repository;
130130

131-
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
132131
use Doctrine\ORM\EntityRepository;
132+
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
133133

134134
class UserRepository extends EntityRepository implements UserLoaderInterface
135135
{
@@ -480,8 +480,8 @@ and want to inject in your ``LoginFormAuthenticator`` a user provider of type
480480
// src/Security/LoginFormAuthenticator.php
481481
namespace App\Security;
482482

483-
use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
484483
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
484+
use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
485485

486486
class LoginFormAuthenticator extends AbstractFormLoginAuthenticator
487487
{

0 commit comments

Comments
 (0)