Skip to content

Commit 9bf91ce

Browse files
committed
Merge branch '3.4' into 4.0
* 3.4: (25 commits) Fixed merge errors Client's history clear alternative Don't mention the abandoned JMSTranslationBundle Reworded the console verbosity article to explain SHELL_VERBOSITY too Added a tip about tests and BCrypt Document that Doctrine associations don't work across different entity managers Update entity_provider.rst Reword Make require as a dev dependency Fixed invalid form validation reference use a class based service ID Merged new example in older example, removing some text Fix typo Document typed arrays in optionsresolver Fixed a wrong reference Document that Doctrine associations don't work across different entity managers Don't use OutputInterface::VERBOSITY constants, use PHP methods instead Mention the new behavior of dump() which returns the passed value Mentioned APP_ENV for Flex apps Updated LDAP documentation for Symfony 3.1 ...
2 parents 1ffcc41 + 4b9bef8 commit 9bf91ce

17 files changed

+160
-65
lines changed

best_practices/i18n.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ XLIFF notes allow you to define that context.
3636

3737
.. tip::
3838

39-
The Apache-licensed `JMSTranslationBundle`_ offers you a web interface for
40-
viewing and editing these translation files. It also has advanced extractors
41-
that can read your project and automatically update the XLIFF files.
39+
The `PHP Translation Bundle`_ includes advanced extractors that can read
40+
your project and automatically update the XLIFF files.
4241

4342
Translation Keys
4443
----------------
@@ -80,4 +79,4 @@ English in the application would be:
8079

8180
Next: :doc:`/best_practices/security`
8281

83-
.. _`JMSTranslationBundle`: https://github.com/schmittjoh/JMSTranslationBundle
82+
.. _`PHP Translation Bundle`: https://github.com/php-translation/symfony-bundle

components/browser_kit.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ also delete all the cookies::
226226
$client = new Client();
227227
$client->request('GET', '/');
228228

229-
// delete history
229+
// reset the client (history and cookies are cleared too)
230230
$client->restart();
231231

232232
Learn more

components/ldap.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,52 @@ LDAP server), you may query the LDAP server using the
7373

7474
// ...
7575

76-
$ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
76+
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
77+
$results = $query->execute();
78+
79+
foreach ($results as $entry) {
80+
// Do something with the results
81+
}
82+
83+
By default, LDAP entries are lazy-loaded. If you wish to fetch
84+
all entries in a single call and do something with the results'
85+
array, you may use the
86+
:method:`Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\Collection::toArray` method::
87+
88+
// ...
89+
90+
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
91+
$results = $query->execute()->toArray();
92+
93+
// Do something with the results array
94+
95+
Creating or updating entries
96+
----------------------------
97+
98+
Since version 3.1, The Ldap component provides means to create
99+
new LDAP entries, update or even delete existing ones::
100+
101+
use Symfony\Component\Ldap\Entry;
102+
// ...
103+
104+
$entry = new Entry('cn=Fabien Potencier,dc=symfony,dc=com', array(
105+
'sn' => array('fabpot'),
106+
'objectClass' => array('inetOrgPerson'),
107+
));
108+
109+
$em = $ldap->getEntryManager();
110+
111+
// Creating a new entry
112+
$em->add($entry);
113+
114+
// Finding and updating an existing entry
115+
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
116+
$result = $query->execute();
117+
$entry = $result[0];
118+
$entry->addAttribute('email', array('fabpot@symfony.com'));
119+
$em->update($entry);
120+
121+
// Removing an existing entry
122+
$em->remove(new Entry('cn=Test User,dc=symfony,dc=com'));
77123

78124
.. _Packagist: https://packagist.org/packages/symfony/ldap

components/options_resolver.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,27 @@ correctly. To validate the types of the options, call
317317
public function configureOptions(OptionsResolver $resolver)
318318
{
319319
// ...
320+
321+
// specify one allowed type
320322
$resolver->setAllowedTypes('host', 'string');
323+
324+
// specify multiple allowed types
321325
$resolver->setAllowedTypes('port', array('null', 'int'));
326+
327+
// check all items in an array recursively for a type
328+
$resolver->setAllowedTypes('dates', 'DateTime[]');
329+
$resolver->setAllowedtypes('ports', 'int[]');
322330
}
323331
}
324332

