Skip to content

Commit 10898c9

Browse files
Henry Snoekwouterj
Henry Snoek
authored andcommitted
5177 use dump() instead of echo in examples
Conflicts: book/doctrine.rst components/expression_language/caching.rst components/expression_language/extending.rst components/expression_language/introduction.rst components/expression_language/syntax.rst components/serializer.rst components/translation/usage.rst
1 parent 78054b2 commit 10898c9

File tree

12 files changed

+44
-41
lines changed

12 files changed

+44
-41
lines changed

book/doctrine.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ to the given ``Category`` object via their ``category_id`` value.
12041204
$category = $product->getCategory();
12051205

12061206
// prints "Proxies\AppBundleEntityCategoryProxy"
1207-
echo get_class($category);
1207+
dump(get_class($category));
12081208

12091209
This proxy object extends the true ``Category`` object, and looks and
12101210
acts exactly like it. The difference is that, by using a proxy object,

book/translation.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ wrapping each with a function capable of translating the text (or "message")
1212
into the language of the user::
1313

1414
// text will *always* print out in English
15-
echo 'Hello World';
15+
dump('Hello World');
1616

1717
// text can be translated into the end-user's language or
1818
// default to English
19-
echo $translator->trans('Hello World');
19+
dump($translator->trans('Hello World'));
2020

2121
.. note::
2222

components/event_dispatcher/generic_event.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ the event arguments::
7575
);
7676
$dispatcher->dispatch('foo', $event);
7777

78-
echo $event['counter'];
78+
dump($event['counter']);
7979

8080
class FooListener
8181
{
@@ -96,7 +96,7 @@ Filtering data::
9696
$event = new GenericEvent($subject, array('data' => 'Foo'));
9797
$dispatcher->dispatch('foo', $event);
9898

99-
echo $event['data'];
99+
dump($event['data']);
100100

101101
class FooListener
102102
{
@@ -105,3 +105,4 @@ Filtering data::
105105
$event['data'] = strtolower($event['data']);
106106
}
107107
}
108+

components/event_dispatcher/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ part of the listener's processing logic::
635635
{
636636
public function myEventListener(Event $event)
637637
{
638-
echo $event->getName();
638+
// ... do something with the event name
639639
}
640640
}
641641

components/form/introduction.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ is created from the form factory.
396396
->add('dueDate', 'date')
397397
->getForm();
398398
399-
echo $twig->render('new.html.twig', array(
399+
dump($twig->render('new.html.twig', array(
400400
'form' => $form->createView(),
401-
));
401+
)));
402402
403403
.. code-block:: php-symfony
404404

components/http_foundation/introduction.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ represented by a PHP callable instead of a string::
415415

416416
$response = new StreamedResponse();
417417
$response->setCallback(function () {
418-
echo 'Hello World';
418+
dump('Hello World');
419419
flush();
420420
sleep(2);
421-
echo 'Hello World';
421+
dump('Hello World');
422422
flush();
423423
});
424424
$response->send();

components/intl.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ This class currently only works with the `intl extension`_ installed::
217217
$reader = new BinaryBundleReader();
218218
$data = $reader->read('/path/to/bundle', 'en');
219219

220-
echo $data['Data']['entry1'];
220+
dump($data['Data']['entry1']);
221221

222222
PhpBundleReader
223223
~~~~~~~~~~~~~~~
@@ -231,7 +231,7 @@ object::
231231
$reader = new PhpBundleReader();
232232
$data = $reader->read('/path/to/bundle', 'en');
233233

234-
echo $data['Data']['entry1'];
234+
dump($data['Data']['entry1']);
235235

236236
BufferedBundleReader
237237
~~~~~~~~~~~~~~~~~~~~
@@ -272,10 +272,10 @@ returned::
272272
$data = $reader->read('/path/to/bundle', 'en');
273273

274274
// Produces an error if the key "Data" does not exist
275-
echo $data['Data']['entry1'];
275+
dump($data['Data']['entry1']);
276276

