Skip to content

[#5388] change echo and print in examples #5451

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

Merged
merged 5 commits into from
Jun 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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();

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 @@ -51,7 +51,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 @@ -47,7 +47,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 @@ -635,7 +635,7 @@ part of the listener's processing logic::
{
public function myEventListener(Event $event)
{
echo $event->getName();
// ... do something with the event name
}
}

Expand Down
16 changes: 7 additions & 9 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,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 @@ -121,9 +121,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 @@ -396,9 +396,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 @@ -415,10 +415,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 @@ -217,7 +217,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 @@ -231,7 +231,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 @@ -272,10 +272,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 @@ -286,12 +286,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
36 changes: 18 additions & 18 deletions components/property_access/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ method. This is done using the index notation that is used in PHP::
'first_name' => 'Wouter',
);

echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
echo $accessor->getValue($person, '[age]'); // null
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
var_dump($accessor->getValue($person, '[age]')); // null

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

Expand All @@ -68,8 +68,8 @@ You can also use multi dimensional arrays::
)
);

echo $accessor->getValue($persons, '[0][first_name]'); // 'Wouter'
echo $accessor->getValue($persons, '[1][first_name]'); // 'Ryan'
var_dump($accessor->getValue($persons, '[0][first_name]')); // 'Wouter'
var_dump($accessor->getValue($persons, '[1][first_name]')); // 'Ryan'

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

echo $accessor->getValue($person, 'firstName'); // 'Wouter'
var_dump($accessor->getValue($person, 'firstName')); // 'Wouter'

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

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

.. caution::

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

$person = new Person();

echo $accessor->getValue($person, 'first_name'); // 'Wouter'
var_dump($accessor->getValue($person, 'first_name')); // 'Wouter'

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

if ($accessor->getValue($person, 'author')) {
echo 'He is an author';
var_dump('He is an author');
}
if ($accessor->getValue($person, 'children')) {
echo 'He has children';
var_dump('He has children');
}

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

$person = new Person();

echo $accessor->getValue($person, 'Wouter'); // array(...)
var_dump($accessor->getValue($person, 'Wouter')); // array(...)

Magic ``__call()`` Method
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -215,7 +215,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert
->enableMagicCall()
->getPropertyAccessor();

echo $accessor->getValue($person, 'wouter'); // array(...)
var_dump($accessor->getValue($person, 'wouter')); // array(...)

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

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

echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
// or
// echo $person['first_name']; // 'Wouter'
// var_dump($person['first_name']); // 'Wouter'

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

echo $person->firstName; // 'Wouter'
echo $person->getLastName(); // 'de Jong'
echo $person->children; // array(Person());
var_dump($person->firstName); // 'Wouter'
var_dump($person->getLastName()); // 'de Jong'
var_dump($person->children); // array(Person());

You can also use ``__call`` to set values but you need to enable the feature,
see `Enable other Features`_.
Expand Down Expand Up @@ -313,7 +313,7 @@ see `Enable other Features`_.

$accessor->setValue($person, 'wouter', array(...));

echo $person->getWouter(); // array(...)
var_dump($person->getWouter()); // array(...)

Mixing Objects and Arrays
-------------------------
Expand Down Expand Up @@ -345,7 +345,7 @@ You can also mix objects and arrays::
$accessor->setValue($person, 'children[0].firstName', 'Wouter');
// equal to $person->getChildren()[0]->firstName = 'Wouter'

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

Enable other Features
Expand Down
5 changes: 3 additions & 2 deletions components/security/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ first constructor argument::

$role = new Role('ROLE_ADMIN');

// will echo 'ROLE_ADMIN'
echo $role->getRole();
// will show 'ROLE_ADMIN'
var_dump($role->getRole());

.. note::

Expand Down Expand Up @@ -247,3 +247,4 @@ decision manager::
if (!$securityContext->isGranted('ROLE_ADMIN')) {
throw new AccessDeniedException();
}

3 changes: 2 additions & 1 deletion components/translation/custom_formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Once created, it can be used as any other loader::

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

echo $translator->trans('welcome');
var_dump($translator->trans('welcome'));

It will print *"accueil"*.

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

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

6 changes: 3 additions & 3 deletions components/translation/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Imagine you want to translate the string *"Symfony is great"* into French::
'Symfony is great!' => 'J\'aime Symfony!',
), 'fr_FR');

echo $translator->trans('Symfony is great!');
var_dump($translator->trans('Symfony is great!'));

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

echo $translated;
var_dump($translated);

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

echo $translated;
var_dump($translated);

Symfony will now look for a translation of the raw message (``Hello %name%``)
and *then* replace the placeholders with their values. Creating a translation
Expand Down
3 changes: 2 additions & 1 deletion cookbook/bundles/remove.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ can remove the ``Acme`` directory as well.
:method:`Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface::getPath` method
to get the path of the bundle::

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

3.1 Remove Bundle Assets
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down