325-
For each option, you can define either just one type or an array of acceptable
326-
types. You can pass any type for which an ``is_<type>()`` function is defined
327-
in PHP. Additionally, you may pass fully qualified class or interface names.
333+
You can pass any type for which an ``is_<type>()`` function is defined in PHP.
334+
You may also pass fully qualified class or interface names (which is checked
335+
using ``instanceof``). Additionally, you can validate all items in an array
336+
recursively by suffixing the type with ``[]``.
337+
338+
.. versionadded:: 3.4
339+
Validating types of array items recursively was introduced in Symfony 3.4.
340+
Prior to Symfony 3.4, only scalar values could be validated.
328341

329342
If you pass an invalid option now, an
330343
:class:`Symfony\\Component\\OptionsResolver\\Exception\\InvalidOptionsException`

components/phpunit_bridge.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,25 @@ in the **Unsilenced** section of the deprecation report.
113113
Mark Tests as Legacy
114114
--------------------
115115

116-
Add the ``@group legacy`` annotation to a test class or method to mark it
117-
as legacy.
116+
There are three ways to mark a test as legacy:
117+
118+
* (**Recommended**) Add the ``@group legacy`` annotation to its class or method;
119+
120+
* Make its class name start with the ``Legacy`` prefix;
121+
122+
* Make its method name start with ``testLegacy*()`` instead of ``test*()``.
123+
124+
.. note::
125+
126+
If your data provider calls code that would usually trigger a deprecation,
127+
you can prefix its name with ``provideLegacy`` or ``getLegacy`` to silent
128+
these deprecations. If your data provider does not execute deprecated
129+
code, it is not required to choose a special naming just because the
130+
test being fed by the data provider is marked as legacy.
131+
132+
Also be aware that choosing one of the two legacy prefixes will not mark
133+
tests as legacy that make use of this data provider. You still have to
134+
mark them as legacy tests explicitly.
118135

119136
Configuration
120137
-------------

components/var_dumper.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ For example::
5050

5151
dump($someVar);
5252

53+
// dump() returns the passed value, so you can dump an object and keep using it
54+
dump($someObject)->someMethod();
55+
5356
By default, the output format and destination are selected based on your
5457
current PHP SAPI:
5558

console/verbosity.rst

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
Verbosity Levels
22
================
33

4-
The console has five verbosity levels. These are defined in the
5-
:class:`Symfony\\Component\\Console\\Output\\OutputInterface`:
6-
7-
=========================================== ================================== =====================
8-
Value Meaning Console option
9-
=========================================== ================================== =====================
10-
``OutputInterface::VERBOSITY_QUIET`` Do not output any messages ``-q`` or ``--quiet``
11-
``OutputInterface::VERBOSITY_NORMAL`` The default verbosity level (none)
12-
``OutputInterface::VERBOSITY_VERBOSE`` Increased verbosity of messages ``-v``
13-
``OutputInterface::VERBOSITY_VERY_VERBOSE`` Informative non essential messages ``-vv``
14-
``OutputInterface::VERBOSITY_DEBUG`` Debug messages ``-vvv``
15-
=========================================== ================================== =====================
4+
Console commands have different verbosity levels, which determine the messages
5+
displayed in their output. By default, commands display only the most useful
6+
messages, but you can control their verbosity with the ``-q`` and ``-v`` options:
7+
8+
.. code-block:: terminal
9+
10+
# do not output any message (not even the command result messages)
11+
$ php bin/console some-command -q
12+
$ php bin/console some-command --quiet
13+
14+
# normal behavior, no option required (display only the useful messages)
15+
$ php bin/console some-command
16+
17+
# increase verbosity of messages
18+
$ php bin/console some-command -v
19+
20+
# display also the informative non essential messages
21+
$ php bin/console some-command -vv
22+
23+
# display all messages (useful to debug errors)
24+
$ php bin/console some-command -vvv
25+
26+
The verbosity level can also be controlled globally for all commands with the
27+
``SHELL_VERBOSITY`` environment variable (the ``-q`` and ``-v`` options still
28+
have more precedence over the value of ``SHELL_VERBOSITY``):
29+
30+
===================== ========================= ===========================================
31+
Console option ``SHELL_VERBOSITY`` value Equivalent PHP constant
32+
===================== ========================= ===========================================
33+
``-q`` or ``--quiet`` ``-1`` ``OutputInterface::VERBOSITY_QUIET``
34+
(none) ``0`` ``OutputInterface::VERBOSITY_NORMAL``
35+
``-v`` ``1`` ``OutputInterface::VERBOSITY_VERBOSE``
36+
``-vv`` ``2`` ``OutputInterface::VERBOSITY_VERY_VERBOSE``
37+
``-vvv`` ``3`` ``OutputInterface::VERBOSITY_DEBUG``
38+
===================== ========================= ===========================================
1639

