minor #28301 Fix code examples in PHPDoc (maidmaid)

This PR was merged into the 2.8 branch.

Discussion
----------

Fix code examples in PHPDoc

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | /
| License       | MIT
| Doc PR        | /

This PR properly indents the code examples in PHPDoc for a clean render.

Commits
-------

1afb043dc5 Fix code examples in PHPDoc
This commit is contained in:
Fabien Potencier 2018-08-30 18:22:36 +02:00
commit fb9ccc0fec
38 changed files with 245 additions and 312 deletions

View File

@ -27,6 +27,7 @@ use Symfony\Component\Security\Core\Exception\TokenNotFoundException;
* and to do the conversion of the datetime column.
*
* In order to use this class, you need the following table in your database:
*
* CREATE TABLE `rememberme_token` (
* `series` char(88) UNIQUE PRIMARY KEY NOT NULL,
* `value` char(88) NOT NULL,

View File

@ -19,11 +19,10 @@ use Twig\TokenParser\AbstractTokenParser;
* Token Parser for the 'dump' tag.
*
* Dump variables with:
* <pre>
*
* {% dump %}
* {% dump foo %}
* {% dump foo, bar %}
* </pre>
*
* @author Julien Galenski <julien.galenski@gmail.com>
*/

View File

@ -232,18 +232,14 @@ class FormHelper extends Helper
* Use this helper for CSRF protection without the overhead of creating a
* form.
*
* <code>
* echo $view['form']->csrfToken('rm_user_'.$user->getId());
* </code>
*
* Check the token in your action using the same intention.
*
* <code>
* $csrfProvider = $this->get('security.csrf.token_generator');
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
* throw new \RuntimeException('CSRF attack detected.');
* }
* </code>
*
* @param string $intention The intention of the protected action
*

View File

