Skip to content

Commit 9a8b380

Browse files
committed
Merge branch '2.7' into 2.8
* 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
2 parents 7d3bd81 + 04edf66 commit 9a8b380

File tree

16 files changed

+186
-33
lines changed

16 files changed

+186
-33
lines changed

book/doctrine.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ information. By convention, this information is usually configured in an
4343
4444
# app/config/parameters.yml
4545
parameters:
46-
database_driver: pdo_mysql
4746
database_host: localhost
4847
database_name: test_project
4948
database_user: root
@@ -64,7 +63,7 @@ information. By convention, this information is usually configured in an
6463
# app/config/config.yml
6564
doctrine:
6665
dbal:
67-
driver: '%database_driver%'
66+
driver: pdo_mysql
6867
host: '%database_host%'
6968
dbname: '%database_name%'
7069
user: '%database_user%'
@@ -84,7 +83,7 @@ information. By convention, this information is usually configured in an
8483
8584
<doctrine:config>
8685
<doctrine:dbal
87-
driver="%database_driver%"
86+
driver="pdo_mysql"
8887
host="%database_host%"
8988
dbname="%database_name%"
9089
user="%database_user%"
@@ -97,7 +96,7 @@ information. By convention, this information is usually configured in an
9796
// app/config/config.php
9897
$configuration->loadFromExtension('doctrine', array(
9998
'dbal' => array(
100-
'driver' => '%database_driver%',
99+
'driver' => 'pdo_mysql',
101100
'host' => '%database_host%',
102101
'dbname' => '%database_name%',
103102
'user' => '%database_user%',

components/console/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ returns the returned code from the command (return value from command's
559559

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

564564
.. caution::
565565

contributing/code/standards.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ example containing most features described below:
9191
);
9292

9393
if (true === $dummy) {
94-
return;
94+
return null;
9595
}
9696

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

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

149149
* Use braces to indicate control structure body regardless of the number of
150150
statements it contains;

cookbook/doctrine/multiple_entity_managers.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ The following configuration code shows how you can configure two entity managers
2727
default_connection: default
2828
connections:
2929
default:
30-
driver: '%database_driver%'
30+
driver: pdo_mysql
3131
host: '%database_host%'
3232
port: '%database_port%'
3333
dbname: '%database_name%'
3434
user: '%database_user%'
3535
password: '%database_password%'
3636
charset: UTF8
3737
customer:
38-
driver: '%database_driver2%'
38+
driver: pdo_mysql
3939
host: '%database_host2%'
4040
port: '%database_port2%'
4141
dbname: '%database_name2%'
@@ -68,7 +68,7 @@ The following configuration code shows how you can configure two entity managers
6868
<config>
6969
<dbal default-connection="default">
7070
<connection name="default"
71-
driver="%database_driver%"
71+
driver="pdo_mysql"
7272
host="%database_host%"
7373
port="%database_port%"
7474
dbname="%database_name%"
@@ -78,7 +78,7 @@ The following configuration code shows how you can configure two entity managers
7878
/>
7979
8080
<connection name="customer"
81-
driver="%database_driver2%"
81+
driver="pdo_mysql"
8282
host="%database_host2%"
8383
port="%database_port2%"
8484
dbname="%database_name2%"
@@ -108,7 +108,7 @@ The following configuration code shows how you can configure two entity managers
108108
'default_connection' => 'default',
109109
'connections' => array(
110110
'default' => array(
111-
'driver' => '%database_driver%',
111+
'driver' => 'pdo_mysql',
112112
'host' => '%database_host%',
113113
'port' => '%database_port%',
114114
'dbname' => '%database_name%',
@@ -117,7 +117,7 @@ The following configuration code shows how you can configure two entity managers
117117
'charset' => 'UTF8',
118118
),
119119
'customer' => array(
120-
'driver' => '%database_driver2%',
120+
'driver' => 'pdo_mysql',
121121
'host' => '%database_host2%',
122122
'port' => '%database_port2%',
123123
'dbname' => '%database_name2%',

cookbook/session/php_bridge.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you're integrating the Symfony full-stack Framework into a legacy application
1111
that starts the session with ``session_start()``, you may still be able to
1212
use Symfony's session management by using the PHP Bridge session.
1313

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

1717
.. configuration-block::

reference/constraints/Choice.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ If your valid choice list is simple, you can pass them in directly via the
4646
4747
class Author
4848
{
49+
/**
50+
* @Assert\Choice({"New York", "Berlin", "Tokyo"})
51+
*/
52+
protected $city;
53+
4954
/**
5055
* @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.")
5156
*/
@@ -57,6 +62,7 @@ If your valid choice list is simple, you can pass them in directly via the
5762
# src/AppBundle/Resources/config/validation.yml
5863
AppBundle\Entity\Author:
5964
properties:
65+
city: [New York, Berlin, Tokyo]
6066
gender:
6167
- Choice:
6268
choices: [male, female]
@@ -71,6 +77,13 @@ If your valid choice list is simple, you can pass them in directly via the
7177
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
7278
7379
<class name="AppBundle\Entity\Author">
80+
<property name="city">
81+
<constraint name="Choice">
82+
<value>New York</value>
83+
<value>Berlin</value>
84+
<value>Tokyo</value>
85+
</constraint>
86+
</property>
7487
<property name="gender">
7588
<constraint name="Choice">
7689
<option name="choices">
@@ -97,6 +110,11 @@ If your valid choice list is simple, you can pass them in directly via the
97110
98111
public static function loadValidatorMetadata(ClassMetadata $metadata)
99112
{
113+
$metadata->addPropertyConstraint(
114+
'gender',
115+
new Assert\Choice(array('New York', 'Berlin', 'Tokyo'))
116+
);
117+
100118
$metadata->addPropertyConstraint('gender', new Assert\Choice(array(
101119
'choices' => array('male', 'female'),
102120
'message' => 'Choose a valid gender.',

reference/constraints/EqualTo.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ To force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualT
2828
Basic Usage
2929
-----------
3030

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

3434
.. configuration-block::
3535

@@ -42,6 +42,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
4242
4343
class Person
4444
{
45+
/**
46+
* @Assert\EqualTo("Mary")
47+
*/
48+
protected $firstName;
49+
4550
/**
4651
* @Assert\EqualTo(
4752
* value = 20
@@ -55,6 +60,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
5560
# src/AppBundle/Resources/config/validation.yml
5661
AppBundle\Entity\Person:
5762
properties:
63+
firstName:
64+
- EqualTo: Mary
5865
age:
5966
- EqualTo:
6067
value: 20
@@ -68,6 +75,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
6875
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6976
7077
<class name="AppBundle\Entity\Person">
78+
<property name="firstName">
79+
<constraint name="EqualTo">
80+
<value>Mary</value>
81+
</constraint>
82+
</property>
7183
<property name="age">
7284
<constraint name="EqualTo">
7385
<option name="value">20</option>
@@ -88,6 +100,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
88100
{
89101
public static function loadValidatorMetadata(ClassMetadata $metadata)
90102
{
103+
$metadata->addPropertyConstraint('firstName', new Assert\EqualTo('Mary'));
104+
91105
$metadata->addPropertyConstraint('age', new Assert\EqualTo(array(
92106
'value' => 20,
93107
)));

reference/constraints/GreaterThan.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ than another value, see :doc:`/reference/constraints/LessThan`.
2424
Basic Usage
2525
-----------
2626

27-
If you want to ensure that the ``age`` of a ``Person`` class is greater than
28-
``18``, you could do the following:
27+
The following constraints ensure that:
28+
29+
* the number of ``siblings`` of a ``Person`` is greater than ``5``
30+
* the ``age`` of a ``Person`` class is greater than ``18``
2931

3032
.. configuration-block::
3133

@@ -38,6 +40,12 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
3840
3941
class Person
4042
{
43+
44+
/**
45+
* @Assert\GreaterThan(5)
46+
*/
47+
protected $siblings;
48+
4149
/**
4250
* @Assert\GreaterThan(
4351
* value = 18
@@ -51,6 +59,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
5159
# src/AppBundle/Resources/config/validation.yml
5260
AppBundle\Entity\Person:
5361
properties:
62+
siblings:
63+
- GreaterThan: 5
5464
age:
5565
- GreaterThan:
5666
value: 18
@@ -64,6 +74,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
6474
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6575
6676
<class name="AppBundle\Entity\Person">
77+
<property name="siblings">
78+
<constraint name="GreaterThan">
79+
<value>5</value>
80+
</constraint>
81+
</property>
6782
<property name="age">
6883
<constraint name="GreaterThan">
6984
<option name="value">18</option>
@@ -84,6 +99,8 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than
8499
{
85100
public static function loadValidatorMetadata(ClassMetadata $metadata)
86101
{
102+
$metadata->addPropertyConstraint('siblings', new Assert\GreaterThan(5));
103+
87104
$metadata->addPropertyConstraint('age', new Assert\GreaterThan(array(
88105
'value' => 18,
89106
)));

reference/constraints/GreaterThanOrEqual.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ the options. To force that a value is greater than another value, see
2323
Basic Usage
2424
-----------
2525

26-
If you want to ensure that the ``age`` of a ``Person`` class is greater than
27-
or equal to ``18``, you could do the following:
26+
The following constraints ensure that:
27+
28+
* the number of ``siblings`` of a ``Person`` is greater than or equal to ``5``
29+
* the ``age`` of a ``Person`` class is greater than or equal to ``18``
2830

2931
.. configuration-block::
3032

@@ -37,6 +39,11 @@ or equal to ``18``, you could do the following:
3739
3840
class Person
3941
{
42+
/**
43+
* @Assert\GreaterThanOrEqual(5)
44+
*/
45+
protected $siblings;
46+
4047
/**
4148
* @Assert\GreaterThanOrEqual(
4249
* value = 18
@@ -50,6 +57,8 @@ or equal to ``18``, you could do the following:
5057
# src/AppBundle/Resources/config/validation.yml
5158
AppBundle\Entity\Person:
5259
properties:
60+
siblings:
61+
- GreaterThanOrEqual: 5
5362
age:
5463
- GreaterThanOrEqual:
5564
value: 18
@@ -63,6 +72,11 @@ or equal to ``18``, you could do the following:
6372
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6473
6574
<class name="AppBundle\Entity\Person">
75+
<property name="siblings">
76+
<constraint name="GreaterThanOrEqual">
77+
<value>5</value>
78+
</constraint>
79+
</property>
6680
<property name="age">
6781
<constraint name="GreaterThanOrEqual">
6882
<option name="value">18</option>
@@ -83,6 +97,8 @@ or equal to ``18``, you could do the following:
8397
{
8498
public static function loadValidatorMetadata(ClassMetadata $metadata)
8599
{
100+
$metadata->addPropertyConstraint('siblings', new Assert\GreaterThanOrEqual(5));
101+
86102
$metadata->addPropertyConstraint('age', new Assert\GreaterThanOrEqual(array(
87103
'value' => 18,
88104
)));

reference/constraints/IdenticalTo.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ To force that a value is *not* identical, see
2929
Basic Usage
3030
-----------
3131

32-
If you want to ensure that the ``age`` of a ``Person`` class is equal to
33-
``20`` and an integer, you could do the following:
32+
The following constraints ensure that:
33+
34+
* ``firstName`` of ``Person` class is equal to ``Mary`` *and* is a string
35+
* ``age`` is equal to``20`` *and* is of type integer
3436

3537
.. configuration-block::
3638

@@ -43,6 +45,11 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to
4345
4446
class Person
4547
{
48+
/**
49+
* @Assert\IdenticalTo("Mary")
50+
*/
51+
protected $firstName;
52+
4653
/**
4754
* @Assert\IdenticalTo(
4855
* value = 20

0 commit comments

Comments
 (0)