Skip to content

5177 change echo and print in examples #5388

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 9 commits into from
3 changes: 2 additions & 1 deletion book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,8 @@ to the given ``Category`` object via their ``category_id`` value.
$category = $product->getCategory();

// prints "Proxies\AppBundleEntityCategoryProxy"
echo get_class($category);
dump(get_class($category));
die();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason why we want to have die()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the original PR #5285 (comment)

'In the framework, dump() needs to be used with a die(), else it won't show up (it'll show up in the WDT).'


This proxy object extends the true ``Category`` object, and looks and
acts exactly like it. The difference is that, by using a proxy object,
Expand Down
6 changes: 4 additions & 2 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ wrapping each with a function capable of translating the text (or "message")
into the language of the user::

// text will *always* print out in English
echo 'Hello World';
dump('Hello World');
die();

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

.. note::

Expand Down
2 changes: 1 addition & 1 deletion components/class_loader/class_map_generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ method::

use Symfony\Component\ClassLoader\ClassMapGenerator;

print_r(ClassMapGenerator::createMap(__DIR__.'/library'));
var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));

Given the files and class from the table above, you should see an output like
this:
Expand Down
2 changes: 1 addition & 1 deletion components/css_selector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ equivalents::

use Symfony\Component\CssSelector\CssSelector;

print CssSelector::toXPath('div.item > h4 > a');
var_dump(CssSelector::toXPath('div.item > h4 > a'));

This gives the following output:

Expand Down
2 changes: 1 addition & 1 deletion components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ traverse easily::
$crawler = new Crawler($html);

foreach ($crawler as $domElement) {
print $domElement->nodeName;
var_dump($domElement->nodeName);
}

Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and
Expand Down
5 changes: 3 additions & 2 deletions components/event_dispatcher/generic_event.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ the event arguments::
);
$dispatcher->dispatch('foo', $event);

echo $event['counter'];
var_dump($event['counter']);

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

echo $event['data'];
var_dump($event['data']);

class FooListener
{
Expand All @@ -105,3 +105,4 @@ Filtering data::
$event['data'] = strtolower($event['data']);
}
}

2 changes: 1 addition & 1 deletion components/event_dispatcher/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ dispatched, are passed as arguments to the listener::
{
public function myEventListener(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
echo $eventName;
// ... do something with the event name
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/expression_language/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and
// the parse() method returns a ParsedExpression
$expression = $language->parse('1 + 4', array());

echo $language->evaluate($expression); // prints 5
var_dump($language->evaluate($expression)); // prints 5

.. code-block:: php

Expand All @@ -68,7 +68,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and
serialize($language->parse('1 + 4', array()))
);

echo $language->evaluate($expression); // prints 5
var_dump($language->evaluate($expression)); // prints 5

.. _DoctrineBridge: https://github.com/symfony/DoctrineBridge
.. _`doctrine cache library`: http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/caching.html
3 changes: 2 additions & 1 deletion components/expression_language/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This method has 3 arguments:
return strtolower($str);
});
echo $language->evaluate('lowercase("HELLO")');
var_dump($language->evaluate('lowercase("HELLO")'));
This will print ``hello``. Both the **compiler** and **evaluator** are passed
an ``arguments`` variable as their first argument, which is equal to the
Expand Down Expand Up @@ -126,3 +126,4 @@ or by using the second argument of the constructor::
parent::__construct($parser, $providers);
}
}

8 changes: 4 additions & 4 deletions components/expression_language/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ The main class of the component is

$language = new ExpressionLanguage();

echo $language->evaluate('1 + 2'); // displays 3
var_dump($language->evaluate('1 + 2')); // displays 3

echo $language->compile('1 + 2'); // displays (1 + 2)
var_dump($language->compile('1 + 2')); // displays (1 + 2)

Expression Syntax
-----------------
Expand All @@ -96,12 +96,12 @@ PHP type (including objects)::
$apple = new Apple();
$apple->variety = 'Honeycrisp';

echo $language->evaluate(
var_dump($language->evaluate(
'fruit.variety',
array(
'fruit' => $apple,
)
);
));

