Skip to content

Commit 557846f

Browse files
committed
Fix code examples in PHPDoc
1 parent 0b48886 commit 557846f

File tree

9 files changed

+71
-105
lines changed

9 files changed

+71
-105
lines changed

ChoiceList/ArrayKeyChoiceList.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@
2929
*
3030
* Example:
3131
*
32-
* ```php
33-
* $choices = array('' => 'Don\'t know', 0 => 'No', 1 => 'Yes');
34-
* $choiceList = new ArrayKeyChoiceList(array_keys($choices));
32+
* $choices = array('' => 'Don\'t know', 0 => 'No', 1 => 'Yes');
33+
* $choiceList = new ArrayKeyChoiceList(array_keys($choices));
3534
*
36-
* $values = $choiceList->getValues()
37-
* // => array('', '0', '1')
35+
* $values = $choiceList->getValues()
36+
* // => array('', '0', '1')
3837
*
39-
* $selectedValues = $choiceList->getValuesForChoices(array(true));
40-
* // => array('1')
41-
* ```
38+
* $selectedValues = $choiceList->getValuesForChoices(array(true));
39+
* // => array('1')
4240
*
4341
* @author Bernhard Schussek <[email protected]>
4442
*

ChoiceList/Factory/PropertyAccessDecorator.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@
2424
*
2525
* Pass the decorated factory to the constructor:
2626
*
27-
* ```php
28-
* $decorator = new PropertyAccessDecorator($factory);
29-
* ```
27+
* $decorator = new PropertyAccessDecorator($factory);
3028
*
3129
* You can now pass property paths for generating choice values, labels, view
3230
* indices, HTML attributes and for determining the preferred choices and the
3331
* choice groups:
3432
*
35-
* ```php
36-
* // extract values from the $value property
37-
* $list = $createListFromChoices($objects, 'value');
38-
* ```
33+
* // extract values from the $value property
34+
* $list = $createListFromChoices($objects, 'value');
3935
*
4036
* @author Bernhard Schussek <[email protected]>
4137
*/

Extension/Core/ChoiceList/ChoiceList.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
* can be stored in the array key pointing to the nested array. The topmost
2929
* level of the hierarchy may also be a \Traversable.
3030
*
31-
* <code>
32-
* $choices = array(true, false);
33-
* $labels = array('Agree', 'Disagree');
34-
* $choiceList = new ArrayChoiceList($choices, $labels);
35-
* </code>
31+
* $choices = array(true, false);
32+
* $labels = array('Agree', 'Disagree');
33+
* $choiceList = new ArrayChoiceList($choices, $labels);
3634
*
3735
* @author Bernhard Schussek <[email protected]>
3836
*

Extension/Core/ChoiceList/ObjectChoiceList.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
* Supports generation of choice labels, choice groups and choice values
2727
* by calling getters of the object (or associated objects).
2828
*
29-
* <code>
30-
* $choices = array($user1, $user2);
29+
* $choices = array($user1, $user2);
3130
*
32-
* // call getName() to determine the choice labels
33-
* $choiceList = new ObjectChoiceList($choices, 'name');
34-
* </code>
31+
* // call getName() to determine the choice labels
32+
* $choiceList = new ObjectChoiceList($choices, 'name');
3533
*
3634
* @author Bernhard Schussek <[email protected]>
3735
*

Extension/Core/ChoiceList/SimpleChoiceList.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
* creating nested arrays. The title of the sub-hierarchy can be stored in the
2323
* array key pointing to the nested array.
2424
*
25-
* <code>
26-
* $choiceList = new SimpleChoiceList(array(
27-
* 'creditcard' => 'Credit card payment',
28-
* 'cash' => 'Cash payment',
29-
* ));
30-
* </code>
25+
* $choiceList = new SimpleChoiceList(array(
26+
* 'creditcard' => 'Credit card payment',
27+
* 'cash' => 'Cash payment',
28+
* ));
3129
*
3230
* @author Bernhard Schussek <[email protected]>
3331
*

Extension/Validator/ViolationMapper/ViolationPath.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ public function isIndex($index)
198198
*
199199
* Consider the following violation path:
200200
*
201-
* <code>
202-
* children[address].children[office].data.street
203-
* </code>
201+
* children[address].children[office].data.street
204202
*
205203
* In this example, "address" and "office" map to forms, while
206204
* "street does not.

FormRendererEngineInterface.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ public function getResourceForBlockName(FormView $view, $blockName);
5353
* and continues with the child of that root, the child of that child etc.
5454
* The following is an example for a block hierarchy:
5555
*
56-
* <code>
57-
* form_widget
58-
* text_widget
59-
* url_widget
60-
* </code>
56+
* form_widget
57+
* text_widget
58+
* url_widget
6159
*
6260
* In this example, "url_widget" is the most specific block, while the other
6361
* blocks are its ancestors in the hierarchy.
@@ -91,11 +89,9 @@ public function getResourceForBlockNameHierarchy(FormView $view, array $blockNam
9189
* and continues with the child of that root, the child of that child etc.
9290
* The following is an example for a block hierarchy:
9391
*
94-
* <code>
95-
* form_widget
96-
* text_widget
97-
* url_widget
98-
* </code>
92+
* form_widget
93+
* text_widget
94+
* url_widget
9995
*
10096
* The second parameter $hierarchyLevel determines the level of the hierarchy
10197
* that should be rendered.

FormRendererInterface.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,14 @@ public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $va
6969
* Use this helper for CSRF protection without the overhead of creating a
7070
* form.
7171
*
72-
* <code>
73-
* <input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
74-
* </code>
72+
* <input type="hidden" name="token" value="<?php $renderer->renderCsrfToken('rm_user_'.$user->getId()) ?>">
7573
*
7674
* Check the token in your action using the same token ID.
7775
*
78-
* <code>
79-
* $csrfProvider = $this->get('security.csrf.token_generator');
80-
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
81-
* throw new \RuntimeException('CSRF attack detected.');
82-
* }
83-
* </code>
76+
* $csrfProvider = $this->get('security.csrf.token_generator');
77+
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
78+
* throw new \RuntimeException('CSRF attack detected.');
79+
* }
8480
*
8581
* @param string $tokenId The ID of the CSRF token
8682
*