1740
It is possible to print a message in a command for only a specific verbosity
1841
level. For example::
@@ -31,38 +54,19 @@ level. For example::
3154
'Password: '.$input->getArgument('password'),
3255
));
3356

34-
// the user class is only printed when the verbose verbosity level is used
35-
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
57+
// available methods: ->isQuiet(), ->isVerbose(), ->isVeryVerbose(), ->isDebug()
58+
if ($output->isVerbose()) {
3659
$output->writeln('User class: '.get_class($user));
3760
}
3861

39-
// alternatively you can pass the verbosity level to writeln()
62+
// alternatively you can pass the verbosity level PHP constant to writeln()
4063
$output->writeln(
4164
'Will only be printed in verbose mode or higher',
4265
OutputInterface::VERBOSITY_VERBOSE
4366
);
4467
}
4568
}
4669

47-
There are also more semantic methods you can use to test for each of the
48-
verbosity levels::
49-
50-
if ($output->isQuiet()) {
51-
// ...
52-
}
53-
54-
if ($output->isVerbose()) {
55-
// ...
56-
}
57-
58-
if ($output->isVeryVerbose()) {
59-
// ...
60-
}
61-
62-
if ($output->isDebug()) {
63-
// ...
64-
}
65-
6670
When the quiet level is used, all output is suppressed as the default
6771
:method:`Symfony\\Component\\Console\\Output\\Output::write` method returns
6872
without actually printing.

deployment.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ as you normally do:
156156
.. caution::
157157

158158
If you get a "class not found" error during this step, you may need to
159-
run ``export SYMFONY_ENV=prod`` before running this command so that
160-
the ``post-install-cmd`` scripts run in the ``prod`` environment.
159+
  run ``export SYMFONY_ENV=prod`` (or ``export APP_ENV=prod`` if you're
160+
  using :doc:`Symfony Flex </setup/flex>`) before running this command so
161+
that the ``post-install-cmd`` scripts run in the ``prod`` environment.
161162

162163
D) Clear your Symfony Cache
163164
~~~~~~~~~~~~~~~~~~~~~~~~~~~

doctrine/multiple_entity_managers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ entity manager that connects to another database might handle the rest.
1616
usually required. Be sure you actually need multiple entity managers before
1717
adding in this layer of complexity.
1818

19+
.. caution::
20+
21+
Entities cannot define associations across different entity managers. If you
22+
need that, there are `several alternatives <https://stackoverflow.com/a/11494543/2804294>`_
23+
that require some custom setup.
24+
1925
The following configuration code shows how you can configure two entity managers:
2026

2127
.. configuration-block::

form/disabling_validation.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@ these cases you can set the ``validation_groups`` option to ``false``::
1818

1919
Note that when you do that, the form will still run basic integrity checks,
2020
for example whether an uploaded file was too large or whether non-existing
21-
fields were submitted. If you want to suppress validation, you can use the
22-
:ref:`POST_SUBMIT event <form-dynamic-form-modification-suppressing-form-validation>`.
21+
fields were submitted.
22+
23+
The submission of extra form fields can be controlled with the
24+
`allow_extra_fields config option`_ and the maximum upload file size should be
25+
handled via your PHP and web server configuration.
26+
27+
.. _`allow_extra_fields config option`: https://symfony.com/doc/current/reference/forms/types/form.html#allow-extra-fields

