Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf202fb8

Browse files
committed
Removed duplicate use statements
1 parentae66893 commitf202fb8

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

‎components/options_resolver.rst

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ is thrown if an unknown option is passed::
9696
The rest of your code can now access the values of the options without
9797
boilerplate code::
9898

99+
// ...
99100
class Mailer
100101
{
101102
// ...
@@ -117,8 +118,7 @@ If an option must be set by the caller, pass that option to
117118
:method:`Symfony\\Component\\OptionsResolver\\Options::validateRequired`.
118119
For example, let's make the ``host`` option required::
119120

120-
use Symfony\Component\OptionsResolver\Options;
121-
121+
// ...
122122
class Mailer
123123
{
124124
// ...
@@ -160,9 +160,8 @@ Type Validation
160160
You can run additional checks on the options to make sure they were passed
161161
correctly. To validate the types of the options, call
162162
:method:`Symfony\\Component\\OptionsResolver\\Options::validateTypes`::
163-
164-
use Symfony\Component\OptionsResolver\Options;
165-
163+
164+
// ...
166165
class Mailer
167166
{
168167
// ...
@@ -206,8 +205,7 @@ one of ``sendmail``, ``mail`` and ``smtp``. Use the method
206205
:method:`Symfony\\Component\\OptionsResolver\\Options::validateValues` to verify
207206
that the passed option contains one of these values::
208207

209-
use Symfony\Component\OptionsResolver\Options;
210-
208+
// ...
211209
class Mailer
212210
{
213211
// ...
@@ -256,8 +254,7 @@ You can implement this feature by passing a closure as default value of the
256254
``port`` option. The closure receives the options as argument. Based on these
257255
options, you can return the desired default value::
258256

259-
use Symfony\Component\OptionsResolver\Options;
260-
257+
// ...
261258
class Mailer
262259
{
263260
// ...
@@ -305,8 +302,7 @@ If you have a large list of options, the option processing code can take up a
305302
lot of space of your method. To make your code easier to read and maintain, it
306303
is a good practice to put the option definitions into static class properties::
307304

308-
use Symfony\Component\OptionsResolver\Options;
309-
305+
// ...
310306
class Mailer
311307
{
312308
private static $defaultOptions = array(
@@ -382,7 +378,7 @@ configuration object to resolve the options.
382378
The following code demonstrates how to write our previous ``Mailer`` class with
383379
an:class:`Symfony\\Component\\OptionsResolver\\OptionsConfig` object::
384380

385-
use Symfony\Component\OptionsResolver\Options;
381+
// ...
386382
use Symfony\Component\OptionsResolver\OptionsConfig;
387383

388384
class Mailer
@@ -431,9 +427,7 @@ the :class:`Symfony\\Component\\OptionsResolver\\OptionsConfig` instance.
431427
Nevertheless, this design also has a benefit: We can extend the ``Mailer``
432428
class and adjust the options of the parent class in the subclass::
433429

434-
use Symfony\Component\OptionsResolver\Options;
435-
use Symfony\Component\OptionsResolver\OptionsConfig;
436-
430+
// ...
437431
class GoogleMailer extends Mailer
438432
{
439433
protected function configureOptions(OptionsConfig $config)
@@ -476,9 +470,7 @@ however, *no default value* will be added to the options array. Pass the names
476470
of the optional options to
477471
:method:`Symfony\\Component\\OptionsResolver\\OptionsConfig::setOptional`::
478472

479-
use Symfony\Component\OptionsResolver\Options;
480-
use Symfony\Component\OptionsResolver\OptionsConfig;
481-
473+
// ...
482474
class Mailer
483475
{
484476
// ...
@@ -493,6 +485,7 @@ of the optional options to
493485
This is useful if you need to know whether an option was explicitly passed. If
494486
not, it will be missing from the options array::
495487

488+
// ...
496489
class Mailer
497490
{
498491
// ...
@@ -523,8 +516,7 @@ not, it will be missing from the options array::
523516
the options before calling
524517
:method:`Symfony\\Component\\OptionsResolver\\Options::resolve`::
525518

526-
use Symfony\Component\OptionsResolver\Options;
527-
519+
// ...
528520
class Mailer
529521
{
530522
// ...
@@ -557,9 +549,7 @@ again. When using a closure as the new value it is passed 2 arguments:
557549

558550
..code-block::php
559551
560-
use Symfony\Component\OptionsResolver\Options;
561-
use Symfony\Component\OptionsResolver\OptionsConfig;
562-
552+
// ...
563553
class Mailer
564554
{
565555
// ...
@@ -592,9 +582,7 @@ again. When using a closure as the new value it is passed 2 arguments:
592582
to improve performance. This means that the previous default value is not
593583
available when overwriting with another closure::
594584

595-
use Symfony\Component\OptionsResolver\Options;
596-
use Symfony\Component\OptionsResolver\OptionsConfig;
597-
585+
// ...
598586
class Mailer
599587
{
600588
// ...
@@ -635,9 +623,7 @@ you can write normalizers. Normalizers are executed after all options were
635623
processed. You can configure these normalizers by calling
636624
:method:`Symfony\\Components\\OptionsResolver\\OptionsConfig::setNormalizers`::
637625

638-
use Symfony\Component\OptionsResolver\Options;
639-
use Symfony\Component\OptionsResolver\OptionsConfig;
640-
626+
// ...
641627
class Mailer
642628
{
643629
// ...
@@ -661,9 +647,7 @@ The normalizer receives the actual ``$value`` and returns the normalized form.
661647
You see that the closure also takes an ``$options`` parameter. This is useful
662648
if you need to use other options for the normalization::
663649

664-
use Symfony\Component\OptionsResolver\Options;
665-
use Symfony\Component\OptionsResolver\OptionsConfig;
666-
650+
// ...
667651
class Mailer
668652
{
669653
// ...
@@ -693,8 +677,7 @@ if you need to use other options for the normalization::
693677
object, perform normalization after the call to
694678
:method:`Symfony\\Component\\OptionsResolver\\Options::resolve`::
695679

696-
use Symfony\Component\OptionsResolver\Options;
697-
680+
// ...
698681
class Mailer
699682
{
700683
// ...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp