Skip to content

Commit b649271

Browse files
committed
Merge branch '3.4' into 4.0
* 3.4: Update typescript.rst Corrected titles of test tools and use safe url for phpspec Add 2 solutions for the 'option with optional argument' problem Simplify the explanation leaving just one solution Add 2 solutions for the 'option with optional argument' problem Fix a typo in the HTML5 date form property Export workflow chart to SVG Remove extra brace in the release schedule Update 3.3-di-changes.rst
2 parents 8934c07 + 022bd2f commit b649271

File tree

7 files changed

+69
-23
lines changed

7 files changed

+69
-23
lines changed

best_practices/tests.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Unit Tests
1313
Unit tests are used to test your "business logic", which should live in classes
1414
that are independent of Symfony. For that reason, Symfony doesn't really
1515
have an opinion on what tools you use for unit testing. However, the most
16-
popular tools are `PhpUnit`_ and `PhpSpec`_.
16+
popular tools are `PHPUnit`_ and `PHPSpec`_.
1717

1818
Functional Tests
1919
----------------
@@ -114,8 +114,8 @@ Learn More about Functional Tests
114114
Consider using the `HautelookAliceBundle`_ to generate real-looking data for
115115
your test fixtures using `Faker`_ and `Alice`_.
116116

117-
.. _`PhpUnit`: https://phpunit.de/
118-
.. _`PhpSpec`: http://www.phpspec.net/
117+
.. _`PHPUnit`: https://phpunit.de/
118+
.. _`PHPSpec`: https://www.phpspec.net/
119119
.. _`smoke testing`: https://en.wikipedia.org/wiki/Smoke_testing_(software)
120120
.. _`Mink`: http://mink.behat.org
121121
.. _`HautelookAliceBundle`: https://github.com/hautelook/AliceBundle

console/input.rst

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ values after a white space or an ``=`` sign (e.g. ``--iterations 5`` or
179179
``--iterations=5``), but short options can only use white spaces or no
180180
separation at all (e.g. ``-i 5`` or ``-i5``).
181181

182+
.. caution::
183+
184+
While it is possible to separate an option from its value with a white space,
185+
using this form leads to an ambiguity should the option appear before the
186+
command name. For example, ``php app/console --iterations 5 app:greet Fabien``
187+
is ambiguous; Symfony would interpret ``5`` as the command name. To avoid
188+
this situation, always place options after the command name, or avoid using
189+
a space to separate the option name from its value.
190+
182191
There are four option variants you can use:
183192

184193
``InputOption::VALUE_IS_ARRAY``
@@ -209,21 +218,53 @@ You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or
209218
array('blue', 'red')
210219
);
211220

212-
.. tip::
221+
Options with optional arguments
222+
-------------------------------
223+
224+
There is nothing forbidding you to create a command with an option that
225+
optionally accepts a value, but it's a bit tricky. Consider this example::
226+
227+
// ...
228+
use Symfony\Component\Console\Input\InputOption;
229+
230+
$this
231+
// ...
232+
->addOption(
233+
'yell',
234+
null,
235+
InputOption::VALUE_OPTIONAL,
236+
'Should I yell while greeting?'
237+
);
238+
239+
This option can be used in 3 ways: ``--yell``, ``yell=louder``, and not passing
240+
the option at all. However, it's hard to distinguish between passing the option
241+
without a value (``greet --yell``) and not passing the option (``greet``).
242+
243+
To solve this issue, you have to set the option's default value to ``false``::
244+
245+
// ...
246+
use Symfony\Component\Console\Input\InputOption;
247+
248+
$this
249+
// ...
250+
->addOption(
251+
'yell',
252+
null,
253+
InputOption::VALUE_OPTIONAL,
254+
'Should I yell while greeting?',
255+
false // this is the new default value, instead of null
256+
);
213257

214-
There is nothing forbidding you to create a command with an option that
215-
optionally accepts a value. However, there is no way you can distinguish
216-
when the option was used without a value (``command --language``) or when
217-
it wasn't used at all (``command``). In both cases, the value retrieved for
218-
the option will be ``null``.
258+
Now check the value of the option and keep in mind that ``false !== null``::
259+
260+
$optionValue = $input->getOptions('yell');
261+
$yell = ($optionValue !== false);
262+
$yellLouder = ($optionValue === 'louder');
219263

220264
.. caution::
221265

222-
While it is possible to separate an option from its value with a white space,
223-
using this form leads to an ambiguity should the option appear before the
224-
command name. For example, ``php bin/console --iterations 5 app:greet Fabien``
225-
is ambiguous; Symfony would interpret ``5`` as the command name. To avoid
226-
this situation, always place options after the command name, or avoid using
227-
a space to separate the option name from its value.
266+
Due to a PHP limitation, passing an empty string is indistinguishable from
267+
not passing any value at all. In ``command --prefix`` and ``command --prefix=''``
268+
cases, the value of the ``prefix`` option will be ``null``.
228269

