Skip to content

Commit 97294e0

Browse files
committed
Merge pull request #1534 from brikou/fix_phpcode_20
fixed php code against 2.0 branch
2 parents ba6e94e + 05cd9f5 commit 97294e0

20 files changed

+49
-59
lines changed

book/controller.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ a controller object. Controllers are also called *actions*.
9494
:linenos:
9595
9696
// src/Acme/HelloBundle/Controller/HelloController.php
97-
9897
namespace Acme\HelloBundle\Controller;
98+
9999
use Symfony\Component\HttpFoundation\Response;
100100
101101
class HelloController
@@ -208,8 +208,8 @@ passed to that method:
208208
209209
<?php
210210
// src/Acme/HelloBundle/Controller/HelloController.php
211-
212211
namespace Acme\HelloBundle\Controller;
212+
213213
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
214214
215215
class HelloController extends Controller
@@ -349,8 +349,8 @@ Add the ``use`` statement atop the ``Controller`` class and then modify the
349349
.. code-block:: php
350350
351351
// src/Acme/HelloBundle/Controller/HelloController.php
352-
353352
namespace Acme\HelloBundle\Controller;
353+
354354
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
355355
use Symfony\Component\HttpFoundation\Response;
356356

book/doctrine.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Without even thinking about Doctrine or databases, you already know that
9393
you need a ``Product`` object to represent those products. Create this class
9494
inside the ``Entity`` directory of your ``AcmeStoreBundle``::
9595

96-
// src/Acme/StoreBundle/Entity/Product.php
96+
// src/Acme/StoreBundle/Entity/Product.php
9797
namespace Acme\StoreBundle\Entity;
9898

