Skip to content

fixed cs of php parts #1497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ Without even thinking about Doctrine or databases, you already know that
you need a ``Product`` object to represent those products. Create this class
inside the ``Entity`` directory of your ``AcmeStoreBundle``::

// src/Acme/StoreBundle/Entity/Product.php
// src/Acme/StoreBundle/Entity/Product.php

namespace Acme\StoreBundle\Entity;

class Product
Expand Down Expand Up @@ -369,7 +370,7 @@ of the bundle:
use Acme\StoreBundle\Entity\Product;
use Symfony\Component\HttpFoundation\Response;
// ...

public function createAction()
{
$product = new Product();
Expand Down Expand Up @@ -733,6 +734,7 @@ ordered alphabetically.
.. code-block:: php

// src/Acme/StoreBundle/Repository/ProductRepository.php

namespace Acme\StoreBundle\Repository;

use Doctrine\ORM\EntityRepository;
Expand Down Expand Up @@ -1058,7 +1060,7 @@ can avoid the second query by issuing a join in the original query. Add the
following method to the ``ProductRepository`` class::

// src/Acme/StoreBundle/Repository/ProductRepository.php

public function findOneByIdJoinedToCategory($id)
{
$query = $this->getManager()
Expand All @@ -1067,7 +1069,7 @@ following method to the ``ProductRepository`` class::
JOIN p.category c
WHERE p.id = :id'
)->setParameter('id', $id);

try {
return $query->getSingleResult();
} catch (\Doctrine\ORM\NoResultException $e) {
Expand Down
4 changes: 4 additions & 0 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ going to need to build a form. But before you begin, first focus on the generic
.. code-block:: php

// src/Acme/TaskBundle/Entity/Task.php

namespace Acme\TaskBundle\Entity;

class Task
Expand Down Expand Up @@ -85,6 +86,7 @@ object and then rendering it in a template. For now, this can all be done
from inside a controller::

// src/Acme/TaskBundle/Controller/DefaultController.php

namespace Acme\TaskBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -939,6 +941,7 @@ Suppose that each ``Task`` belongs to a simple ``Category`` object. Start,
of course, by creating the ``Category`` object::

// src/Acme/TaskBundle/Entity/Category.php

namespace Acme\TaskBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -981,6 +984,7 @@ Now that your application has been updated to reflect the new requirements,
create a form class so that a ``Category`` object can be modified by the user::

// src/Acme/TaskBundle/Form/Type/CategoryType.php

namespace Acme\TaskBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
Expand Down
5 changes: 3 additions & 2 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ called ``Acme\HelloBundle\Controller\Hello``. Start by creating this file
inside your ``AcmeHelloBundle``::

// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
namespace Acme\HelloBundle\Controller;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be reverted, because it is used in the next code block (and this code is included there because of the ...).

Or, maybe better, place this line in the next code block. I think that's the best option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wouterj done thank you ;)

class HelloController
{
Expand Down Expand Up @@ -282,6 +281,7 @@ of writing the HTML inside the controller, render a template instead:
:linenos:

// src/Acme/HelloBundle/Controller/HelloController.php

namespace Acme\HelloBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -625,6 +625,7 @@ Start by creating a ``src/Acme/TestBundle/`` directory and adding a new file
called ``AcmeTestBundle.php``::

// src/Acme/TestBundle/AcmeTestBundle.php

namespace Acme\TestBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand Down
1 change: 1 addition & 0 deletions book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ be stored in the database.
.. code-block:: php

// src/Acme/UserBundle/Entity/User.php

namespace Acme\UserBundle\Entity;

use Symfony\Component\Security\Core\User\UserInterface;
Expand Down
5 changes: 4 additions & 1 deletion book/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ unit tests. Suppose, for example, that you have an *incredibly* simple class
called ``Calculator`` in the ``Utility/`` directory of your bundle::

// src/Acme/DemoBundle/Utility/Calculator.php

namespace Acme\DemoBundle\Utility;

class Calculator
{
public function add($a, $b)
Expand All @@ -66,6 +67,7 @@ To test this, create a ``CalculatorTest`` file in the ``Tests/Utility`` director
of your bundle::

// src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php

namespace Acme\DemoBundle\Tests\Utility;

use Acme\DemoBundle\Utility\Calculator;
Expand Down Expand Up @@ -133,6 +135,7 @@ For example, the Symfony2 Standard Edition provides a simple functional test
for its ``DemoController`` (`DemoControllerTest`_) that reads as follows::

// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php

namespace Acme\DemoBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
Expand Down
1 change: 1 addition & 0 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ your application:
.. code-block:: php

// src/Acme/BlogBundle/Entity/Author.php

namespace Acme\BlogBundle\Entity;

class Author
Expand Down
1 change: 1 addition & 0 deletions book/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ your application:
.. code-block:: php

// src/Acme/BlogBundle/Entity/Author.php

namespace Acme\BlogBundle\Entity;

class Author
Expand Down
2 changes: 2 additions & 0 deletions cookbook/bundles/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ To take advantage of this system, you'll create a ``Configuration`` class
and build a tree that defines your configuration in that class::

// src/Acme/HelloBundle/DependencyInjection/Configuration.php

namespace Acme\HelloBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down Expand Up @@ -501,6 +502,7 @@ Comments and examples can be added to your configuration nodes using the
``->setInfo()`` and ``->setExample()`` methods::

// src/Acme/HelloBundle/DependencyExtension/Configuration.php

namespace Acme\HelloBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down
6 changes: 4 additions & 2 deletions cookbook/bundles/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ where you want the overridden files to live. Start by registering the ``FOSUserB
as the "parent" of your bundle::

// src/Acme/UserBundle/AcmeUserBundle.php

namespace Acme\UserBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand All @@ -41,6 +42,7 @@ just create your own ``RegistrationController.php`` file, override the bundle's
original method, and change its functionality::

// src/Acme/UserBundle/Controller/RegistrationController.php

namespace Acme\UserBundle\Controller;

use FOS\UserBundle\Controller\RegistrationController as BaseController;
Expand All @@ -50,9 +52,9 @@ original method, and change its functionality::
public function registerAction()
{
$response = parent::registerAction();

// do custom stuff

return $response;
}
}
Expand Down
1 change: 1 addition & 0 deletions cookbook/console/console_command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Edition) to greet us from the command line, create ``GreetCommand.php`` and
add the following to it::

// src/Acme/DemoBundle/Command/GreetCommand.php

namespace Acme\DemoBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
Expand Down
7 changes: 4 additions & 3 deletions cookbook/doctrine/event_listeners_subscribers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,19 @@ listener on the event ``postPersist``. That class behind that service must have
a ``postPersist`` method, which will be called when the event is thrown::

// src/Acme/SearchBundle/Listener/SearchIndexer.php

namespace Acme\SearchBundle\Listener;

use Doctrine\ORM\Event\LifecycleEventArgs;
use Acme\StoreBundle\Entity\Product;

class SearchIndexer
{
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
$entityManager = $args->getEntityManager();

// perhaps you only want to act on some "Product" entity
if ($entity instanceof Product) {
// do something with the Product
Expand Down
1 change: 1 addition & 0 deletions cookbook/doctrine/file_uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Basic Setup
First, create a simple Doctrine Entity class to work with::

// src/Acme/DemoBundle/Entity/Document.php

namespace Acme\DemoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
1 change: 1 addition & 0 deletions cookbook/doctrine/reverse_engineering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ The newly created ``BlogComment`` entity class looks as follow:
<?php

// src/Acme/BlogBundle/Entity/BlogComment.php

namespace Acme\BlogBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
4 changes: 3 additions & 1 deletion cookbook/form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ You can now use your custom field type immediately, simply by creating a
new instance of the type in one of your forms::

// src/Acme/DemoBundle/Form/Type/AuthorType.php

namespace Acme\DemoBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class AuthorType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
Expand Down Expand Up @@ -262,6 +263,7 @@ registered as a service. And because we used the ``form.type`` alias in its
configuration, using the field is now much easier::

// src/Acme/DemoBundle/Form/Type/AuthorType.php

namespace Acme\DemoBundle\Form\Type;

use Symfony\Component\Form\FormBuilderInterface;
Expand Down
4 changes: 2 additions & 2 deletions cookbook/form/data_transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ will enter the issue number. The field will display an error if a non existing n
was entered::

// src/Acme/TaskBundle/Form/Type/IssueSelectorType.php

namespace Acme\TaskBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Acme\TaskBundle\Form\DataTransformer\IssueToNumberTransformer;
use Doctrine\Common\Persistence\ObjectManager;

Expand Down Expand Up @@ -137,7 +137,7 @@ Next, we create the data transformer, which does the actual conversion::
/**
* Transforms a string (number) to an object (issue).
*
* @param string $number
* @param string $number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a standard, you need to align all variable names and there description, but not the variable name and a description of another item without a variable name (e.g. @throws)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

php cs fixer was used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this seems odd - what if $number has a description? Then it wouldn't line up with the description of the @throws or the Issue (if it had one).

I can't really argue with the phpcs, but this one almost feels wrong :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weaverryan reverted ;)

* @return Issue|null
* @throws TransformationFailedException if object (issue) is not found.
*/
Expand Down
13 changes: 7 additions & 6 deletions cookbook/form/dynamic_form_generation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ is new (e.g. hasn't been persisted to the database). Based on that, the subscrib
might look like the following::

// src/Acme/DemoBundle/Form/EventListener/AddNameFieldSubscriber.php

namespace Acme\DemoBundle\Form\EventListener;

use Symfony\Component\Form\Event\DataEvent;
Expand All @@ -99,12 +100,12 @@ might look like the following::
class AddNameFieldSubscriber implements EventSubscriberInterface
{
private $factory;

public function __construct(FormFactoryInterface $factory)
{
$this->factory = $factory;
}

public static function getSubscribedEvents()
{
// Tells the dispatcher that we want to listen on the form.pre_set_data
Expand All @@ -116,11 +117,11 @@ might look like the following::
{
$data = $event->getData();
$form = $event->getForm();
// During form creation setData() is called with null as an argument
// by the FormBuilder constructor. We're only concerned with when

// During form creation setData() is called with null as an argument
// by the FormBuilder constructor. We're only concerned with when
// setData is called with an actual Entity object in it (whether new,
// or fetched with Doctrine). This if statement let's us skip right
// or fetched with Doctrine). This if statement let's us skip right
// over the null condition.
if (null === $data) {
return;
Expand Down
Loading