Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  [#6597] some tweaks
  [Validator] Add shorter examples using the default option
  Typo fix
  Updated the CS rule about return null; and return;
  Update date.rst - Fixes typo
  NullOutput should be passed to $command->run()
  Hard values for the driver option
  • Loading branch information
xabbuh committed Jun 30, 2016
2 parents 7d3bd81 + 04edf66 commit 9a8b380
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 33 deletions.
7 changes: 3 additions & 4 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ information. By convention, this information is usually configured in an
# app/config/parameters.yml
parameters:
database_driver: pdo_mysql
database_host: localhost
database_name: test_project
database_user: root
Expand All @@ -64,7 +63,7 @@ information. By convention, this information is usually configured in an
# app/config/config.yml
doctrine:
dbal:
driver: '%database_driver%'
driver: pdo_mysql
host: '%database_host%'
dbname: '%database_name%'
user: '%database_user%'
Expand All @@ -84,7 +83,7 @@ information. By convention, this information is usually configured in an
<doctrine:config>
<doctrine:dbal
driver="%database_driver%"
driver="pdo_mysql"
host="%database_host%"
dbname="%database_name%"
user="%database_user%"
Expand All @@ -97,7 +96,7 @@ information. By convention, this information is usually configured in an
// app/config/config.php
$configuration->loadFromExtension('doctrine', array(
'dbal' => array(
'driver' => '%database_driver%',
'driver' => 'pdo_mysql',
'host' => '%database_host%',
'dbname' => '%database_name%',
'user' => '%database_user%',
Expand Down
2 changes: 1 addition & 1 deletion components/console/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ returns the returned code from the command (return value from command's

If you want to suppress the output of the executed command, pass a
:class:`Symfony\\Component\\Console\\Output\\NullOutput` as the second
argument to ``$command->execute()``.
argument to ``$command->run()``.

.. caution::

Expand Down
8 changes: 4 additions & 4 deletions contributing/code/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ example containing most features described below:
);

if (true === $dummy) {
return;
return null;
}

if ('string' === $dummy) {
Expand All @@ -109,7 +109,7 @@ example containing most features described below:
* @param mixed $value Some value to check against
* @param bool $theSwitch Some switch to control the method's flow
*
* @return bool|null The resultant check if $theSwitch isn't false, null otherwise
* @return bool|void The resultant check if $theSwitch isn't false, void otherwise
*/
private function reverseBoolean($value = null, $theSwitch = false)
{
Expand Down Expand Up @@ -143,8 +143,8 @@ Structure
* Add a blank line before ``return`` statements, unless the return is alone
inside a statement-group (like an ``if`` statement);

* Use just ``return;`` instead of ``return null;`` when a function must return
void early;
* Use ``return null;`` when a function explicitly returns ``null`` values and
use ``return;`` when the function returns ``void`` values;

* Use braces to indicate control structure body regardless of the number of
statements it contains;
Expand Down
12 changes: 6 additions & 6 deletions cookbook/doctrine/multiple_entity_managers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ The following configuration code shows how you can configure two entity managers
default_connection: default
connections:
default:
driver: '%database_driver%'
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
customer:
driver: '%database_driver2%'
driver: pdo_mysql
host: '%database_host2%'
port: '%database_port2%'
dbname: '%database_name2%'
Expand Down Expand Up @@ -68,7 +68,7 @@ The following configuration code shows how you can configure two entity managers
<config>
<dbal default-connection="default">
<connection name="default"
driver="%database_driver%"
driver="pdo_mysql"
host="%database_host%"
port="%database_port%"
dbname="%database_name%"
Expand All @@ -78,7 +78,7 @@ The following configuration code shows how you can configure two entity managers
/>
<connection name="customer"
driver="%database_driver2%"
driver="pdo_mysql"
host="%database_host2%"
port="%database_port2%"
dbname="%database_name2%"
Expand Down Expand Up @@ -108,7 +108,7 @@ The following configuration code shows how you can configure two entity managers
'default_connection' => 'default',
'connections' => array(
'default' => array(
'driver' => '%database_driver%',
'driver' => 'pdo_mysql',
'host' => '%database_host%',
'port' => '%database_port%',
'dbname' => '%database_name%',
Expand All @@ -117,7 +117,7 @@ The following configuration code shows how you can configure two entity managers
'charset' => 'UTF8',
),
'customer' => array(
'driver' => '%database_driver2%',
'driver' => 'pdo_mysql',
'host' => '%database_host2%',
'port' => '%database_port2%',
'dbname' => '%database_name2%',
Expand Down
2 changes: 1 addition & 1 deletion cookbook/session/php_bridge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you're integrating the Symfony full-stack Framework into a legacy application
that starts the session with ``session_start()``, you may still be able to
use Symfony's session management by using the PHP Bridge session.

If the application has sets it's own PHP save handler, you can specify null
If the application has it's own PHP save handler, you can specify null
for the ``handler_id``:

.. configuration-block::
Expand Down
18 changes: 18 additions & 0 deletions reference/constraints/Choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ If your valid choice list is simple, you can pass them in directly via the
class Author
{
/**
* @Assert\Choice({"New York", "Berlin", "Tokyo"})
*/
protected $city;
/**
* @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.")
*/
Expand All @@ -57,6 +62,7 @@ If your valid choice list is simple, you can pass them in directly via the
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Author:
properties:
city: [New York, Berlin, Tokyo]
gender:
- Choice:
choices: [male, female]
Expand All @@ -71,6 +77,13 @@ If your valid choice list is simple, you can pass them in directly via the
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="AppBundle\Entity\Author">
<property name="city">
<constraint name="Choice">
<value>New York</value>
<value>Berlin</value>
<value>Tokyo</value>
</constraint>
</property>
<property name="gender">
<constraint name="Choice">
<option name="choices">
Expand All @@ -97,6 +110,11 @@ If your valid choice list is simple, you can pass them in directly via the
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint(
'gender',
new Assert\Choice(array('New York', 'Berlin', 'Tokyo'))
);
$metadata->addPropertyConstraint('gender', new Assert\Choice(array(
'choices' => array('male', 'female'),
'message' => 'Choose a valid gender.',
Expand Down
18 changes: 16 additions & 2 deletions reference/constraints/EqualTo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ To force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualT
Basic Usage
-----------

If you want to ensure that the ``age`` of a ``Person`` class is equal to
``20``, you could do the following:
If you want to ensure that the ``firstName`` of a ``Person`` class is equal to ``Mary``
and that the ``age`` is ``20``, you could do the following:

.. configuration-block::

Expand All @@ -42,6 +42,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
class Person
{
/**
* @Assert\EqualTo("Mary")
*/
protected $firstName;
/**
* @Assert\EqualTo(
* value = 20
Expand All @@ -55,6 +60,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Person:
properties:
firstName:
- EqualTo: Mary
age:
- EqualTo:
value: 20
Expand All @@ -68,6 +75,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="AppBundle\Entity\Person">
<property name="firstName">
<constraint name="EqualTo">
<value>Mary</value>
</constraint>
</property>
<property name="age">
<constraint name="EqualTo">
<option name="value">20</option>
Expand All @@ -88,6 +100,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('firstName', new Assert\EqualTo('Mary'));
$metadata->addPropertyConstraint('age', new Assert\EqualTo(array(
'value' => 20,
)));
Expand Down
21 changes: 19 additions & 2 deletions reference/constraints/GreaterThan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ than another value, see :doc:`/reference/constraints/LessThan`.
Basic Usage
-----------

If you want to ensure that the ``age`` of a ``Person`` class is greater than
``18``, you could do the following:
The following constraints ensure that:

* the number of ``siblings`` of a ``Person`` is greater than ``5``
* the ``age`` of a ``Person`` class is greater than ``18``

.. configuration-block::

Expand All @@ -38,6 +40,12 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
class Person
{
/**
* @Assert\GreaterThan(5)
*/
protected $siblings;
/**
* @Assert\GreaterThan(
* value = 18
Expand All @@ -51,6 +59,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Person:
properties:
siblings:
- GreaterThan: 5
age:
- GreaterThan:
value: 18
Expand All @@ -64,6 +74,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="AppBundle\Entity\Person">
<property name="siblings">
<constraint name="GreaterThan">
<value>5</value>
</constraint>
</property>
<property name="age">
<constraint name="GreaterThan">
<option name="value">18</option>
Expand All @@ -84,6 +99,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('siblings', new Assert\GreaterThan(5));
$metadata->addPropertyConstraint('age', new Assert\GreaterThan(array(
'value' => 18,
)));
Expand Down
20 changes: 18 additions & 2 deletions reference/constraints/GreaterThanOrEqual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ the options. To force that a value is greater than another value, see
Basic Usage
-----------

If you want to ensure that the ``age`` of a ``Person`` class is greater than
or equal to ``18``, you could do the following:
The following constraints ensure that:

* the number of ``siblings`` of a ``Person`` is greater than or equal to ``5``
* the ``age`` of a ``Person`` class is greater than or equal to ``18``

.. configuration-block::

Expand All @@ -37,6 +39,11 @@ or equal to ``18``, you could do the following:
class Person
{
/**
* @Assert\GreaterThanOrEqual(5)
*/
protected $siblings;
/**
* @Assert\GreaterThanOrEqual(
* value = 18
Expand All @@ -50,6 +57,8 @@ or equal to ``18``, you could do the following:
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Person:
properties:
siblings:
- GreaterThanOrEqual: 5
age:
- GreaterThanOrEqual:
value: 18
Expand All @@ -63,6 +72,11 @@ or equal to ``18``, you could do the following:
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="AppBundle\Entity\Person">
<property name="siblings">
<constraint name="GreaterThanOrEqual">
<value>5</value>
</constraint>
</property>
<property name="age">
<constraint name="GreaterThanOrEqual">
<option name="value">18</option>
Expand All @@ -83,6 +97,8 @@ or equal to ``18``, you could do the following:
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('siblings', new Assert\GreaterThanOrEqual(5));
$metadata->addPropertyConstraint('age', new Assert\GreaterThanOrEqual(array(
'value' => 18,
)));
Expand Down
11 changes: 9 additions & 2 deletions reference/constraints/IdenticalTo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ To force that a value is *not* identical, see
Basic Usage
-----------

If you want to ensure that the ``age`` of a ``Person`` class is equal to
``20`` and an integer, you could do the following:
The following constraints ensure that:

* ``firstName`` of ``Person` class is equal to ``Mary`` *and* is a string
* ``age`` is equal to``20`` *and* is of type integer

.. configuration-block::

Expand All @@ -43,6 +45,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
class Person
{
/**
* @Assert\IdenticalTo("Mary")
*/
protected $firstName;
/**
* @Assert\IdenticalTo(
* value = 20
Expand Down
Loading

0 comments on commit 9a8b380

Please sign in to comment.