8000 Update translation.rst by solazs · Pull Request #4989 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Update translation.rst #4989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 82 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
265604b
[#4243] Tweaks to the new var-dumper component
weaverryan Nov 5, 2014
09a6fd7
[Form] Add entity manager instance support for em option
GeLoLabs Oct 18, 2014
1a29f24
typos in the var-dumper component
nicolas-grekas Nov 8, 2014
9caea6f
feature #4336 [Form] Add entity manager instance support for em optio…
weaverryan Nov 13, 2014
3329bd2
feature #4424 [#4243] Tweaks to the new var-dumper component (weaverr…
weaverryan Nov 13, 2014
0d5cb0d
Merge branch '2.7'
weaverryan Nov 13, 2014
0c92fab
Merge branch '2.7'
weaverryan Nov 13, 2014
51224e9
Merge branch '2.7'
wouterj Nov 19, 2014
d6ce29f
Merge branch '2.7'
weaverryan Nov 24, 2014
f24b645
Merge branch '2.7'
weaverryan Nov 24, 2014
d969e8b
Merge branch '2.7'
weaverryan Nov 25, 2014
0fb81cc
Merge branch '2.7'
weaverryan Nov 25, 2014
6b73990
Merge branch '2.7'
wouterj Dec 1, 2014
8099ac1
Merge branch '2.7'
weaverryan Dec 4, 2014
486baf8
Merge branch '2.7'
wouterj Dec 7, 2014
d921dcd
Merge branch '2.7'
wouterj Dec 7, 2014
f0ac8bb
Merge branch '2.7'
weaverrya 8000 n Dec 7, 2014
3454883
Merge branch '2.7'
weaverryan Dec 7, 2014
d30dc9e
Merge remote-tracking branch 'origin/master'
weaverryan Dec 8, 2014
2d1c336
Merge branch '2.7'
weaverryan Dec 11, 2014
e539bd1
Merge branch '2.7'
weaverryan Dec 20, 2014
0906e0c
Merge branch '2.7'
weaverryan Dec 21, 2014
4056218
Merge branch '2.7'
weaverryan Dec 23, 2014
07aa543
Merge branch '2.7'
weaverryan Dec 26, 2014
2fcebc1
Merge branch '2.7'
wouterj Dec 28, 2014
8131844
Merge branch '2.7'
weaverryan Dec 29, 2014
cb6f846
Merge branch '2.7'
weaverryan Dec 31, 2014
9e5fc6c
Merge branch '2.7'
weaverryan Dec 31, 2014
56db7af
Merge branch '2.7'
weaverryan Dec 31, 2014
27296ad
Merge branch '2.7'
wouterj Dec 31, 2014
353995e
Merge branch '2.7'
weaverryan Jan 1, 2015
fcfea43
Merge branch '2.7'
wouterj Jan 2, 2015
6ef6a04
Merge branch '2.7'
weaverryan Jan 3, 2015
bcab77b
bump Symfony requirements to PHP 5.5
xabbuh Jan 4, 2015
d33b78b
don't describe removed usage of Yaml::parse()
xabbuh Jan 4, 2015
6f9832d
Merge branch '2.7'
wouterj Jan 4, 2015
42d2b15
Merge branch '2.7'
weaverryan Jan 4, 2015
7d2f0f3
Removed 2.5 versionadded as its deprecated
wouterj Jan 4, 2015
92b10b1
bug #4758 [Components][Yaml] don't describe removed usage of Yaml::pa…
wouterj Jan 8, 2015
032a6b4
Merge branch '2.7'
wouterj Jan 8, 2015
c859790
Fixed markup
wouterj Jan 9, 2015
9919bca
Revert "Fixed markup"
wouterj Jan 9, 2015
ca3b4c8
feature #4753 bump Symfony requirements to PHP 5.5 (xabbuh)
wouterj Jan 16, 2015
a17bdd7
Merge branch '2.7'
wouterj Jan 16, 2015
dc25c65
minor #4769 [2.7] Removed 2.5 versionadded as its deprecated (WouterJ)
weaverryan Jan 16, 2015
050f7ce
Documented true regex
wouterj Jan 18, 2015
7363c9b
Merge branch '2.6' into 2.7
weaverryan Jan 18, 2015
907ee0d
Merge branch '2.7'
weaverryan Jan 18, 2015
728205f
Replaced setDefaultOptions by the new configureOptions method
peterrehm Jan 6, 2015
74d2e30
feature #4786 Replaced setDefaultOptions by the new configureOptions …
weaverryan Jan 21, 2015
885c378
[#4786] Adding a few versionadded's for the changed method name
weaverryan Jan 21, 2015
e4d22f0
added documentation for the new absolute_url() and relative_path() Tw…
fabpot Jan 10, 2015
6e6bae8
Small grammar-ish fix
wouterj Jan 25, 2015
6c498d4
feature #4805 added documentation for the new absolute_url() and rela…
weaverryan Jan 25, 2015
8fe9069
added documentation for the new absolute_url() and relative_path() Tw…
fabpot Jan 10, 2015
a5addaa
[#4805] Adding versionadded
weaverryan Jan 25, 2015
61ea87b
Merge branch '2.6' into 2.7
weaverryan Jan 25, 2015
c33b371
Merge branch '2.7'
weaverryan Jan 25, 2015
7c07a44
Merge branch '2.6' into 2.7
weaverryan Jan 25, 2015
99e2996
Merge branch '2.7'
weaverryan Jan 25, 2015
a57db5b
feature #4879 Documented true regex (WouterJ)
weaverryan Jan 30, 2015
39f6876
Merge branch '2.6' into 2.7
weaverryan Jan 30, 2015
714f630
Merge branch '2.7'
weaverryan Jan 30, 2015
bc29584
Merge branch '2.6' into 2.7
wouterj Jan 30, 2015
87eb36c
Merge branch '2.7'
wouterj Jan 30, 2015
d71fe6d
Merge branch '2.6' into 2.7
wouterj Feb 1, 2015
c0f9f67
Merge branch '2.7'
wouterj Feb 1, 2015
78f4f69
Merge branch '2.6' into 2.7
wouterj Feb 1, 2015
ebe2706
Added January changelog
wouterj Feb 1, 2015
ad97700
Merge branch '2.7'
wouterj Feb 1, 2015
6fd286b
Added January changelog
wouterj Feb 1, 2015
7f8d6bd
Merge branch '2.6' into 2.7
wouterj Feb 1, 2015
8d56ad7
Merge branch '2.7'
wouterj Feb 1, 2015
ef39a01
Remove diff
wouterj Feb 1, 2015
70902f5
Merge branch '2.6' into 2.7
weaverryan Feb 1, 2015
81e8c13
Merge branch '2.7'
weaverryan Feb 1, 2015
b7f7421
Update translation.rst
solazs Feb 11, 2015
94914c5
Review note about setting the translator locale in a controller.
solazs Feb 15, 2015
d5566b1
Finaly touches on translation locale setting note
solazs Feb 20, 2015
fdae4bc
Merge branch 'master' of https://github.com/solazs/symfony-docs into …
solazs Mar 6, 2015
cbc91e3
Remove useless setLocale() call and add code block with locale setter
solazs Mar 6, 2015
30b4dfa
Revert "Merge branch 'master' of https://github.com/solazs/symfony-do…
solazs Mar 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 57 additions & 24 deletions components/var_dumper/advanced.rst
object this way::
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@
Advanced Usage of the VarDumper Component
=========================================

``dump()`` function is just a thin wrapper and a more convenient way to call
The ``dump()`` function is just a thin wrapper and a more convenient way to call
:method:`VarDumper::dump() <Symfony\\Component\\VarDumper\\VarDumper::dump>`.
You can change the behavior of this function by calling
:method:`VarDumper::setHandler($callable) <Symfony\\Component\\VarDumper\\VarDumper::setHandler>`:
calls to ``dump()`` will then be forwarded to ``$callable``.
:method:`VarDumper::setHandler($callable) <Symfony\\Component\\VarDumper\\VarDumper::setHandler>`.
Calls to ``dump()`` will then be forwarded to ``$callable``.

By adding a handler, you can customize the `Cloners`_, `Dumpers`_ and `Casters`_
as explained below. A simple implementation of a handler function might look
like this::

use Symfony\Component\VarDumper\VarDumper;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;

VarDumper::setHandler(function($var) {
$cloner = new VarCloner();
$dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();

$dumper->dump($cloner->cloneVar($var));
});

Cloners
~~~~~~~
-------

A cloner is used to create an intermediate representation of any PHP variable.
Its output is a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`
Expand All @@ -21,18 +37,24 @@ object that wraps this representation.
You can create a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`

use Symfony\Component\VarDumper\Cloner\VarCloner;

$cloner = new VarCloner();
$data = $cloner->cloneVar($myVar);
// this is commonly then passed to the dumper
// see the example at the top of this page
// $dumper->dump($data);

A cloner also applies limits when creating this representation, so that the
A cloner also applies limits when creating the representation, so that the
corresponding Data object could represent only a subset of the cloned variable.
Before :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::cloneVar`,
Before calling :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::cloneVar`,
you can configure these limits:

* :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::setMaxItems`
configures the maximum number of items that will be cloned *past the first
nesting level*. Items are counted using a breadth-first algorithm so that
lower level items have higher priority than deeply nested items;
configures the maximum number of items that will be cloned
*past the first nesting level*. Items are counted using a breadth-first
algorithm so that lower level items have higher priority than deeply nested
items;
* :method:`Symfony\\Component\\VarDumper\\Cloner\\VarCloner::setMaxString`
configures the maximum number of characters that will be cloned before
cutting overlong strings;
Expand All @@ -45,7 +67,7 @@ method:

* the first ``$maxDepth`` argument allows limiting dumps in the depth dimension,
* the second ``$maxItemsPerDepth`` limits the number of items per depth level,
* and the last ``$useRefHandles`` defaults to ``true`` but allows removing
* and the last ``$useRefHandles`` defaults to ``true``, but allows removing
internal objects' handles for sparser output,
* but unlike the previous limits on cloners that remove data on purpose,
these can be changed back and forth before dumping since they do not affect
Expand All @@ -54,11 +76,11 @@ method:
.. note::

When no limit is applied, a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`
object is as accurate as the native :phpfunction:`serialize` function
and thus could have a wider purpose than strictly dumping for debugging.
object is as accurate as the native :phpfunction:`serialize` function,
and thus could be for purposes beyond dumping for debugging.

Dumpers
~~~~ 8000 ~~~
-------

A dumper is responsible for outputting a string representation of a PHP variable,
using a :class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object as input.
Expand All @@ -70,14 +92,17 @@ for optionally colored command line output.

For example, if you want to dump some ``$variable``, just do::

use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;

$cloner = new VarCloner();
$dumper = new CliDumper();

$dumper->dump($cloner->cloneVar($variable));

By using the first argument of the constructor, you can select the output
stream where the dump will be written. By default, the ``CliDumper`` writes
on ``php://stdout`` and the ``HtmlDumper`` on ``php://output``, but any PHP
on ``php://stdout`` and the ``HtmlDumper`` on ``php://output``. But any PHP
stream (resource or URL) is acceptable.

Instead of a stream destination, you can also pass it a ``callable`` that
Expand All @@ -90,6 +115,9 @@ method or the second argument of the

For example, to get a dump as a string in a variable, you can do::

use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;

$cloner = new VarCloner();
$dumper = new CliDumper();
$output = '';
Expand All @@ -107,7 +135,10 @@ For example, to get a dump as a string in a variable, you can do::

// $output is now populated with the dump representation of $variable

An other option for doing the same could be::
Another option for doing the same could be::

use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;

cloner = new VarCloner();
$dumper = new CliDumper();
Expand All @@ -128,9 +159,9 @@ them from re-implementing the logic required to walk through a
:class:`Symfony\\Component\\VarDumper\\Cloner\\Data` object's internal structure.

Casters
~~~~~~~
-------

Objects and resources nested in a PHP variable are casted to arrays in the
Objects and resources nested in a PHP variable are "cast" to arrays in the
intermediate :class:`Symfony\\Component\\VarDumper\\Cloner\\Data`
representation. You can tweak the array representation for each object/resource
by hooking a Caster into this process. The component already includes many
Expand All @@ -140,6 +171,8 @@ If you want to build your own Caster, you can register one before cloning
a PHP variable. Casters are registered using either a Cloner's constructor
or its ``addCasters()`` method::

use Symfony\Component\VarDumper\Cloner\VarCloner;

$myCasters = array(...);
$cloner = new VarCloner($myCasters);

Expand Down Expand Up @@ -172,7 +205,7 @@ being cloned in an array. They are callables that accept four arguments:
* an array modelled for objects after PHP's native ``(array)`` cast operator,
* a :class:`Symfony\\Component\\VarDumper\\Cloner\\Stub` object
representing the main properties of the object (class, type, etc.),
* true/false when the caster is called nested is a structure or not.
* true/false when the caster is called nested in a structure or not.

Here is a simple caster not doing anything::

Expand All @@ -186,18 +219,18 @@ Here is a simple caster not doing anything::
For objects, the ``$array`` parameter comes pre-populated using PHP's native
``(array)`` casting operator or with the return value of ``$object->__debugInfo()``
if the magic method exists. Then, the return value of one Caster is given
as argument to the next Caster in the chain.
as the array argument to the next Caster in the chain.

When casting with the ``(array)`` operator, PHP prefixes protected properties
with a ``\0*\0`` and private ones with the class owning the property:
e.g. ``\0Foobar\0`` prefixes all private properties of objects of type Foobar.
Casters follow this convention and add two more prefixes: ``\0~\0`` is used
for virtual properties and ``\0+\0`` for dynamic ones (runtime added
with a ``\0*\0`` and private ones with the class owning the property. For example,
``\0Foobar\0`` will be the prefix for all private properties of objects of
type Foobar. Casters follow this convention and add two more prefixes: ``\0~\0``
is used for virtual properties and ``\0+\0`` for dynamic ones (runtime added
properties not in the class declaration).

.. note::

Although you can, it is best advised not to alter the state of an object
Although you can, it is advised to not alter the state of an object
while casting it in a Caster.

.. tip::
Expand Down
39 changes: 34 additions & 5 deletions components/var_dumper/introduction.rst
9E88
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@ use instead of e.g. :phpfunction:`var_dump`. By using it, you'll gain:
reference structure of your data;
* Ability to operate in the context of an output buffering handler.

For example::

require __DIR__.'/vendor/autoload.php';
// create a variable, which could be anything!
$someVar = '...';

dump($someVar);

By default, the output format and destination are selected based on your
current PHP SAPI:

* On the command line (CLI SAPI), the output is written on ``STDOUT``. This
can be surprising to some because this bypasses PHP's output buffering
mechanism;
* On other SAPIs, dumps are written as HTML on the regular output.
* On other SAPIs, dumps are written as HTML in the regular output.

.. note::

Expand Down Expand Up @@ -101,8 +109,8 @@ original value. You can configure the limits in terms of:
<config max-items="250" max-string-length="-1" />
</container>

Reading a Dump
--------------
Dump Examples and Output
------------------------

For simple variables, reading the output should be straightforward.
Here are some examples showing first a variable defined in PHP,
Expand All @@ -115,6 +123,7 @@ then its dump representation::
'a boolean' => true,
'an empty array' => array(),
);
dump($var);

.. image:: /images/components/var_dumper/01-simple.png

Expand All @@ -131,6 +140,7 @@ then its dump representation::
$var .= "Non-UTF-8 strings length are counted in octet size.\n";
$var .= "Because of this `\xE9` octet (\\xE9),\n";
$var .= "this string is not UTF-8 valid, thus the `b` prefix.\n";
dump($var);

.. image:: /images/components/var_dumper/02-multi-line-str.png

Expand All @@ -144,6 +154,7 @@ then its dump representation::
}

$var = new PropertyExample();
dump($var);

.. image:: /images/components/var_dumper/03-object.png

Expand All @@ -161,6 +172,7 @@ then its dump representation::

$var = new DynamicPropertyExample();
$var->undeclaredProperty = 'Runtime added dynamic properties have `"` around their name.';
dump($var);

.. image:: /images/components/var_dumper/04-dynamic-property.png

Expand All @@ -172,12 +184,20 @@ then its dump representation::
}
$var = new ReferenceExample();
$var->aCircularReference = $var;
dump($var);

.. image:: /images/components/var_dumper/05-soft-ref.png

.. code-block:: php

$var = new \ErrorException("For some objects, properties have special values\nthat are best represented as constants, like\n`severity` below. Hovering displays the value (`2`).\n", 0, E_WARNING);
$var = new \ErrorException(
"For some objects, properties have special values\n"
."that are best represented as constants, like\n"
."`severity` below. Hovering displays the value (`2`).\n",
0,
E_WARNING
);
dump($var);

.. image:: /images/components/var_dumper/06-constants.png

Expand All @@ -190,6 +210,7 @@ then its dump representation::
$var[2] = array("Hard references (circular or sibling)");
$var[3] =& $var[2];
$var[3][] = "are dumped using `&number` prefixes.";
dump($var);

.. image:: /images/components/var_dumper/07-hard-ref.png

Expand All @@ -199,12 +220,20 @@ then its dump representation::
$var[] = "Some resources and special objects like the current";
$var[] = "one are sometimes best represented using virtual";
$var[] = "properties that describe their internal state.";
dump($var);

.. image:: /images/components/var_dumper/08-virtual-property.png

.. code-block:: php

$var = new AcmeController("When a dump goes over its maximum items limit,\nor when some special objects are encountered,\nchildren can be replaced by an ellipsis and\noptionnally followed by a number that says how\nmany have been removed; `9` in this case.\n");
$var = new AcmeController(
"When a dump goes over its maximum items limit,\n"
."or when some special objects are encountered,\n"
."children can be replaced by an ellipsis and\n"
."optionnally followed by a number that says how\n"
."many have been removed; `9` in this case.\n"
);
dump($var);

.. image:: /images/components/var_dumper/09-cut.png

Expand Down
0