229270
.. _`docopt standard`: http://docopt.org/

contributing/community/releases.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Version Feature Freeze Release End of Maintenance End of Life
122122
`2.6`_ 09/2014 11/2014 07/2015 (8 months) 01/2016
123123
`2.7`_ (LTS) 03/2015 05/2015 05/2018 (36 months) 05/2019
124124
`2.8`_ (LTS) 09/2015 11/2015 11/2018 (36 months [2]_) 11/2019
125-
`3.0`_ 09/2015 11/2015 07/2016 (8 months) [3]_) 01/2017
125+
`3.0`_ 09/2015 11/2015 07/2016 (8 months [3]_) 01/2017
126126
`3.1`_ 03/2016 05/2016 01/2017 (8 months) 07/2017
127127
`3.2`_ 09/2016 11/2016 07/2017 (8 months) 01/2018
128128
`3.3`_ 03/2017 05/2017 01/2018 (8 months) 07/2018
@@ -194,7 +194,7 @@ version is published every two years and there is a year to upgrade.
194194

195195
.. _Semantic Versioning: https://semver.org/
196196
.. _Git repository: https://github.com/symfony/symfony
197-
.. _SensioLabs: http://sensiolabs.com/
197+
.. _SensioLabs: https://sensiolabs.com/
198198
.. _roadmap notification: https://symfony.com/roadmap
199199
.. _extended to September 2014: https://symfony.com/blog/extended-maintenance-for-symfony-2-4
200200
.. _timeline calculator: https://symfony.com/roadmap#checker

frontend/encore/typescript.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ also configure the `ts-loader options`_ via a callback:
2828
2929
.enableTypeScriptLoader(function (typeScriptConfigOptions) {
3030
typeScriptConfigOptions.transpileOnly = true;
31-
typeScriptConfigOptions.configFileName = '/path/to/tsconfig.json';
31+
typeScriptConfigOptions.configFile = '/path/to/tsconfig.json';
3232
});
3333
3434
If React assets are enabled (``.enableReactPreset()``), any ``.tsx`` file will be

reference/forms/types/options/html5.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ html5
66
If this is set to ``true`` (the default), it'll use the HTML5 type (date, time
77
or datetime) to render the field. When set to ``false``, it'll use the text type.
88

9-
This is useful when you want to use a custom JavaScript datapicker, which
9+
This is useful when you want to use a custom JavaScript datepicker, which
1010
often requires a text type instead of an HTML5 type.

service_container/3.3-di-changes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The Symfony 3.3 DI Container Changes Explained (autowiring, _defaults, etc)
22
===========================================================================
33

4-
If you look at the ``services.yaml`` file in a new Symfony 3.3 project, you'll
4+
If you look at the ``services.yaml`` file in a new Symfony 3.3 or newer project, you'll
55
notice some big changes: ``_defaults``, ``autowiring``, ``autoconfigure`` and more.
66
These features are designed to *automate* configuration and make development faster,
77
without sacrificing predictability, which is very important! Another goal is to make
@@ -589,6 +589,8 @@ to the new id. Create a new ``legacy_aliases.yml`` file:
589589
590590
# app/config/legacy_aliases.yml
591591
services:
592+
_defaults:
593+
public: true
592594
# aliases so that the old service ids can still be accessed
593595
# remove these if/when you are not fetching these directly
594596
# from the container via $container->get()

workflow/dumping-workflows.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ How to Dump Workflows
66

77
To help you debug your workflows, you can dump a representation of your workflow
88
with the use of a ``DumperInterface``. Use the ``GraphvizDumper`` to create a
9-
PNG image of the workflow defined above::
9+
PNG or SVG image of the workflow defined above::
1010

1111
// dump-graph.php
1212
$dumper = new GraphvizDumper();
1313
echo $dumper->dump($definition);
1414

1515
.. code-block:: terminal
1616
17-
$ php dump-graph.php | dot -Tpng -o graph.png
17+
$ php dump-graph.php | dot -Tsvg -o graph.svg
18+
19+
# run this command if you prefer PNG images:
20+
# $ php dump-graph.php | dot -Tpng -o graph.png
1821
1922
The result will look like this:
2023

@@ -25,7 +28,7 @@ Inside a Symfony application, you can dump the dot file with the
2528

2629
.. code-block:: terminal
2730
28-
$ php bin/console workflow:dump name | dot -Tpng -o graph.png
31+
$ php bin/console workflow:dump name | dot -Tsvg -o graph.svg
2932
3033
.. note::
3134

0 commit comments

Comments
 (0)