form/dynamic_form_modification.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,3 @@ field according to the current selection in the ``sport`` field:
613613
The major benefit of submitting the whole form to just extract the updated
614614
``position`` field is that no additional server-side code is needed; all the
615615
code from above to generate the submitted form can be reused.
616-
617-
.. _form-dynamic-form-modification-suppressing-form-validation:
618-
619-
Suppressing Form Validation
620-
---------------------------
621-
622-
To suppress form validation, set ``validation_groups`` to ``false`` or an empty
623-
array.

logging/monolog_console.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ is passed when a command gets executed.
1111

1212
When a lot of logging has to happen, it's cumbersome to print information
1313
depending on the verbosity settings (``-v``, ``-vv``, ``-vvv``) because the
14-
calls need to be wrapped in conditions. The code quickly gets verbose or dirty.
15-
For example::
14+
calls need to be wrapped in conditions. For example::
1615

1716
use Symfony\Component\Console\Input\InputInterface;
1817
use Symfony\Component\Console\Output\OutputInterface;
1918

2019
protected function execute(InputInterface $input, OutputInterface $output)
2120
{
22-
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
21+
if ($output->isDebug()) {
2322
$output->writeln('Some info');
2423
}
2524

26-
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
25+
if ($output->isVerbose()) {
2726
$output->writeln('Some more info');
2827
}
2928
}

reference/configuration/security.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ persisting the encoded password alone is enough.
595595
All the encoded passwords are ``60`` characters long, so make sure to
596596
allocate enough space for them to be persisted.
597597

598+
.. tip::
599+
600+
A simple technique to make tests much faster when using BCrypt is to set
601+
the cost to ``4``, which is the minimum value allowed, in the ``test``
602+
environment configuration.
603+
598604
.. _reference-security-firewall-context:
599605

600606
Firewall Context

service_container/3.3-di-changes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,13 @@ Start by updating the service ids to class names:
618618

619619
Services associated with global PHP classes (i.e. not using PHP namespaces)
620620
must maintain the ``class`` parameter. For example, when using the old Twig
621+
<<<<<<< HEAD
622+
classes (e.g. ``Twig_Extensions_Extension_Intl`` instead of ``Twig\Extensions\IntlExtension``)
623+
you can't redefine the service as `Twig_Extensions_Extension_Intl: ~` and
624+
=======
621625
classes (e.g. ``Twig_Extensions_Extension_Intl`` instead of ``Twig\Extensions\IntlExtension``),
622626
  you can't redefine the service as ``Twig_Extensions_Extension_Intl: ~`` and
627+
>>>>>>> upstream/3.3
623628
you must keep the original ``class`` parameter.
624629

625630
But, this change will break our app! The old service ids (e.g. ``app.github_notifier``)

service_container/compiler_passes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ How to Work with Compiler Passes
88
Compiler passes give you an opportunity to manipulate other service
99
definitions that have been registered with the service container. You
1010
can read about how to create them in the components section
11-
":ref:`components-di-compiler-pass`".
11+
":ref:`components-di-separate-compiler-passes`".
1212

1313
Compiler passes are registered in the ``build()`` method of the application kernel::
1414

service_container/factories.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ Configuration of the service container then looks like this:
146146
.. code-block:: yaml
147147
148148
# config/services.yaml
149-
app.newsletter_manager:
150-
class: App\Email\NewsletterManager
149+
AppBundle\Email\NewsletterManager:
151150
# new syntax
152151
factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager'
153152
# old syntax

setup/built_in_web_server.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ First, execute this command:
2727
.. code-block:: terminal
2828
2929
$ cd your-project/
30-
$ composer require symfony/web-server-bundle
30+
$ composer require --dev symfony/web-server-bundle
3131
3232
Then, enable the bundle in the kernel of the application::
3333

0 commit comments

Comments
 (0)