Skip to content

Commit

Permalink
5177 use var_dump() in components
Browse files Browse the repository at this point in the history
Conflicts:
	components/expression_language/caching.rst
	components/expression_language/extending.rst
	components/expression_language/introduction.rst
	components/expression_language/syntax.rst
	components/serializer.rst
  • Loading branch information
Henry Snoek authored and wouterj committed Jun 27, 2015
1 parent c2acbee commit 9fa1c11
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 37 deletions.
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;

dump(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;

dump(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) {
dump($domElement->nodeName);
var_dump($domElement->nodeName);
}

Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and
Expand Down
4 changes: 2 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);

dump($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);

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

class FooListener
{
Expand Down
6 changes: 3 additions & 3 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ directories::

foreach ($finder as $file) {
// Dump the absolute path
dump($file->getRealpath());
var_dump($file->getRealpath());

// Dump the relative path to the file, omitting the filename
dump($file->getRelativePath());
var_dump($file->getRelativePath());

// Dump the relative path to the file
dump($file->getRelativePathname());
var_dump($file->getRelativePathname());
}

The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo`
Expand Down
2 changes: 1 addition & 1 deletion components/form/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ is created from the form factory.
->add('dueDate', 'date')
->getForm();
dump($twig->render('new.html.twig', array(
var_dump($twig->render('new.html.twig', array(
'form' => $form->createView(),
)));
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 () {
dump('Hello World');
var_dump('Hello World');
flush();
sleep(2);
dump('Hello World');
var_dump('Hello World');
flush();
});
$response->send();
Expand Down
10 changes: 5 additions & 5 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');

dump($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');

dump($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
dump($data['Data']['entry1']);
var_dump($data['Data']['entry1']);

// Returns null if the key "Data" does not exist
dump($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,7 +286,7 @@ 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``::

dump($reader->readEntry(
var_dump($reader->readEntry(
'/path/to/bundle',
'en',
array('Data', 'entry1'),
Expand Down
32 changes: 16 additions & 16 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',
);

dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
dump($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 Down Expand Up @@ -86,13 +86,13 @@ To read from properties, use the "dot" notation::
$person = new Person();
$person->firstName = 'Wouter';

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

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

dump($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();

dump($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')) {
dump('He is an author');
var_dump('He is an author');
}
if ($accessor->getValue($person, 'children')) {
dump('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();

dump($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();

dump($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');

dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
// or
// dump($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()));

dump($person->firstName); // 'Wouter'
dump($person->getLastName()); // 'de Jong'
dump($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(...));
dump($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'

dump('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
2 changes: 1 addition & 1 deletion components/security/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ first constructor argument::
$role = new Role('ROLE_ADMIN');

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

.. note::

Expand Down
2 changes: 1 addition & 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');

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

It will print *"accueil"*.

Expand Down
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');

dump($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);

dump($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)
);

dump($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

0 comments on commit 9fa1c11

Please sign in to comment.