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

Skip to content

Commit 5853272

Browse files
committed
Merge branch '3.0' into 3.1
2 parents bce6255 + a1f8c3a commit 5853272

File tree

4 files changed

+58
-21
lines changed

4 files changed

+58
-21
lines changed

components/phpunit_bridge.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ related to deprecations.
133133
Time-sensitive Tests
134134
--------------------
135135

136-
.. versionadded:: 2.8
137-
Support for clock mocking was introduced in Symfony 2.8.
138-
139136
Use Case
140137
~~~~~~~~
141138

components/yaml/introduction.rst

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,6 @@ array to its YAML representation:
162162
163163
file_put_contents('/path/to/file.yml', $yaml);
164164
165-
.. note::
166-
167-
Of course, the Symfony Yaml dumper is not able to dump resources. Also,
168-
even if the dumper is able to dump PHP objects, it is considered to be a
169-
not supported feature.
170-
171165
If an error occurs during the dump, the parser throws a
172166
:class:`Symfony\\Component\\Yaml\\Exception\\DumpException` exception.
173167

@@ -178,7 +172,10 @@ If you only need to dump one array, you can use the
178172
179173
use Symfony\Component\Yaml\Yaml;
180174
181-
$yaml = Yaml::dump($array, $inline);
175+
$yaml = Yaml::dump($array);
176+
177+
Array Expansion and Inlining
178+
............................
182179

183180
The YAML format supports two kind of representation for arrays, the expanded
184181
one, and the inline one. By default, the dumper uses the inline
@@ -194,7 +191,7 @@ representation to the inline one:
194191

195192
.. code-block:: php
196193
197-
echo $dumper->dump($array, 1);
194+
echo Yaml::dump($array, 1);
198195
199196
.. code-block:: yaml
200197
@@ -203,7 +200,7 @@ representation to the inline one:
203200
204201
.. code-block:: php
205202
206-
echo $dumper->dump($array, 2);
203+
echo Yaml::dump($array, 2);
207204
208205
.. code-block:: yaml
209206
@@ -212,6 +209,58 @@ representation to the inline one:
212209
foo: bar
213210
bar: baz
214211
212+
Indentation
213+
...........
214+
215+
By default the YAML component will use 4 spaces for indentation. This can be
216+
changed using the third argument as follows::
217+
218+
// use 8 spaces for indentation
219+
echo Yaml::dump($array, 2, 8);
220+
221+
.. code-block:: yaml
222+
223+
foo: bar
224+
bar:
225+
foo: bar
226+
bar: baz
227+
228+
Invalid Types and Object Serialization
229+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230+
231+
By default the YAML component will encode any "unsupported" type (i.e.
232+
resources and objects) as ``null``.
233+
234+
Instead of encoding as ``null`` you can choose to throw an exception if an invalid
235+
type is encountered in either the dumper or parser as follows::
236+
237+
// throw an exception if a resource or object is encountered
238+
Yaml::dump($data, 2, 4, true);
239+
240+
// throw an exception if an encoded object is found in the YAML string
241+
Yaml::parse($yaml, true);
242+
243+
However, you can activate object support using the next argument::
244+
245+
$object = new \stdClass();
246+
$object->foo = 'bar';
247+
248+
$dumped = Yaml::dump($object, 2, 4, false, true);
249+
// !!php/object:O:8:"stdClass":1:{s:5:"foo";s:7:"bar";}
250+
251+
$parsed = Yaml::parse($dumped, false, true);
252+
var_dump(is_object($parsed)); // true
253+
echo $parsed->foo; // bar
254+
255+
The YAML component uses PHP's ``serialize()`` method to generate a string
256+
representation of the object.
257+
258+
.. caution::
259+
260+
Object serialization is specific to this implementation, other PHP YAML
261+
parsers will likely not recognize the ``php/object`` tag and non-PHP
262+
implementations certainly won't - use with discretion!
263+
215264
.. _YAML: http://yaml.org/
216265
.. _Packagist: https://packagist.org/packages/symfony/yaml
217266
.. _`YAML 1.2 version specification`: http://yaml.org/spec/1.2/spec.html

reference/forms/types/entity.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,6 @@ return a ``QueryBuilder``.
205205
If you'd like to display an empty list of entries, you can return ``null`` in
206206
the Closure.
207207

208-
.. versionadded:: 2.8
209-
Returning ``null`` in the Closure was introduced in Symfony 2.8.
210-
211208
Overridden Options
212209
------------------
213210

reference/twig_reference.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,6 @@ information in :ref:`book-templating-pages`.
345345
absolute_url
346346
~~~~~~~~~~~~
347347

348-
.. versionadded:: 2.7
349-
The ``absolute_url()`` function was introduced in Symfony 2.7.
350-
351348
.. code-block:: jinja
352349
353350
{{ absolute_url(path) }}
@@ -370,9 +367,6 @@ you're on the following page in your app:
370367
relative_path
371368
~~~~~~~~~~~~~
372369

373-
.. versionadded:: 2.7
374-
The ``relative_path()`` function was introduced in Symfony 2.7.
375-
376370
.. code-block:: jinja
377371
378372
{{ relative_path(path) }}

0 commit comments

Comments
 (0)
0