Skip to content

Commit 4f3ce84

Browse files
committed
minor #5451 [#5388] change echo and print in examples (snoek09)
This PR was merged into the 2.3 branch. Discussion ---------- [#5388] change echo and print in examples This is a split of #5388 for the 2.3 branch. Original description: > | Q | A > | ------------- | --- > | Doc fix? | yes > | New docs? | no > | Applies to | all > | Fixed tickets | #5177 > > Original PR and discussion in #5285 > > Change echo/print in examples to use: > > - `var_dump()` in components docs > - `dump()` in framework docs Commits ------- 37db975 5177 use var_dump() in components 9fa1c11 5177 use var_dump() in components c2acbee 5177 add die() after dump() 78c9b7c 5177 use dump() instead of print in examples 10898c9 5177 use dump() instead of echo in examples
2 parents 78054b2 + 37db975 commit 4f3ce84

File tree

16 files changed

+58
-53
lines changed

16 files changed

+58
-53
lines changed

book/doctrine.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ 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));
1208+
die();
12081209

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

book/translation.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ 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');
16+
die();
1617

1718
// text can be translated into the end-user's language or
1819
// default to English
19-
echo $translator->trans('Hello World');
20+
dump($translator->trans('Hello World'));
21+
die();
2022

2123
.. note::
2224

components/class_loader/class_map_generator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ method::
5050

5151
use Symfony\Component\ClassLoader\ClassMapGenerator;
5252

53-
print_r(ClassMapGenerator::createMap(__DIR__.'/library'));
53+
var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));
5454

5555
Given the files and class from the table above, you should see an output like
5656
this:

components/css_selector.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ equivalents::
5151

5252
use Symfony\Component\CssSelector\CssSelector;
5353

54-
print CssSelector::toXPath('div.item > h4 > a');
54+
var_dump(CssSelector::toXPath('div.item > h4 > a'));
5555

5656
This gives the following output:
5757

components/dom_crawler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ traverse easily::
4747
$crawler = new Crawler($html);
4848

4949
foreach ($crawler as $domElement) {
50-
print $domElement->nodeName;
50+
var_dump($domElement->nodeName);
5151
}
5252

5353
Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and

components/event_dispatcher/generic_event.rst

Lines changed: 3 additions & 2 deletions
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+
var_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+
var_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

Lines changed: 1 addition & 1 deletion
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/finder.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ directories::
3030
$finder->files()->in(__DIR__);
3131

3232
foreach ($finder as $file) {
33-
// Print the absolute path
34-
print $file->getRealpath()."\n";
33+
// Dump the absolute path
34+
var_dump($file->getRealpath());
3535

36-
// Print the relative path to the file, omitting the filename
37-
print $file->getRelativePath()."\n";
36+
// Dump the relative path to the file, omitting the filename
37+
var_dump($file->getRelativePath());
3838

39-
// Print the relative path to the file
40-
print $file->getRelativePathname()."\n";
39+
// Dump the relative path to the file
40+
var_dump($file->getRelativePathname());
4141
}
4242

4343
The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo`
@@ -121,9 +121,7 @@ And it also works with user-defined streams::
121121
$finder = new Finder();
122122
$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
123123
foreach ($finder->in('s3://bucket-name') as $file) {
124-
// ... do something
125-
126-
print $file->getFilename()."\n";
124+
// ... do something with the file
127125
}
128126

129127
.. note::

components/form/introduction.rst

Lines changed: 2 additions & 2 deletions
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+
var_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

Lines changed: 2 additions & 2 deletions
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+
var_dump('Hello World');
419419
flush();
420420
sleep(2);
421-
echo 'Hello World';
421+
var_dump('Hello World');
422422
flush();
423423
});
424424
$response->send();

0 commit comments

Comments
 (0)