277277
// Returns null if the key "Data" does not exist
278-
echo $reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1'));
278+
dump($reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1')));
279279

280280
Additionally, the
281281
:method:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface::readEntry`
@@ -286,12 +286,12 @@ multi-valued entries (arrays), the values of the more specific and the fallback
286286
locale will be merged. In order to suppress this behavior, the last parameter
287287
``$fallback`` can be set to ``false``::
288288

289-
echo $reader->readEntry(
289+
dump($reader->readEntry(
290290
'/path/to/bundle',
291291
'en',
292292
array('Data', 'entry1'),
293293
false
294-
);
294+
));
295295

296296
Accessing ICU Data
297297
------------------

components/property_access/introduction.rst

+18-18
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ method. This is done using the index notation that is used in PHP::
5151
'first_name' => 'Wouter',
5252
);
5353

54-
echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
55-
echo $accessor->getValue($person, '[age]'); // null
54+
dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
55+
dump($accessor->getValue($person, '[age]')); // null
5656

5757
As you can see, the method will return ``null`` if the index does not exists.
5858

@@ -68,8 +68,8 @@ You can also use multi dimensional arrays::
6868
)
6969
);
7070

71-
echo $accessor->getValue($persons, '[0][first_name]'); // 'Wouter'
72-
echo $accessor->getValue($persons, '[1][first_name]'); // 'Ryan'
71+
dump($accessor->getValue($persons, '[0][first_name]')); // 'Wouter'
72+
dump($accessor->getValue($persons, '[1][first_name]')); // 'Ryan'
7373

7474
Reading from Objects
7575
--------------------
@@ -86,13 +86,13 @@ To read from properties, use the "dot" notation::
8686
$person = new Person();
8787
$person->firstName = 'Wouter';
8888

89-
echo $accessor->getValue($person, 'firstName'); // 'Wouter'
89+
dump($accessor->getValue($person, 'firstName')); // 'Wouter'
9090

9191
$child = new Person();
9292
$child->firstName = 'Bar';
9393
$person->children = array($child);
9494

95-
echo $accessor->getValue($person, 'children[0].firstName'); // 'Bar'
95+
dump($accessor->getValue($person, 'children[0].firstName')); // 'Bar'
9696

9797
.. caution::
9898

@@ -122,7 +122,7 @@ property name (``first_name`` becomes ``FirstName``) and prefixes it with
122122

123123
$person = new Person();
124124

125-
echo $accessor->getValue($person, 'first_name'); // 'Wouter'
125+
dump($accessor->getValue($person, 'first_name')); // 'Wouter'
126126

127127
Using Hassers/Issers
128128
~~~~~~~~~~~~~~~~~~~~
@@ -151,10 +151,10 @@ getters, this means that you can do something like this::
151151
$person = new Person();
152152

153153
if ($accessor->getValue($person, 'author')) {
154-
echo 'He is an author';
154+
dump('He is an author');
155155
}
156156
if ($accessor->getValue($person, 'children')) {
157-
echo 'He has children';
157+
dump('He has children');
158158
}
159159

160160
This will produce: ``He is an author``
@@ -179,7 +179,7 @@ The ``getValue`` method can also use the magic ``__get`` method::
179179

180180
$person = new Person();
181181

182-
echo $accessor->getValue($person, 'Wouter'); // array(...)
182+
dump($accessor->getValue($person, 'Wouter')); // array(...)
183183

184184
Magic ``__call()`` Method
185185
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -215,7 +215,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert
215215
->enableMagicCall()
216216
->getPropertyAccessor();
217217

218-
echo $accessor->getValue($person, 'wouter'); // array(...)
218+
dump($accessor->getValue($person, 'wouter')); // array(...)
219219

220220
.. versionadded:: 2.3
221221
The use of magic ``__call()`` method was introduced in Symfony 2.3.
@@ -239,9 +239,9 @@ method::
239239

240240
$accessor->setValue($person, '[first_name]', 'Wouter');
241241

242-
echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
242+
dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
243243
// or
244-
// echo $person['first_name']; // 'Wouter'
244+
// dump($person['first_name']); // 'Wouter'
245245

246246
Writing to Objects
247247
------------------
@@ -275,9 +275,9 @@ can use setters, the magic ``__set`` method or properties to set values::
275275
$accessor->setValue($person, 'lastName', 'de Jong');
276276
$accessor->setValue($person, 'children', array(new Person()));
277277

278-
echo $person->firstName; // 'Wouter'
279-
echo $person->getLastName(); // 'de Jong'
280-
echo $person->children; // array(Person());
278+
dump($person->firstName); // 'Wouter'
279+
dump($person->getLastName()); // 'de Jong'
280+
dump($person->children); // array(Person());
281281

282282
You can also use ``__call`` to set values but you need to enable the feature,
283283
see `Enable other Features`_.
@@ -313,7 +313,7 @@ see `Enable other Features`_.
313313
314314
$accessor->setValue($person, 'wouter', array(...));
315315
316-
echo $person->getWouter(); // array(...)
316+
dump($person->getWouter()); // array(...)
317317
318318
Mixing Objects and Arrays
319319
-------------------------
@@ -345,7 +345,7 @@ You can also mix objects and arrays::
345345
$accessor->setValue($person, 'children[0].firstName', 'Wouter');
346346
// equal to $person->getChildren()[0]->firstName = 'Wouter'
347347

348-
echo 'Hello '.$accessor->getValue($person, 'children[0].firstName'); // 'Wouter'
348+
dump('Hello '.$accessor->getValue($person, 'children[0].firstName')); // 'Wouter'
349349
// equal to $person->getChildren()[0]->firstName
350350

351351
Enable other Features

components/security/authorization.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ first constructor argument::
186186

187187
$role = new Role('ROLE_ADMIN');
188188

189-
// will echo 'ROLE_ADMIN'
190-
echo $role->getRole();
189+
// will show 'ROLE_ADMIN'
190+
dump($role->getRole());
191191

192192
.. note::
193193

@@ -247,3 +247,4 @@ decision manager::
247247
if (!$securityContext->isGranted('ROLE_ADMIN')) {
248248
throw new AccessDeniedException();
249249
}
250+

components/translation/custom_formats.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Once created, it can be used as any other loader::
6363

6464
$translator->addResource('my_format', __DIR__.'/translations/messages.txt', 'fr_FR');
6565

66-
echo $translator->trans('welcome');
66+
dump($translator->trans('welcome'));
6767

6868
It will print *"accueil"*.
6969

@@ -116,3 +116,4 @@ YAML file are dumped into a text file with the custom format::
116116

117117
$dumper = new MyFormatDumper();
118118
$dumper->dump($catalogue, array('path' => __DIR__.'/dumps'));
119+

components/translation/usage.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Imagine you want to translate the string *"Symfony is great"* into French::
1515
'Symfony is great!' => 'J\'aime Symfony!',
1616
), 'fr_FR');
1717

18-
echo $translator->trans('Symfony is great!');
18+
dump($translator->trans('Symfony is great!'));
1919

2020
In this example, the message *"Symfony is great!"* will be translated into
2121
the locale set in the constructor (``fr_FR``) if the message exists in one of
@@ -31,7 +31,7 @@ Sometimes, a message containing a variable needs to be translated::
3131
// ...
3232
$translated = $translator->trans('Hello '.$name);
3333

34-
echo $translated;
34+
dump($translated);
3535

3636
However, creating a translation for this string is impossible since the translator
3737
will try to look up the exact message, including the variable portions
@@ -45,7 +45,7 @@ variable with a "placeholder"::
4545
array('%name%' => $name)
4646
);
4747

48-
echo $translated;
48+
dump($translated);
4949

5050
Symfony will now look for a translation of the raw message (``Hello %name%``)
5151
and *then* replace the placeholders with their values. Creating a translation

cookbook/bundles/remove.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ can remove the ``Acme`` directory as well.
7979
:method:`Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface::getPath` method
8080
to get the path of the bundle::
8181

82-
echo $this->container->get('kernel')->getBundle('AcmeDemoBundle')->getPath();
82+
dump($this->container->get('kernel')->getBundle('AcmeDemoBundle')->getPath());
8383

8484
3.1 Remove Bundle Assets
8585
~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)