diff --git a/book/doctrine.rst b/book/doctrine.rst index 7ecd592ef63..5f842454f7c 100644 --- a/book/doctrine.rst +++ b/book/doctrine.rst @@ -1199,7 +1199,7 @@ to the given ``Category`` object via their ``category_id`` value. $category = $product->getCategory(); // prints "Proxies\AppBundleEntityCategoryProxy" - echo get_class($category); + dump(get_class($category)); This proxy object extends the true ``Category`` object, and looks and acts exactly like it. The difference is that, by using a proxy object, diff --git a/book/translation.rst b/book/translation.rst index 579150646bf..7b3247ae583 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -12,11 +12,11 @@ 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'); // text can be translated into the end-user's language or // default to English - echo $translator->trans('Hello World'); + dump($translator->trans('Hello World')); .. note:: diff --git a/components/class_loader/class_map_generator.rst b/components/class_loader/class_map_generator.rst index faf06e88809..b35aa731824 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; - print_r(ClassMapGenerator::createMap(__DIR__.'/library')); + 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 2eaf063169c..62be28c88e9 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -49,7 +49,7 @@ equivalents:: use Symfony\Component\CssSelector\CssSelector; - print CssSelector::toXPath('div.item > h4 > a'); + 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 c9809e28331..64b6630f9ed 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -45,7 +45,7 @@ traverse easily:: $crawler = new Crawler($html); foreach ($crawler as $domElement) { - print $domElement->nodeName; + 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 3be0b9bb876..73ade2a1c8e 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); - echo $event['counter']; + dump($event['counter']); class FooListener { @@ -96,7 +96,7 @@ Filtering data:: $event = new GenericEvent($subject, array('data' => 'Foo')); $dispatcher->dispatch('foo', $event); - echo $event['data']; + dump($event['data']); class FooListener { @@ -105,3 +105,4 @@ Filtering data:: $event['data'] = strtolower($event['data']); } } + diff --git a/components/event_dispatcher/introduction.rst b/components/event_dispatcher/introduction.rst index a106834b965..c951c6f5016 100644 --- a/components/event_dispatcher/introduction.rst +++ b/components/event_dispatcher/introduction.rst @@ -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 } } diff --git a/components/expression_language/caching.rst b/components/expression_language/caching.rst index f7de6fb9066..7b36ce4163d 100644 --- a/components/expression_language/caching.rst +++ b/components/expression_language/caching.rst @@ -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 + dump($language->evaluate($expression)); // prints 5 .. code-block:: php @@ -68,7 +68,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and serialize($language->parse('1 + 4', array())) ); - echo $language->evaluate($expression); // prints 5 + 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 diff --git a/components/expression_language/extending.rst b/components/expression_language/extending.rst index 4aded7c5aeb..16708a2a5a8 100644 --- a/components/expression_language/extending.rst +++ b/components/expression_language/extending.rst @@ -44,7 +44,7 @@ This method has 3 arguments: return strtolower($str); }); - echo $language->evaluate('lowercase("HELLO")'); + 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 @@ -126,3 +126,4 @@ or by using the second argument of the constructor:: parent::__construct($parser, $providers); } } + diff --git a/components/expression_language/introduction.rst b/components/expression_language/introduction.rst index b14e37d5504..7ed8c179639 100644 --- a/components/expression_language/introduction.rst +++ b/components/expression_language/introduction.rst @@ -68,9 +68,9 @@ The main class of the component is $language = new ExpressionLanguage(); - echo $language->evaluate('1 + 2'); // displays 3 + dump($language->evaluate('1 + 2')); // displays 3 - echo $language->compile('1 + 2'); // displays (1 + 2) + dump($language->compile('1 + 2')); // displays (1 + 2) Expression Syntax ----------------- @@ -96,12 +96,12 @@ PHP type (including objects):: $apple = new Apple(); $apple->variety = 'Honeycrisp'; - echo $language->evaluate( + 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`. diff --git a/components/expression_language/syntax.rst b/components/expression_language/syntax.rst index 56ec1da1173..7766ee075ec 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -42,12 +42,12 @@ to JavaScript:: $apple = new Apple(); $apple->variety = 'Honeycrisp'; - echo $language->evaluate( + dump($language->evaluate( 'fruit.variety', array( 'fruit' => $apple, ) - ); + )); This will print out ``Honeycrisp``. @@ -72,12 +72,12 @@ JavaScript:: $robot = new Robot(); - echo $language->evaluate( + dump($language->evaluate( 'robot.sayHi(3)', array( 'robot' => $robot, ) - ); + )); This will print out ``Hi Hi Hi!``. @@ -93,9 +93,9 @@ constant:: define('DB_USER', 'root'); - echo $language->evaluate( + dump($language->evaluate( 'constant("DB_USER")' - ); + )); This will print out ``root``. @@ -114,12 +114,12 @@ array keys, similar to JavaScript:: $data = array('life' => 10, 'universe' => 10, 'everything' => 22); - echo $language->evaluate( + dump($language->evaluate( 'data["life"] + data["universe"] + data["everything"]', array( 'data' => $data, ) - ); + )); This will print out ``42``. @@ -140,14 +140,14 @@ Arithmetic Operators For example:: - echo $language->evaluate( + dump($language->evaluate( 'life + universe + everything', array( 'life' => 10, 'universe' => 10, 'everything' => 22, ) - ); + )); This will print out ``42``. @@ -230,13 +230,13 @@ String Operators For example:: - echo $language->evaluate( + dump($language->evaluate( 'firstName~" "~lastName', array( 'firstName' => 'Arthur', 'lastName' => 'Dent', ) - ); + )); This would print out ``Arthur Dent``. diff --git a/components/finder.rst b/components/finder.rst index f3e8d5e8310..7abc705eb4f 100644 --- a/components/finder.rst +++ b/components/finder.rst @@ -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 + 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 + dump($file->getRelativePath()); - // Print the relative path to the file - print $file->getRelativePathname()."\n"; + // Dump the relative path to the file + dump($file->getRelativePathname()); } The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo` @@ -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:: diff --git a/components/form/introduction.rst b/components/form/introduction.rst index fae4de63540..5e1839543b4 100644 --- a/components/form/introduction.rst +++ b/components/form/introduction.rst @@ -394,9 +394,9 @@ is created from the form factory. ->add('dueDate', 'date') ->getForm(); - echo $twig->render('new.html.twig', array( + dump($twig->render('new.html.twig', array( 'form' => $form->createView(), - )); + ))); .. code-block:: php-symfony diff --git a/components/http_foundation/introduction.rst b/components/http_foundation/introduction.rst index 73187523f3f..551ae331172 100644 --- a/components/http_foundation/introduction.rst +++ b/components/http_foundation/introduction.rst @@ -447,10 +447,10 @@ represented by a PHP callable instead of a string:: $response = new StreamedResponse(); $response->setCallback(function () { - echo 'Hello World'; + dump('Hello World'); flush(); sleep(2); - echo 'Hello World'; + dump('Hello World'); flush(); }); $response->send(); diff --git a/components/intl.rst b/components/intl.rst index c638f8bd2f6..4adc9277bf3 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -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']; + dump($data['Data']['entry1']); PhpBundleReader ~~~~~~~~~~~~~~~ @@ -152,7 +152,7 @@ object:: $reader = new PhpBundleReader(); $data = $reader->read('/path/to/bundle', 'en'); - echo $data['Data']['entry1']; + dump($data['Data']['entry1']); BufferedBundleReader ~~~~~~~~~~~~~~~~~~~~ @@ -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']; + dump($data['Data']['entry1']); // Returns null if the key "Data" does not exist - echo $reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1')); + dump($reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1'))); Additionally, the :method:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface::readEntry` @@ -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( + dump($reader->readEntry( '/path/to/bundle', 'en', array('Data', 'entry1'), false - ); + )); Accessing ICU Data ------------------ diff --git a/components/property_access/introduction.rst b/components/property_access/introduction.rst index d8d4c774610..1e08ad30d6c 100644 --- a/components/property_access/introduction.rst +++ b/components/property_access/introduction.rst @@ -45,8 +45,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 + dump($accessor->getValue($person, '[first_name]')); // 'Wouter' + dump($accessor->getValue($person, '[age]')); // null As you can see, the method will return ``null`` if the index does not exists. @@ -62,8 +62,8 @@ You can also use multi dimensional arrays:: ) ); - echo $accessor->getValue($persons, '[0][first_name]'); // 'Wouter' - echo $accessor->getValue($persons, '[1][first_name]'); // 'Ryan' + dump($accessor->getValue($persons, '[0][first_name]')); // 'Wouter' + dump($accessor->getValue($persons, '[1][first_name]')); // 'Ryan' Reading from Objects -------------------- @@ -80,13 +80,13 @@ To read from properties, use the "dot" notation:: $person = new Person(); $person->firstName = 'Wouter'; - echo $accessor->getValue($person, 'firstName'); // 'Wouter' + dump($accessor->getValue($person, 'firstName')); // 'Wouter' $child = new Person(); $child->firstName = 'Bar'; $person->children = array($child); - echo $accessor->getValue($person, 'children[0].firstName'); // 'Bar' + dump($accessor->getValue($person, 'children[0].firstName')); // 'Bar' .. caution:: @@ -116,7 +116,7 @@ property name (``first_name`` becomes ``FirstName``) and prefixes it with $person = new Person(); - echo $accessor->getValue($person, 'first_name'); // 'Wouter' + dump($accessor->getValue($person, 'first_name')); // 'Wouter' Using Hassers/Issers ~~~~~~~~~~~~~~~~~~~~ @@ -145,10 +145,10 @@ getters, this means that you can do something like this:: $person = new Person(); if ($accessor->getValue($person, 'author')) { - echo 'He is an author'; + dump('He is an author'); } if ($accessor->getValue($person, 'children')) { - echo 'He has children'; + dump('He has children'); } This will produce: ``He is an author`` @@ -173,7 +173,7 @@ The ``getValue`` method can also use the magic ``__get`` method:: $person = new Person(); - echo $accessor->getValue($person, 'Wouter'); // array(...) + dump($accessor->getValue($person, 'Wouter')); // array(...) .. _components-property-access-magic-call: @@ -211,7 +211,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert ->enableMagicCall() ->getPropertyAccessor(); - echo $accessor->getValue($person, 'wouter'); // array(...) + dump($accessor->getValue($person, 'wouter')); // array(...) .. versionadded:: 2.3 The use of magic ``__call()`` method was introduced in Symfony 2.3. @@ -235,9 +235,9 @@ method:: $accessor->setValue($person, '[first_name]', 'Wouter'); - echo $accessor->getValue($person, '[first_name]'); // 'Wouter' + dump($accessor->getValue($person, '[first_name]')); // 'Wouter' // or - // echo $person['first_name']; // 'Wouter' + // dump($person['first_name']); // 'Wouter' Writing to Objects ------------------ @@ -271,9 +271,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()); + dump($person->firstName); // 'Wouter' + dump($person->getLastName()); // 'de Jong' + dump($person->children); // array(Person()); You can also use ``__call`` to set values but you need to enable the feature, see `Enable other Features`_. @@ -309,7 +309,7 @@ see `Enable other Features`_. $accessor->setValue($person, 'wouter', array(...)); - echo $person->getWouter(); // array(...) + dump($person->getWouter()); // array(...) Checking Property Paths ----------------------- @@ -374,7 +374,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' + 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 17d51b6e998..c8651e76391 100644 --- a/components/security/authorization.rst +++ b/components/security/authorization.rst @@ -191,8 +191,8 @@ first constructor argument:: $role = new Role('ROLE_ADMIN'); - // will echo 'ROLE_ADMIN' - echo $role->getRole(); + // will show 'ROLE_ADMIN' + dump($role->getRole()); .. note:: @@ -253,3 +253,4 @@ decision manager:: if (!$authorizationChecker->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException(); } + diff --git a/components/serializer.rst b/components/serializer.rst index 7a4bd7006a3..55f563f5314 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -358,7 +358,7 @@ having unique identifiers:: }); $serializer = new Serializer(array($normalizer), array($encoder)); - echo $serializer->serialize($org, 'json'); + dump($serializer->serialize($org, 'json')); // {"name":"Les-Tilleuls.coop","members":[{"name":"K\u00e9vin", organization: "Les-Tilleuls.coop"}]} JMSSerializer diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index 4378d249f86..793d118c549 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'); - echo $translator->trans('welcome'); + dump($translator->trans('welcome')); It will print *"accueil"*. @@ -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')); + diff --git a/components/translation/usage.rst b/components/translation/usage.rst index 4ccd2c3e868..6dad3147b0e 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'); - echo $translator->trans('Symfony is great!'); + 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); - echo $translated; + 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) ); - echo $translated; + 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 @@ -392,3 +392,4 @@ The ``$messages`` variable will have the following structure:: 'Value is too long' => 'Valeur est trop long', ), ); + diff --git a/cookbook/bundles/remove.rst b/cookbook/bundles/remove.rst index 407ee421aa4..2cc87decf61 100644 --- a/cookbook/bundles/remove.rst +++ b/cookbook/bundles/remove.rst @@ -79,7 +79,7 @@ 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()); 3.1 Remove Bundle Assets ~~~~~~~~~~~~~~~~~~~~~~~~