8000 Merge branch '3.0' into 3.1 · symfony/symfony-docs@df818a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit df818a7

Browse files
committed
Merge branch '3.0' into 3.1
* 3.0: Simplified the contribution article for Symfony Docs Update routing.rst [#6590] fix version in versionadded directive Added note on YAML mappings as objects use static Yaml API Adding a description for the use_microseconds parameter introduced in MonologBundle v2.11 Clarify signed requests in the ESI renderer refs #5898 Fix updates of testing.rst for 3.0
2 parents 5853272 + dc03f45 commit df818a7

File tree

9 files changed

+230
-214
lines changed

9 files changed

+230
-214
lines changed

book/http_cache.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,12 @@ One great advantage of the ESI renderer is that you can make your application
11981198
as dynamic as needed and at the same time, hit the application as little as
11991199
possible.
12001200

1201+
.. caution::
1202+
1203+
The fragment listener only responds to signed requests. Requests are only
1204+
signed when using the fragment renderer and the ``render_esi`` Twig
1205+
function.
1206+
12011207
.. note::
12021208

12031209
Once you start using ESI, remember to always use the ``s-maxage``

book/testing.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ called ``Calculator`` in the ``Util/`` directory of the app bundle::
6363
}
6464

6565
To test this, create a ``CalculatorTest`` file in the ``tests/AppBundle/Util`` directory
66-
of your bundle::
66+
of your application::
6767

6868
// tests/AppBundle/Util/CalculatorTest.php
6969
namespace Tests\AppBundle\Util;
@@ -84,13 +84,13 @@ of your bundle::
8484

8585
.. note::
8686

87-
By convention, the ``Tests/AppBundle`` directory should replicate the directory
87+
By convention, the ``tests/AppBundle`` directory should replicate the directory
8888
of your bundle for unit tests. So, if you're testing a class in the
89-
``AppBundle/Util/`` directory, put the test in the ``tests/AppBundle/Util/``
89+
``src/AppBundle/Util/`` directory, put the test in the ``tests/AppBundle/Util/``
9090
directory.
9191