@ -342,6 +342,7 @@ class PrototypedArrayNode extends ArrayNode
* one is same as this->keyAttribute and the other is 'value', then the prototype will be different.
*
* For example, assume $this->keyAttribute is 'name' and the value array is as follows:
*
* array(
* array(
* 'name' => 'name001',
@ -350,6 +351,7 @@ class PrototypedArrayNode extends ArrayNode
* )
*
* Now, the key is 0 and the child node is:
*
* array(
* 'name' => 'name001',
* 'value' => 'value001'
@ -357,11 +359,13 @@ class PrototypedArrayNode extends ArrayNode
*
* When normalizing the value array, the 'name' element will removed from the child node
* and its value becomes the new key of the child node:
*
* array(
* 'name001' => array('value' => 'value001')
* )
*
* Now only 'value' element is left in the child node which can be further simplified into a string:
*
* array('name001' => 'value001')
*
* Now, the key becomes 'name001' and the child node becomes 'value001' and

View File

@ -224,7 +224,7 @@ class Table
* Renders table to output.
*
* Example:
* <code>
*
* +---------------+-----------------------+------------------+
* | ISBN | Title | Author |
* +---------------+-----------------------+------------------+
@ -232,7 +232,6 @@ class Table
* | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
* | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
* +---------------+-----------------------+------------------+
* </code>
*/
public function render()
{
@ -266,7 +265,9 @@ class Table
/**
* Renders horizontal header separator.
*
* Example: <code>+-----+-----------+-------+</code>
* Example:
*
* +-----+-----------+-------+
*/
private function renderRowSeparator()
{
@ -297,7 +298,9 @@ class Table
/**
* Renders table row.
*
* Example: <code>| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |</code>
* Example:
*
* | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
*
* @param array $row
* @param string $cellFormat

View File

@ -33,11 +33,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
* A service can also be defined by creating a method named
* getXXXService(), where XXX is the camelized version of the id:
*
* <ul>
* <li>request -> getRequestService()</li>
* <li>mysql_session_storage -> getMysqlSessionStorageService()</li>
* <li>symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()</li>
* </ul>
* * request -> getRequestService()
* * mysql_session_storage -> getMysqlSessionStorageService()
* * symfony.mysql_session_storage -> getSymfony_MysqlSessionStorageService()
*
* The container can have three possible behaviors when a service does not exist:
*

View File

@ -787,7 +787,7 @@ class Crawler extends \SplObjectStorage
* Escaped characters are: quotes (") and apostrophe (').
*
* Examples:
* <code>
*
* echo Crawler::xpathLiteral('foo " bar');
* //prints 'foo " bar'
*
@ -796,7 +796,7 @@ class Crawler extends \SplObjectStorage
*
* echo Crawler::xpathLiteral('a\'b"c');
* //prints concat('a', "'", 'b"c')
* </code>
*
*
* @param string $s String to be escaped
*

View File

@ -186,9 +186,7 @@ class FormFieldRegistry
/**
* Splits a field name into segments as a web browser would do.
*
* <code>
* getSegments('base[foo][3][]') = array('base', 'foo, '3', '');
* </code>
*
* @param string $name The name of the field
*

View File

@ -29,7 +29,6 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
*
* Example:
*
* ```php
* $choices = array('' => 'Don\'t know', 0 => 'No', 1 => 'Yes');
* $choiceList = new ArrayKeyChoiceList(array_keys($choices));
*
@ -38,7 +37,6 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
*
* $selectedValues = $choiceList->getValuesForChoices(array(true));
* // => array('1')
* ```
*
* @author Bernhard Schussek <bschussek@gmail.com>
*

View File

@ -24,18 +24,14 @@ use Symfony\Component\PropertyAccess\PropertyPath;
*
* Pass the decorated factory to the constructor:
*
* ```php
* $decorator = new PropertyAccessDecorator($factory);
* ```
*
* You can now pass property paths for generating choice values, labels, view
* indices, HTML attributes and for determining the preferred choices and the
* choice groups:
*
* ```php
* // extract values from the $value property
* $list = $createListFromChoices($objects, 'value');
* ```
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/

View File

@ -28,11 +28,9 @@ use Symfony\Component\Form\FormConfigBuilder;
* can be stored in the array key pointing to the nested array. The topmost
* level of the hierarchy may also be a \Traversable.
*
* <code>
* $choices = array(true, false);
* $labels = array('Agree', 'Disagree');
* $choiceList = new ArrayChoiceList($choices, $labels);
* </code>
*
* @author Bernhard Schussek <bschussek@gmail.com>
*

View File

@ -26,12 +26,10 @@ use Symfony\Component\PropertyAccess\PropertyPath;
* Supports generation of choice labels, choice groups and choice values
* by calling getters of the object (or associated objects).
*
* <code>
* $choices = array($user1, $user2);
*
* // call getName() to determine the choice labels
* $choiceList = new ObjectChoiceList($choices, 'name');
* </code>
*
* @author Bernhard Schussek <bschussek@gmail.com>
*

View File

@ -22,12 +22,10 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList;
* creating nested arrays. The title of the sub-hierarchy can be stored in the
* array key pointing to the nested array.
*
* <code>
* $choiceList = new SimpleChoiceList(array(
* 'creditcard' => 'Credit card payment',
* 'cash' => 'Cash payment',
* ));
* </code>
*
* @author Bernhard Schussek <bschussek@gmail.com>
*

View File

@ -198,9 +198,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
*
* Consider the following violation path:
*
* <code>
* children[address].children[office].data.street
* </code>
*
* In this example, "address" and "office" map to forms, while
* "street does not.

View File

@ -53,11 +53,9 @@ interface FormRendererEngineInterface
* and continues with the child of that root, the child of that child etc.
* The following is an example for a block hierarchy:
*
* <code>
* form_widget
* text_widget
* url_widget
* </code>
*
* In this example, "url_widget" is the most specific block, while the other
* blocks are its ancestors in the hierarchy.
@ -91,11 +89,9 @@ interface FormRendererEngineInterface
* and continues with the child of that root, the child of that child etc.
* The following is an example for a block hierarchy:
*
* <code>
* form_widget
* text_widget
* url_widget
* </code>
*
* The second parameter $hierarchyLevel determines the level of the hierarchy
* that should be rendered.

View File

@ -69,18 +69,14 @@ interface FormRendererInterface
* Use this helper for CSRF protection without the overhead of creating a
* form.
*
* <code>
* <input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
* </code>
*
* Check the token in your action using the same token ID.
*
* <code>
* $csrfProvider = $this->get('security.csrf.token_generator');
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
* throw new \RuntimeException('CSRF attack detected.');
* }
* </code>
*
* @param string $tokenId The ID of the CSRF token
*

View File

@ -18,7 +18,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
*
* Use this class to conveniently create new form factories:
*
* <code>
* use Symfony\Component\Form\Forms;
*
* $formFactory = Forms::createFormFactory();
@ -32,15 +31,12 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* 'choices_as_values' => true,
* ))
* ->getForm();
* </code>
*
* You can also add custom extensions to the form factory:
*
* <code>
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new AcmeExtension())
* ->getFormFactory();
* </code>
*
* If you create custom form types or type extensions, it is
* generally recommended to create your own extensions that lazily
@ -48,18 +44,15 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* does not matter that much, you can also pass them directly to the
* form factory:
*
* <code>
* $formFactory = Forms::createFormFactoryBuilder()
* ->addType(new PersonType())
* ->addType(new PhoneNumberType())
* ->addTypeExtension(new FormTypeHelpTextExtension())
* ->getFormFactory();
* </code>
*
* Support for the Validator component is provided by ValidatorExtension.
* This extension needs a validator object to function properly:
*
* <code>
* use Symfony\Component\Validator\Validation;
* use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
*
@ -67,14 +60,12 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new ValidatorExtension($validator))
* ->getFormFactory();
* </code>
*
* Support for the Templating component is provided by TemplatingExtension.
* This extension needs a PhpEngine object for rendering forms. As second
* argument you should pass the names of the default themes. Here is an
* example for using the default layout with "<div>" tags:
*
* <code>
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
* $formFactory = Forms::createFormFactoryBuilder()
@ -82,11 +73,9 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* 'FrameworkBundle:Form',
* )))
* ->getFormFactory();
* </code>
*
* The next example shows how to include the "<table>" layout:
*
* <code>
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
* $formFactory = Forms::createFormFactoryBuilder()
@ -95,7 +84,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* 'FrameworkBundle:FormTable',
* )))
* ->getFormFactory();
* </code>
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/

View File

@ -360,11 +360,9 @@ class OptionsResolver implements Options, OptionsResolverInterface
*
* The normalizer should be a closure with the following signature:
*
* ```php
* function (Options $options, $value) {
* // ...
* }
* ```
*
* The closure is invoked when {@link resolve()} is called. The closure
* has access to the resolved values of other options through the passed

View File

@ -29,10 +29,8 @@ interface OptionsResolverInterface
* evaluate the option value lazily. These closures must have one
* of the following signatures:
*
* <code>
* function (Options $options)
* function (Options $options, $value)
* </code>
*
* The second parameter passed to the closure is the previously
* set default value, in case you are overwriting an existing
@ -154,9 +152,7 @@ interface OptionsResolverInterface
*
* The normalizers should be closures with the following signature:
*
* <code>
* function (Options $options, $value)
* </code>
*
* The second parameter passed to the closure is the value of
* the option.

View File

@ -36,12 +36,10 @@ interface UserInterface
/**
* Returns the roles granted to the user.
*
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* }
* </code>
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object

View File

@ -31,9 +31,13 @@ interface AuthenticationEntryPointInterface
* response that "helps" the user start into the authentication process.
*
* Examples:
* A) For a form login, you might redirect to the login page
*
* - For a form login, you might redirect to the login page
*
* return new RedirectResponse('/login');
* B) For an API token authentication system, you return a 401 response
*
* - For an API token authentication system, you return a 401 response
*
* return new Response('Auth header required', 401);
*
* @param Request $request The request that resulted in an AuthenticationException

View File

@ -21,9 +21,7 @@ use Symfony\Component\Templating\Asset\UrlPackage;
*
* Usage:
*
* <code>
* <img src="<?php echo $view['assets']->getUrl('foo.png') ?>" />
* </code>
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Kris Wallsmith <kris@symfony.com>

View File

@ -20,9 +20,7 @@ use Symfony\Component\Templating\Asset\PackageInterface;
*
* Usage:
*
* <code>
* <img src="<?php echo $view['assets']->getUrl('foo.png') ?>" />
* </code>
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Kris Wallsmith <kris@symfony.com>

View File

@ -37,7 +37,7 @@ abstract class AbstractOperation implements OperationInterface
* This array stores 'all', 'new' and 'obsolete' messages for all valid domains.
*
* The data structure of this array is as follows:
* ```php
*
* array(
* 'domain 1' => array(
* 'all' => array(...),
@ -51,7 +51,6 @@ abstract class AbstractOperation implements OperationInterface
* ),
* ...
* )
* ```
*
* @var array The array that stores 'all', 'new' and 'obsolete' messages
*/

View File

@ -19,11 +19,9 @@ namespace Symfony\Component\Validator;
* element in the validation graph and the root element that was originally
* passed to the validator. For example, take the following graph:
*
* <pre>
* (Person)---(firstName: string)
* \
* (address: Address)---(street: string)
* </pre>
*
* If the <tt>Person</tt> object is validated and validation fails for the
* "firstName" property, the generated violation has the <tt>Person</tt>

View File

@ -16,21 +16,17 @@ namespace Symfony\Component\Validator;
*
* For example, let's validate the following object graph:
*
* <pre>
* (Person)---($firstName: string)
* \
* ($address: Address)---($street: string)
* </pre>
*
* We validate the <tt>Person</tt> instance, which becomes the "root" of the
* validation run (see {@link getRoot}). The state of the context after the
* first step will be like this:
*
* <pre>
* (Person)---($firstName: string)
* ^ \
* ($address: Address)---($street: string)
* </pre>
*
* The validator is stopped at the <tt>Person</tt> node, both the root and the
* value (see {@link getValue}) of the context point to the <tt>Person</tt>
@ -41,11 +37,9 @@ namespace Symfony\Component\Validator;
* After advancing to the property <tt>$firstName</tt> of the <tt>Person</tt>
* instance, the state of the context looks like this:
*
* <pre>
* (Person)---($firstName: string)
* \ ^
* ($address: Address)---($street: string)
* </pre>
*
* The validator is stopped at the property <tt>$firstName</tt>. The root still
* points to the <tt>Person</tt> instance, because this is where the validation
@ -56,12 +50,10 @@ namespace Symfony\Component\Validator;
* <tt>$street</tt> property of the <tt>Address</tt> instance, the context state
* looks like this:
*
* <pre>
* (Person)---($firstName: string)
* \
* ($address: Address)---($street: string)
* ^
* </pre>
*
* The validator is stopped at the property <tt>$street</tt>. The root still
* points to the <tt>Person</tt> instance, but the property path is now
@ -128,19 +120,14 @@ interface ExecutionContextInterface
* argument which is appended to the current property path when a violation
* is created. For example, take the following object graph:
*
* <pre>
* (Person)---($address: Address)---($phoneNumber: PhoneNumber)
* ^
* </pre>
*
* When the execution context stops at the <tt>Person</tt> instance, the
* property path is "address". When you validate the <tt>PhoneNumber</tt>
* instance now, pass "phoneNumber" as sub path to correct the property path
* to "address.phoneNumber":
*
* <pre>
* $context->validate($address->phoneNumber, 'phoneNumber');
* </pre>
*
* Any violations generated during the validation will be added to the
* violation list that you can access with {@link getViolations}.
@ -167,19 +154,14 @@ interface ExecutionContextInterface
* Use the parameter <tt>$subPath</tt> to adapt the property path for the
* validated value. For example, take the following object graph:
*
* <pre>
* (Person)---($address: Address)---($street: string)
* ^
* </pre>
*
* When the validator validates the <tt>Address</tt> instance, the
* property path stored in the execution context is "address". When you
* manually validate the property <tt>$street</tt> now, pass the sub path
* "street" to adapt the full property path to "address.street":
*
* <pre>
* $context->validate($address->street, new NotNull(), 'street');
* </pre>
*
* @param mixed $value The value to validate
* @param Constraint|Constraint[] $constraints The constraint(s) to validate against
@ -290,9 +272,7 @@ interface ExecutionContextInterface
*
* For example, take the following object graph:
*
* <pre>
* (Person)---($address: Address)---($street: string)
* </pre>
*
* When the <tt>Person</tt> instance is passed to the validator, the
* property path is initially empty. When the <tt>$address</tt> property

View File

@ -24,10 +24,9 @@ class Yaml
* Parses YAML into a PHP value.
*
* Usage:
* <code>
*
* $array = Yaml::parse(file_get_contents('config.yml'));
* print_r($array);
* </code>
*
* As this method accepts both plain strings and file names as an input,
* you must validate the input before calling this method. Passing a file