@@ -109,8 +109,108 @@ original value. You can configure the limits in terms of:
109109 Reading a Dump
110110--------------
111111
112- For simple variables, reading the output should be straightforward::
112+ For simple variables, reading the output should be straightforward.
113+ Here are some examples showing first a variable defined in PHP,
114+ then its dump representation:
113115
114- dump(array(true, 1.1, "string"));
116+ .. code-block :: php
117+
118+ $var = array(
119+ 'a simple string' => "in an array of 5 elements",
120+ 'a float' => 1.0,
121+ 'an integer' => 1,
122+ 'a boolean' => true,
123+ 'an empty array' => array(),
124+ );
125+
126+ .. image :: /images/components/var_dumper/01-simple.png
127+
128+ .. note ::
129+ The gray arrow (â–¼) is a toggle button for hidding/showing
130+ children of nested structures.
131+
132+ .. code-block :: php
133+
134+ $var = "This is a multi-line string.\n";
135+ $var .= "Hovering a string shows its length.\n";
136+ $var .= "The length of UTF-8 strings is counted in terms of UTF-8 characters.\n";
137+ $var .= "Non-UTF-8 strings length are counted in octet size.\n";
138+ $var .= "Because of this `\xE9` octet (\\xE9),\n";
139+ $var .= "this string is not UTF-8 valid, thus the `b` prefix.\n";
140+
141+ .. image :: /images/components/var_dumper/02-multi-line-str.png
142+
143+ .. code-block :: php
144+
145+ class PropertyExample
146+ {
147+ public $publicProperty = 'The `+` prefix denotes public properties,';
148+ protected $protectedProperty = '`#` protected ones and `-` private ones.';
149+ private $privateProperty = 'Hovering a property shows a reminder.';
150+ }
151+
152+ $var = new PropertyExample();
153+
154+ .. image :: /images/components/var_dumper/03-object.png
155+
156+ .. note ::
157+ `#14 ` is the internal object handle. It allows comparing two
158+ consecutive dumps of the same object.
159+
160+ .. code-block :: php
161+
162+ class DynamicPropertyExample
163+ {
164+ public $declaredProperty = 'This property is declared in the class definition';
165+ }
166+
167+ $var = new DynamicPropertyExample();
168+ $var->undeclaredProperty = 'Runtime added dynamic properties have `"` around their name.';
169+
170+ .. image :: /images/components/var_dumper/04-dynamic-property.png
171+
172+ .. code-block :: php
173+
174+ class ReferenceExample
175+ {
176+ public $info = "Circular and sibling references are displayed as `#number`.\nHovering them highlights all instances in the same dump.\n";
177+ }
178+ $var = new ReferenceExample();
179+ $var->aCircularReference = $var;
180+
181+ .. image :: /images/components/var_dumper/05-soft-ref.png
182+
183+ .. code-block :: php
184+
185+ $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);
186+
187+ .. image :: /images/components/var_dumper/06-constants.png
188+
189+ .. code-block :: php
190+
191+ $var = array();
192+ $var[0] = 1;
193+ $var[1] =& $var[0];
194+ $var[1] += 1;
195+ $var[2] = array("Hard references (circular or sibling)");
196+ $var[3] =& $var[2];
197+ $var[3][] = "are dumped using `&number` prefixes.";
198+
199+ .. image :: /images/components/var_dumper/07-hard-ref.png
200+
201+ .. code-block :: php
202+
203+ $var = new \ArrayObject();
204+ $var[] = "Some resources and special objects like the current";
205+ $var[] = "one are sometimes best represented using virtual";
206+ $var[] = "properties that describe their internal state.";
207+
208+ .. image :: /images/components/var_dumper/08-virtual-property.png
209+
210+ .. code-block :: php
211+
212+ $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");
213+
214+ .. image :: /images/components/var_dumper/09-cut.png
115215
116216.. _Packagist : https://packagist.org/packages/symfony/var-dumper
0 commit comments