9292
Just like in your real application - autoloading is automatically enabled
93-
via the ``autoload.php`` file (as configured by default in the
93+
via the ``app/autoload.php`` file (as configured by default in the
9494
``phpunit.xml.dist`` file).
9595

9696
Running tests for a given file or directory is also very easy:
@@ -835,7 +835,7 @@ PHPUnit Configuration
835835

836836
Each application has its own PHPUnit configuration, stored in the
837837
``phpunit.xml.dist`` file. You can edit this file to change the defaults or
838-
create an ``phpunit.xml`` file to set up a configuration for your local machine
838+
create a ``phpunit.xml`` file to set up a configuration for your local machine
839839
only.
840840

841841
.. tip::
@@ -870,7 +870,7 @@ configuration adds tests from a custom ``lib/tests`` directory:
870870
<testsuites>
871871
<testsuite name="Project Test Suite">
872872
<!-- ... --->
873-
<directory>../lib/tests</directory>
873+
<directory>lib/tests</directory>
874874
</testsuite>
875875
</testsuites>
876876
<!-- ... --->
@@ -887,10 +887,10 @@ section:
887887
<filter>
888888
<whitelist>
889889
<!-- ... -->
890-
<director 67E6 y>../lib</directory>
890+
<directory>lib</directory>
891891
<exclude>
892892
<!-- ... -->
893-
<directory>../lib/tests</directory>
893+
<directory>lib/tests</directory>
894894
</exclude>
895895
</whitelist>
896896
</filter>

components/yaml/introduction.rst

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,20 @@ acts as a thin wrapper that simplifies common uses.
9595
Reading YAML Files
9696
~~~~~~~~~~~~~~~~~~
9797

98-
The :method:`Symfony\\Component\\Yaml\\Parser::parse` method parses a YAML
98+
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` method parses a YAML
9999
string and converts it to a PHP array:
100100

101101
.. code-block:: php
102102
103-
use Symfony\Component\Yaml\Parser;
103+
use Symfony\Component\Yaml\Yaml;
104+
105+
$value = Yaml::parse(file_get_contents('/path/to/file.yml'));
104106
105-
$yaml = new Parser();
107+
.. caution::
106108

107-
$value = $yaml->parse(file_get_contents('/path/to/file.yml'));
109+
Because it is currently possible to pass a filename to this method, you
110+
must validate the input first. Passing a filename is deprecated in
111+
Symfony 2.2, and was removed in Symfony 3.0.
108112

109113
If an error occurs during parsing, the parser throws a
110114
:class:`Symfony\\Component\\Yaml\\Exception\\ParseException` exception
@@ -116,64 +120,49 @@ error occurred:
116120
use Symfony\Component\Yaml\Exception\ParseException;
117121
118122
try {
119-
$value = $yaml->parse(file_get_contents('/path/to/file.yml'));
123+
$value = Yaml::parse(file_get_contents('/path/to/file.yml'));
120124
} catch (ParseException $e) {
121125
printf("Unable to parse the YAML string: %s", $e->getMessage());
122126
}
123127
124-
.. tip::
125-
126-
As the parser is re-entrant, you can use the same parser object to load
127-
different YAML strings.
128-
129-
It may also be convenient to use the
130-
:method:`Symfony\\Component\\Yaml\\Yaml::parse` wrapper method:
128+
.. _components-yaml-dump:
131129

132-
.. code-block:: php
130+
Objects for Mappings
131+
....................
133132

134-
use Symfony\Component\Yaml\Yaml;
133+
.. versionadded:: 2.7
134+
Support for parsing mappings as objects was introduced in Symfony 2.7.
135135

136-
$yaml = Yaml::parse(file_get_contents('/path/to/file.yml'));
136+
Yaml :ref:`mappings <yaml-format-collections>` are basically associative
137+
arrays. You can instruct the parser to return mappings as objects (i.e.
138+
``\stdClass`` instances) by setting the fourth argument to ``true``::
137139

138-
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML string.
139-
Internally, it constructs a :class:`Symfony\\Component\\Yaml\\Parser` object and calls
140-
the :method:`Symfony\\Component\\Yaml\\Parser::parse` method.
141-
142-
.. _components-yaml-dump:
140 10000 +
$object = Yaml::parse('{"foo": "bar"}', false, false, true);
141+
echo get_class($object); // stdClass
142+
echo $object->foo; // bar
143143

144144
Writing YAML Files
145145
~~~~~~~~~~~~~~~~~~
146146

147-
The :method:`Symfony\\Component\\Yaml\\Dumper::dump` method dumps any PHP
147+
The :method:`Symfony\\Component\\Yaml\\Yaml::dump` method dumps any PHP
148148
array to its YAML representation:
149149

150150
.. code-block:: php
151151
152-
use Symfony\Component\Yaml\Dumper;
152+
use Symfony\Component\Yaml\Yaml;
153153
154154
$array = array(
155155
'foo' => 'bar',
156156
'bar' => array('foo' => 'bar', 'bar' => 'baz'),
157157
);
158158
159-
$dumper = new Dumper();
160-
161-
$yaml = $dumper->dump($array);
159+
$yaml = Yaml::dump($array);
162160
163161
file_put_contents('/path/to/file.yml', $yaml);
164162
165163
If an error occurs during the dump, the parser throws a
166164
:class:`Symfony\\Component\\Yaml\\Exception\\DumpException` exception.
167165

168-
If you only need to dump one array, you can use the
169-
:method:`Symfony\\Component\\Yaml\\Yaml::dump` static method shortcut:
170-
171-
.. code-block:: php
172-
173-
use Symfony\Component\Yaml\Yaml;
174-
175-
$yaml = Yaml::dump($array);
176-
177166
Array Expansion and Inlining
178167
............................
179168

@@ -185,7 +174,7 @@ representation:
185174
186175
{ foo: bar, bar: { foo: bar, bar: baz } }
187176
188-
The second argument of the :method:`Symfony\\Component\\Yaml\\Dumper::dump`
177+
The second argument of the :method:`Symfony\\Component\\Yaml\\Yaml::dump`
189178
method customizes the level at which the output switches from the expanded
190179
representation to the inline one:
191180

components/yaml/yaml_format.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ YAML uses the ISO-8601 standard to express dates:
165165
# simple date
166166
2002-12-14
167167
168+
.. _yaml-format-collections:
169+
168170
Collections
169171
-----------
170172

0 commit comments

Comments
 (0)
0