This will print "Honeycrisp". For more information, see the :doc:`/components/expression_language/syntax`
entry, especially :ref:`component-expression-objects` and :ref:`component-expression-arrays`.
Expand Down
24 changes: 12 additions & 12 deletions components/expression_language/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ to JavaScript::
$apple = new Apple();
$apple->variety = 'Honeycrisp';

echo $language->evaluate(
var_dump($language->evaluate(
'fruit.variety',
array(
'fruit' => $apple,
)
);
));

This will print out ``Honeycrisp``.

Expand All @@ -72,12 +72,12 @@ JavaScript::

$robot = new Robot();

echo $language->evaluate(
var_dump($language->evaluate(
'robot.sayHi(3)',
array(
'robot' => $robot,
)
);
));

This will print out ``Hi Hi Hi!``.

Expand All @@ -93,9 +93,9 @@ constant::

define('DB_USER', 'root');

echo $language->evaluate(
var_dump($language->evaluate(
'constant("DB_USER")'
);
));

This will print out ``root``.

Expand All @@ -114,12 +114,12 @@ array keys, similar to JavaScript::

$data = array('life' => 10, 'universe' => 10, 'everything' => 22);

echo $language->evaluate(
var_dump($language->evaluate(
'data["life"] + data["universe"] + data["everything"]',
array(
'data' => $data,
)
);
));

This will print out ``42``.

Expand All @@ -140,14 +140,14 @@ Arithmetic Operators

For example::

echo $language->evaluate(
var_dump($language->evaluate(
'life + universe + everything',
array(
'life' => 10,
'universe' => 10,
'everything' => 22,
)
);
));

This will print out ``42``.

Expand Down Expand Up @@ -230,13 +230,13 @@ String Operators

For example::

echo $language->evaluate(
var_dump($language->evaluate(
'firstName~" "~lastName',
array(
'firstName' => 'Arthur',
'lastName' => 'Dent',
)
);
));

This would print out ``Arthur Dent``.

Expand Down
16 changes: 7 additions & 9 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ directories::
$finder->files()->in(__DIR__);

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

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

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

The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo`
Expand Down Expand Up @@ -116,9 +116,7 @@ And it also works with user-defined streams::
$finder = new Finder();
$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
foreach ($finder->in('s3://bucket-name') as $file) {
// ... do something

print $file->getFilename()."\n";
// ... do something with the file
}

.. note::
Expand Down
4 changes: 2 additions & 2 deletions components/form/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ is created from the form factory.
->add('dueDate', 'date')
->getForm();

echo $twig->render('new.html.twig', array(
var_dump($twig->render('new.html.twig', array(
'form' => $form->createView(),
));
)));

.. code-block:: php-symfony

Expand Down
4 changes: 2 additions & 2 deletions components/http_foundation/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@ represented by a PHP callable instead of a string::

$response = new StreamedResponse();
$response->setCallback(function () {
echo 'Hello World';
var_dump('Hello World');
flush();
sleep(2);
echo 'Hello World';
var_dump('Hello World');
flush();
});
$response->send();
Expand Down
12 changes: 6 additions & 6 deletions components/intl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ This class currently only works with the `intl extension`_ installed::
$reader = new BinaryBundleReader();
$data = $reader->read('/path/to/bundle', 'en');

echo $data['Data']['entry1'];
var_dump($data['Data']['entry1']);

PhpBundleReader
~~~~~~~~~~~~~~~
Expand All @@ -152,7 +152,7 @@ object::
$reader = new PhpBundleReader();
$data = $reader->read('/path/to/bundle', 'en');

echo $data['Data']['entry1'];
var_dump($data['Data']['entry1']);

BufferedBundleReader
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -193,10 +193,10 @@ returned::
$data = $reader->read('/path/to/bundle', 'en');

// Produces an error if the key "Data" does not exist
echo $data['Data']['entry1'];
var_dump($data['Data']['entry1']);

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

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

echo $reader->readEntry(
var_dump($reader->readEntry(
'/path/to/bundle',
'en',
array('Data', 'entry1'),
false
);
));

Accessing ICU Data
------------------
Expand Down
Loading