9999
class Product
@@ -369,7 +369,7 @@ of the bundle:
369369
use Acme\StoreBundle\Entity\Product;
370370
use Symfony\Component\HttpFoundation\Response;
371371
// ...
372-
372+
373373
public function createAction()
374374
{
375375
$product = new Product();
@@ -1058,7 +1058,7 @@ can avoid the second query by issuing a join in the original query. Add the
10581058
following method to the ``ProductRepository`` class::
10591059

10601060
// src/Acme/StoreBundle/Repository/ProductRepository.php
1061-
1061+
10621062
public function findOneByIdJoinedToCategory($id)
10631063
{
10641064
$query = $this->getEntityManager()
@@ -1067,7 +1067,7 @@ following method to the ``ProductRepository`` class::
10671067
JOIN p.category c
10681068
WHERE p.id = :id'
10691069
)->setParameter('id', $id);
1070-
1070+
10711071
try {
10721072
return $query->getSingleResult();
10731073
} catch (\Doctrine\ORM\NoResultException $e) {

book/forms.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ that will house the logic for building the task form:
754754
.. code-block:: php
755755
756756
// src/Acme/TaskBundle/Form/Type/TaskType.php
757-
758757
namespace Acme\TaskBundle\Form\Type;
759758
760759
use Symfony\Component\Form\AbstractType;

book/from_flat_php_to_symfony2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ them for you. Here's the same sample application, now built in Symfony2:
543543

544544
<?php
545545
// src/Acme/BlogBundle/Controller/BlogController.php
546-
547546
namespace Acme\BlogBundle\Controller;
547+
548548
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
549549

550550
class BlogController extends Controller

book/page_creation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ greeted. To create the page, follow the simple two-step process.
4848
``web`` directory of your new Symfony2 project. For detailed information
4949
on this process, see the documentation on the web server you are using.
5050
Here's the relevant documentation page for some web server you might be using:
51-
51+
5252
* For Apache HTTP Server, refer to `Apache's DirectoryIndex documentation`_.
5353
* For Nginx, refer to `Nginx HttpCoreModule location documentation`_.
5454

@@ -209,8 +209,6 @@ inside your ``AcmeHelloBundle``::
209209
// src/Acme/HelloBundle/Controller/HelloController.php
210210
namespace Acme\HelloBundle\Controller;
211211

212-
use Symfony\Component\HttpFoundation\Response;
213-
214212
class HelloController
215213
{
216214
}
@@ -225,8 +223,10 @@ Create the ``indexAction`` method that Symfony will execute when the ``hello``
225223
route is matched::
226224

227225
// src/Acme/HelloBundle/Controller/HelloController.php
226+
namespace Acme\HelloBundle\Controller;
227+
228+
use Symfony\Component\HttpFoundation\Response;
228229

229-
// ...
230230
class HelloController
231231
{
232232
public function indexAction($name)

book/routing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pattern that points to a specific PHP class and method:
8080
.. code-block:: php
8181
8282
// src/Acme/BlogBundle/Controller/BlogController.php
83-
8483
namespace Acme\BlogBundle\Controller;
84+
8585
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8686
8787
class BlogController extends Controller
@@ -815,8 +815,8 @@ The controller might look like this:
815815
.. code-block:: php
816816
817817
// src/Acme/BlogBundle/Controller/BlogController.php
818-
819818
namespace Acme\BlogBundle\Controller;
819+
820820
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
821821
822822
class BlogController extends Controller

book/testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ called ``Calculator`` in the ``Utility/`` directory of your bundle::
5252

5353
// src/Acme/DemoBundle/Utility/Calculator.php
5454
namespace Acme\DemoBundle\Utility;
55-
55+
5656
class Calculator
5757
{
5858
public function add($a, $b)

cookbook/bundles/inheritance.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ original method, and change its functionality::
5050
public function registerAction()
5151
{
5252
$response = parent::registerAction();
53-
53+
5454
// do custom stuff
55-
55+
5656
return $response;
5757
}
5858
}

cookbook/doctrine/event_listeners_subscribers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ a ``postPersist`` method, which will be called when the event is thrown::
8686

8787
// src/Acme/SearchBundle/Listener/SearchIndexer.php
8888
namespace Acme\SearchBundle\Listener;
89-
89+
9090
use Doctrine\ORM\Event\LifecycleEventArgs;
9191
use Acme\StoreBundle\Entity\Product;
92-
92+
9393
class SearchIndexer
9494
{
9595
public function postPersist(LifecycleEventArgs $args)
9696
{
9797
$entity = $args->getEntity();
9898
$entityManager = $args->getEntityManager();
99-
99+
100100
// perhaps you only want to act on some "Product" entity
101101
if ($entity instanceof Product) {
102102
// do something with the Product

cookbook/form/create_custom_field_type.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ will be called `GenderType` and the file will be stored in the default location
2020
for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extends
2121
:class:`Symfony\\Component\\Form\\AbstractType`::
2222

23-
# src/Acme/DemoBundle/Form/Type/GenderType.php
23+
// src/Acme/DemoBundle/Form/Type/GenderType.php
2424
namespace Acme\DemoBundle\Form\Type;
2525

2626
use Symfony\Component\Form\AbstractType;
@@ -153,7 +153,7 @@ new instance of the type in one of your forms::
153153

154154
use Symfony\Component\Form\AbstractType;
155155
use Symfony\Component\Form\FormBuilder;
156-
156+
157157
class AuthorType extends AbstractType
158158
{
159159
public function buildForm(FormBuilder $builder, array $options)
@@ -231,7 +231,7 @@ returned by the ``getName`` method defined earlier. We'll see the importance
231231
of this in a moment when we use the custom field type. But first, add a ``__construct``
232232
argument to ``GenderType``, which receives the gender configuration::
233233

234-
# src/Acme/DemoBundle/Form/Type/GenderType.php
234+
// src/Acme/DemoBundle/Form/Type/GenderType.php
235235
namespace Acme\DemoBundle\Form\Type;
236236
// ...
237237

cookbook/form/data_transformers.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ manager can be automatically injected:
193193
You can now add the type to your form by its alias as follows::
194194

195195
// src/Acme/TaskBundle/Form/Type/TaskType.php
196-
197196
namespace Acme\TaskBundle\Form\Type;
198197

199198
use Symfony\Component\Form\AbstractType;

cookbook/form/dynamic_form_generation.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ might look like the following::
9999
class AddNameFieldSubscriber implements EventSubscriberInterface
100100
{
101101
private $factory;
102-
102+
103103
public function __construct(FormFactoryInterface $factory)
104104
{
105105
$this->factory = $factory;
106106
}
107-
107+
108108
public static function getSubscribedEvents()
109109
{
110110
// Tells the dispatcher that we want to listen on the form.pre_set_data
@@ -116,11 +116,11 @@ might look like the following::
116116
{
117117
$data = $event->getData();
118118
$form = $event->getForm();
119-
120-
// During form creation setData() is called with null as an argument
121-
// by the FormBuilder constructor. We're only concerned with when
119+
120+
// During form creation setData() is called with null as an argument
121+
// by the FormBuilder constructor. We're only concerned with when
122122
// setData is called with an actual Entity object in it (whether new,
123-
// or fetched with Doctrine). This if statement let's us skip right
123+
// or fetched with Doctrine). This if statement let's us skip right
124124
// over the null condition.
125125
if (null === $data) {
126126
return;

cookbook/form/form_collections.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ objects. Start by creating a simple ``Task`` class::
2424

2525
// src/Acme/TaskBundle/Entity/Task.php
2626
namespace Acme\TaskBundle\Entity;
27-
27+
2828
use Doctrine\Common\Collections\ArrayCollection;
2929

3030
class Task
@@ -37,7 +37,7 @@ objects. Start by creating a simple ``Task`` class::
3737
{
3838
$this->tags = new ArrayCollection();
3939
}
40-
40+
4141
public function getDescription()
4242
{
4343
return $this->description;
@@ -149,13 +149,13 @@ In your controller, you'll now initialize a new instance of ``TaskType``::
149149

150150
// src/Acme/TaskBundle/Controller/TaskController.php
151151
namespace Acme\TaskBundle\Controller;
152-
152+
153153
use Acme\TaskBundle\Entity\Task;
154154
use Acme\TaskBundle\Entity\Tag;
155155
use Acme\TaskBundle\Form\Type\TaskType;
156156
use Symfony\Component\HttpFoundation\Request;
157157
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
158-
158+
159159
class TaskController extends Controller
160160
{
161161
public function newAction(Request $request)
@@ -171,17 +171,17 @@ In your controller, you'll now initialize a new instance of ``TaskType``::
171171
$tag2->name = 'tag2';
172172
$task->getTags()->add($tag2);
173173
// end dummy code
174-
174+
175175
$form = $this->createForm(new TaskType(), $task);
176-
176+
177177
// process the form on POST
178178
if ('POST' === $request->getMethod()) {
179179
$form->bindRequest($request);
180180
if ($form->isValid()) {
181181
// maybe do some form processing, like saving the Task and Tag objects
182182
}
183183
}
184-
184+
185185
return $this->render('AcmeTaskBundle:Task:new.html.twig', array(
186186
'form' => $form->createView(),
187187
));
@@ -280,7 +280,7 @@ add the ``allow_add`` option to our collection field::
280280

281281
// src/Acme/TaskBundle/Form/Type/TaskType.php
282282
// ...
283-
283+
284284
public function buildForm(FormBuilder $builder, array $options)
285285
{
286286
$builder->add('description');
@@ -491,7 +491,7 @@ Start by adding the ``allow_delete`` option in the form Type::
491491
492492
// src/Acme/TaskBundle/Form/Type/TaskType.php
493493
// ...
494-
494+
495495
public function buildForm(FormBuilder $builder, array $options)
496496
{
497497
$builder->add('description');

cookbook/form/use_virtuals_forms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ For example, imagine you have two entities, a ``Company`` and a ``Customer``::
2525

2626
.. code-block:: php
2727
28-
// src/Acme/HelloBundle/Entity/Company.php
28+
// src/Acme/HelloBundle/Entity/Customer.php
2929
namespace Acme\HelloBundle\Entity;
3030
3131
class Customer

cookbook/security/custom_authentication_provider.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ provider.
6161
public $created;
6262
public $digest;
6363
public $nonce;
64-
64+
6565
public function __construct(array $roles = array())
6666
{
6767
parent::__construct($roles);
68-
68+
6969
// If the user has roles, consider it authenticated
7070
$this->setAuthenticated(count($roles) > 0);
7171
}
@@ -141,7 +141,7 @@ set an authenticated token in the security context if successful.
141141
142142
if ($returnValue instanceof TokenInterface) {
143143
return $this->securityContext->setToken($returnValue);
144-
} else if ($returnValue instanceof Response) {
144+
} elseif ($returnValue instanceof Response) {
145145
return $event->setResponse($returnValue);
146146
}
147147
} catch (AuthenticationException $e) {
@@ -208,7 +208,7 @@ the ``PasswordDigest`` header value matches with the user's password.
208208
{
209209
$user = $this->userProvider->loadUserByUsername($token->getUsername());
210210
211-
if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) {
211+
if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) {
212212
$authenticatedToken = new WsseUserToken($user->getRoles());
213213
$authenticatedToken->setUser($user);
214214

cookbook/security/custom_provider.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class: ``getRoles()``, ``getPassword()``, ``getSalt()``, ``getUsername()``,
2727

2828
Let's see this in action::
2929

30-
// src/Acme/WebserviceUserBundle/Security/User.php
30+
// src/Acme/WebserviceUserBundle/Security/User/WebserviceUser.php
3131
namespace Acme\WebserviceUserBundle\Security\User;
3232

3333
use Symfony\Component\Security\Core\User\UserInterface;
@@ -65,7 +65,7 @@ Let's see this in action::
6565
public function getUsername()
6666
{
6767
return $this->username;
68-
}
68+
}
6969

7070
public function eraseCredentials()
7171
{

0 commit comments

Comments
 (0)