From 9fa1c11d1df41e65335e8ed772095ba45e8ceff5 Mon Sep 17 00:00:00 2001 From: Henry Snoek Date: Wed, 17 Jun 2015 20:07:31 +0200 Subject: [PATCH] 5177 use var_dump() in components Conflicts: components/expression_language/caching.rst components/expression_language/extending.rst components/expression_language/introduction.rst components/expression_language/syntax.rst components/serializer.rst --- .../class_loader/class_map_generator.rst | 2 +- components/css_selector.rst | 2 +- components/dom_crawler.rst | 2 +- components/event_dispatcher/generic_event.rst | 4 +-- components/finder.rst | 6 ++-- components/form/introduction.rst | 2 +- components/http_foundation/introduction.rst | 4 +-- components/intl.rst | 10 +++--- components/property_access/introduction.rst | 32 +++++++++---------- components/security/authorization.rst | 2 +- components/translation/custom_formats.rst | 2 +- components/translation/usage.rst | 6 ++-- 12 files changed, 37 insertions(+), 37 deletions(-) diff --git a/components/class_loader/class_map_generator.rst b/components/class_loader/class_map_generator.rst index b35aa731824..772bd9ab693 100644 --- a/components/class_loader/class_map_generator.rst +++ b/components/class_loader/class_map_generator.rst @@ -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: diff --git a/components/css_selector.rst b/components/css_selector.rst index fb6c5cea7f9..cbb2e133044 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -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: diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index b6609ecb192..fb82e1ae1a1 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -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 diff --git a/components/event_dispatcher/generic_event.rst b/components/event_dispatcher/generic_event.rst index 73ade2a1c8e..27d3723e994 100644 --- a/components/event_dispatcher/generic_event.rst +++ b/components/event_dispatcher/generic_event.rst @@ -75,7 +75,7 @@ the event arguments:: ); $dispatcher->dispatch('foo', $event); - dump($event['counter']); + var_dump($event['counter']); class FooListener { @@ -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 { diff --git a/components/finder.rst b/components/finder.rst index 4d73e8a4ecb..f4c1bde02dd 100644 --- a/components/finder.rst +++ b/components/finder.rst @@ -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` diff --git a/components/form/introduction.rst b/components/form/introduction.rst index 931dc87fdb5..89d1848fbc6 100644 --- a/components/form/introduction.rst +++ b/components/form/introduction.rst @@ -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(), ))); diff --git a/components/http_foundation/introduction.rst b/components/http_foundation/introduction.rst index 2640459e8c9..287a78ac625 100644 --- a/components/http_foundation/introduction.rst +++ b/components/http_foundation/introduction.rst @@ -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(); diff --git a/components/intl.rst b/components/intl.rst index 1a8dc20573e..75c843f5ee6 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -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 ~~~~~~~~~~~~~~~ @@ -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 ~~~~~~~~~~~~~~~~~~~~ @@ -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` @@ -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'), diff --git a/components/property_access/introduction.rst b/components/property_access/introduction.rst index 1b1f5179b75..3df0b1b5a28 100644 --- a/components/property_access/introduction.rst +++ b/components/property_access/introduction.rst @@ -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. @@ -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:: @@ -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 ~~~~~~~~~~~~~~~~~~~~ @@ -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`` @@ -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 ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -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. @@ -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 ------------------ @@ -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`_. @@ -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 ------------------------- @@ -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 diff --git a/components/security/authorization.rst b/components/security/authorization.rst index 5032b91340c..3b170d106e4 100644 --- a/components/security/authorization.rst +++ b/components/security/authorization.rst @@ -187,7 +187,7 @@ first constructor argument:: $role = new Role('ROLE_ADMIN'); // will show 'ROLE_ADMIN' - dump($role->getRole()); + var_dump($role->getRole()); .. note:: diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index 793d118c549..14c6e65c8b0 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -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"*. diff --git a/components/translation/usage.rst b/components/translation/usage.rst index 55cb44ae832..eb0fe4978c5 100644 --- a/components/translation/usage.rst +++ b/components/translation/usage.rst @@ -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 @@ -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 @@ -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