Forms.php

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,84 +18,72 @@
1818
*
1919
* Use this class to conveniently create new form factories:
2020
*
21-
* <code>
22-
* use Symfony\Component\Form\Forms;
23-
*
24-
* $formFactory = Forms::createFormFactory();
25-
*
26-
* $form = $formFactory->createBuilder()
27-
* ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
28-
* ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
29-
* ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType')
30-
* ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
31-
* 'choices' => array('Male' => 'm', 'Female' => 'f'),
32-
* 'choices_as_values' => true,
33-
* ))
34-
* ->getForm();
35-
* </code>
21+
* use Symfony\Component\Form\Forms;
22+
*
23+
* $formFactory = Forms::createFormFactory();
24+
*
25+
* $form = $formFactory->createBuilder()
26+
* ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
27+
* ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
28+
* ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType')
29+
* ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
30+
* 'choices' => array('Male' => 'm', 'Female' => 'f'),
31+
* 'choices_as_values' => true,
32+
* ))
33+
* ->getForm();
3634
*
3735
* You can also add custom extensions to the form factory:
3836
*
39-
* <code>
40-
* $formFactory = Forms::createFormFactoryBuilder()
41-
* ->addExtension(new AcmeExtension())
42-
* ->getFormFactory();
43-
* </code>
37+
* $formFactory = Forms::createFormFactoryBuilder()
38+
* ->addExtension(new AcmeExtension())
39+
* ->getFormFactory();
4440
*
4541
* If you create custom form types or type extensions, it is
4642
* generally recommended to create your own extensions that lazily
4743
* load these types and type extensions. In projects where performance
4844
* does not matter that much, you can also pass them directly to the
4945
* form factory:
5046
*
51-
* <code>
52-
* $formFactory = Forms::createFormFactoryBuilder()
53-
* ->addType(new PersonType())
54-
* ->addType(new PhoneNumberType())
55-
* ->addTypeExtension(new FormTypeHelpTextExtension())
56-
* ->getFormFactory();
57-
* </code>
47+
* $formFactory = Forms::createFormFactoryBuilder()
48+
* ->addType(new PersonType())
49+
* ->addType(new PhoneNumberType())
50+
* ->addTypeExtension(new FormTypeHelpTextExtension())
51+
* ->getFormFactory();
5852
*
5953
* Support for the Validator component is provided by ValidatorExtension.
6054
* This extension needs a validator object to function properly:
6155
*
62-
* <code>
63-
* use Symfony\Component\Validator\Validation;
64-
* use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
56+
* use Symfony\Component\Validator\Validation;
57+
* use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
6558
*
66-
* $validator = Validation::createValidator();
67-
* $formFactory = Forms::createFormFactoryBuilder()
68-
* ->addExtension(new ValidatorExtension($validator))
69-
* ->getFormFactory();
70-
* </code>
59+
* $validator = Validation::createValidator();
60+
* $formFactory = Forms::createFormFactoryBuilder()
61+
* ->addExtension(new ValidatorExtension($validator))
62+
* ->getFormFactory();
7163
*
7264
* Support for the Templating component is provided by TemplatingExtension.
7365
* This extension needs a PhpEngine object for rendering forms. As second
7466
* argument you should pass the names of the default themes. Here is an
7567
* example for using the default layout with "<div>" tags:
7668
*
77-
* <code>
78-
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
69+
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
7970
*
80-
* $formFactory = Forms::createFormFactoryBuilder()
81-
* ->addExtension(new TemplatingExtension($engine, null, array(
82-
* 'FrameworkBundle:Form',
83-
* )))
84-
* ->getFormFactory();
85-
* </code>
71+
* $formFactory = Forms::createFormFactoryBuilder()
72+
* ->addExtension(new TemplatingExtension($engine, null, array(
73+
* 'FrameworkBundle:Form',
74+
* )))
75+
* ->getFormFactory();
8676
*
8777
* The next example shows how to include the "<table>" layout:
8878
*
89-
* <code>
90-
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
79+
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
9180
*
92-
* $formFactory = Forms::createFormFactoryBuilder()
93-
* ->addExtension(new TemplatingExtension($engine, null, array(
94-
* 'FrameworkBundle:Form',
95-
* 'FrameworkBundle:FormTable',
96-
* )))
97-
* ->getFormFactory();
98-
* </code>
81+
* $formFactory = Forms::createFormFactoryBuilder()
82+
* ->addExtension(new TemplatingExtension($engine, null, array(
83+
* 'FrameworkBundle:Form',
84+
* 'FrameworkBundle:FormTable',
85+
* )))
86+
* ->getFormFactory();
9987
*
10088
* @author Bernhard Schussek <[email protected]>
10189
*/

0 commit comments

Comments
 (0)