Skip to content

Commit 3fd845a

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Use gender-neutral language in the main Serializer article Removed the term "simple" from creating a new page Update datetime.rst components/phpunit_bridge.rst Add best practice note about version Use is_numeric() drop deprecated config value [Console] Fix SymfonyStyle::ask usage Update BC policy to tell about adding/removing return types
2 parents 768242f + b74be85 commit 3fd845a

File tree

8 files changed

+49
-28
lines changed

8 files changed

+49
-28
lines changed

components/phpunit_bridge.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@ Installation
2828

2929
.. code-block:: terminal
3030
31-
$ composer require --dev symfony/phpunit-bridge
31+
$ composer require --dev "symfony/phpunit-bridge:*"
3232
3333
Alternatively, you can clone the `<https://github.com/symfony/phpunit-bridge>`_ repository.
3434

3535
.. include:: /components/require_autoload.rst.inc
3636

37+
.. note::
38+
39+
The PHPUnit bridge is designed to work with all maintained versions of
40+
Symfony components, even across different major versions of them. You should
41+
always use its very latest stable major version to get the most accurate
42+
deprecation report.
43+
3744
If you plan to :ref:`write-assertions-about-deprecations` and use the regular
3845
PHPUnit script (not the modified PHPUnit script provided by Symfony), you have
3946
to register a new `test listener`_ called ``SymfonyTestsListener``:

components/serializer.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ simple schema.
1313

1414
.. image:: /_images/components/serializer/serializer_workflow.png
1515

16-
As you can see in the picture above, an array is used as a man in
17-
the middle. This way, Encoders will only deal with turning specific
18-
**formats** into **arrays** and vice versa. The same way, Normalizers
16+
As you can see in the picture above, an array is used as an intermediary between
17+
objects and serialized contents. This way, encoders will only deal with turning
18+
specific **formats** into **arrays** and vice versa. The same way, Normalizers
1919
will deal with turning specific **objects** into **arrays** and vice versa.
2020

2121
Serialization is a complex topic. This component may not cover all your use cases out of the box,
@@ -63,13 +63,13 @@ Serializing an Object
6363
For the sake of this example, assume the following class already
6464
exists in your project::
6565

66-
namespace Acme;
66+
namespace App\Model;
6767

6868
class Person
6969
{
7070
private $age;
7171
private $name;
72-
private $sportsman;
72+
private $sportsperson;
7373
private $createdAt;
7474

7575
// Getters
@@ -89,9 +89,9 @@ exists in your project::
8989
}
9090

9191
// Issers
92-
public function isSportsman()
92+
public function isSportsperson()
9393
{
94-
return $this->sportsman;
94+
return $this->sportsperson;
9595
}
9696

9797
// Setters
@@ -105,9 +105,9 @@ exists in your project::
105105
$this->age = $age;
106106
}
107107

108-
public function setSportsman($sportsman)
108+
public function setSportsperson($sportsperson)
109109
{
110-
$this->sportsman = $sportsman;
110+
$this->sportsperson = $sportsperson;
111111
}
112112

113113
public function setCreatedAt($createdAt)
@@ -119,14 +119,14 @@ exists in your project::
119119
Now, if you want to serialize this object into JSON, you only need to
120120
use the Serializer service created before::
121121

122-
$person = new Acme\Person();
122+
$person = new App\Model\Person();
123123
$person->setName('foo');
124124
$person->setAge(99);
125-
$person->setSportsman(false);
125+
$person->setSportsperson(false);
126126

127127
$jsonContent = $serializer->serialize($person, 'json');
128128

129-
// $jsonContent contains {"name":"foo","age":99,"sportsman":false}
129+
// $jsonContent contains {"name":"foo","age":99,"sportsperson":false}
130130

131131
echo $jsonContent; // or return it in a Response
132132

@@ -140,13 +140,13 @@ Deserializing an Object
140140
You'll now learn how to do the exact opposite. This time, the information
141141
of the ``Person`` class would be encoded in XML format::
142142

143-
use Acme\Person;
143+
use App\Model\Person;
144144

145145
$data = <<<EOF
146146
<person>
147147
<name>foo</name>
148148
<age>99</age>
149-
<sportsman>false</sportsman>
149+
<sportsperson>false</sportsperson>
150150
</person>
151151
EOF;
152152

@@ -191,7 +191,7 @@ The serializer can also be used to update an existing object::
191191
$person = new Person();
192192
$person->setName('bar');
193193
$person->setAge(99);
194-
$person->setSportsman(true);
194+
$person->setSportsperson(true);
195195

196196
$data = <<<EOF
197197
<person>
@@ -201,7 +201,7 @@ The serializer can also be used to update an existing object::
201201
EOF;
202202

203203
$serializer->deserialize($data, Person::class, 'xml', array('object_to_populate' => $person));
204-
// $person = Acme\Person(name: 'foo', age: '69', sportsman: true)
204+
// $person = App\Model\Person(name: 'foo', age: '69', sportsperson: true)
205205

206206
This is a common need when working with an ORM.
207207

@@ -404,7 +404,7 @@ method on the normalizer definition::
404404
$encoder = new JsonEncoder();
405405

406406
$serializer = new Serializer(array($normalizer), array($encoder));
407-
$serializer->serialize($person, 'json'); // Output: {"name":"foo","sportsman":false}
407+
$serializer->serialize($person, 'json'); // Output: {"name":"foo","sportsperson":false}
408408

409409
.. _component-serializer-converting-property-names-when-serializing-and-deserializing:
410410

@@ -516,8 +516,8 @@ Serializing Boolean Attributes
516516
------------------------------
517517

518518
If you are using isser methods (methods prefixed by ``is``, like
519-
``Acme\Person::isSportsman()``), the Serializer component will automatically
520-
detect and use it to serialize related attributes.
519+
``App\Model\Person::isSportsperson()``), the Serializer component will
520+
automatically detect and use it to serialize related attributes.
521521

522522
The ``ObjectNormalizer`` also takes care of methods starting with ``has``, ``add``
523523
and ``remove``.
@@ -527,7 +527,7 @@ Using Callbacks to Serialize Properties with Object Instances
527527

528528
When serializing, you can set a callback to format a specific object property::
529529

530-
use Acme\Person;
530+
use App\Model\Person;
531531
use Symfony\Component\Serializer\Encoder\JsonEncoder;
532532
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
533533
use Symfony\Component\Serializer\Serializer;

console/style.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ User Input Methods
235235
the third argument::
236236

237237
$io->ask('Number of workers to start', 1, function ($number) {
238-
if (!is_integer($number)) {
239-
throw new \RuntimeException('You must type an integer.');
238+
if (!is_numeric($number)) {
239+
throw new \RuntimeException('You must type a number.');
240240
}
241241

242-
return $number;
242+
return (int) $number;
243243
});
244244

245245
:method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::askHidden`

contributing/code/bc.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ backward compatibility promise:
8282
+-----------------------------------------------+-----------------------------+
8383
| Add a default value to an argument | Yes |
8484
+-----------------------------------------------+-----------------------------+
85+
| Add a return type to an implemented method | Yes |
86+
+-----------------------------------------------+-----------------------------+
8587

8688
Using our Classes
8789
~~~~~~~~~~~~~~~~~
@@ -173,6 +175,8 @@ Remove default value of an argument No
173175
Add type hint to an argument No
174176
Remove type hint of an argument No
175177
Change argument type No
178+
Add return type No
179+
Remove return type No [9]_
176180
Change return type No
177181
**Constants**
178182
Add constant Yes
@@ -229,6 +233,8 @@ Remove default value of an argument No
229233
Add type hint to an argument No [7]_ [8]_
230234
Remove type hint of an argument No [7]_ [8]_
231235
Change argument type No [7]_ [8]_
236+
Add return type No [7]_ [8]_
237+
Remove return type No [7]_ [8]_ [9]_
232238
Change return type No [7]_ [8]_
233239
**Protected Methods**
234240
Add protected method Yes
@@ -244,6 +250,8 @@ Remove default value of an argument No [7]_
244250
Add type hint to an argument No [7]_ [8]_
245251
Remove type hint of an argument No [7]_ [8]_
246252
Change argument type No [7]_ [8]_
253+
Add return type No [7]_ [8]_
254+
Remove return type No [7]_ [8]_ [9]_
247255
Change return type No [7]_ [8]_
248256
**Private Methods**
249257
Add private method Yes
@@ -257,6 +265,8 @@ Remove default value of an argument Yes
257265
Add type hint to an argument Yes
258266
Remove type hint of an argument Yes
259267
Change argument type Yes
268+
Add return type Yes
269+
Remove return type Yes
260270
Change return type Yes
261271
**Static Methods**
262272
Turn non static into static No [7]_ [8]_
@@ -300,6 +310,8 @@ Change value of a constant Yes [1]_ [5]_
300310
Changing an argument type is only possible with a parent type.
301311
Changing a return type is only possible with a child type.
302312
313+
.. [9] Allowed for the ``void`` return type.
314+
303315
.. _Semantic Versioning: https://semver.org/
304316
.. _scalar type: https://php.net/manual/en/function.is-scalar.php
305317
.. _boolean values: https://php.net/manual/en/function.boolval.php

contributing/code/core_team.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Active Core Members
9797
* **Tobias Nyholm** (`Nyholm`_) manages the official and contrib recipes
9898
repositories;
9999

100-
* **Samuel Rozé** (`sroze`_) can merge into Messenger_ component.
100+
* **Samuel Rozé** (`sroze`_) can merge into the Messenger_ component.
101101

102102
* **Deciders Team** (``@symfony/deciders`` on GitHub):
103103

page_creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Create your First Page in Symfony
88
=================================
99

1010
Creating a new page - whether it's an HTML page or a JSON endpoint - is a
11-
simple two-step process:
11+
two-step process:
1212

1313
#. **Create a route**: A route is the URL (e.g. ``/about``) to your page and
1414
points to a controller;

reference/forms/types/collection.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ type::
347347
entry_type
348348
~~~~~~~~~~
349349

350-
**type**: ``string`` or :class:`Symfony\\Component\\Form\\FormTypeInterface` **default**: ``Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType``
350+
**type**: ``string`` **default**: ``Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType``
351351

352352
This is the field type for each item in this collection (e.g. ``TextType``,
353353
``ChoiceType``, etc). For example, if you have an array of email addresses,

reference/forms/types/datetime.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ If the ``widget`` option is set to ``single_text``, this option specifies
109109
the format of the input, i.e. how Symfony will interpret the given input
110110
as a datetime string. It defaults to the `RFC 3339`_ format which is used
111111
by the HTML5 ``datetime`` field. Keeping the default value will cause the
112-
field to be rendered as an ``input`` field with ``type="datetime"``.
112+
field to be rendered as an ``input`` field with ``type="datetime"``. For
113+
more information on valid formats, see `Date/Time Format Syntax`_.
113114

114115
.. include:: /reference/forms/types/options/hours.rst.inc
115116

@@ -214,3 +215,4 @@ Field Variables
214215
+----------+------------+----------------------------------------------------------------------+
215216

216217
.. _`RFC 3339`: https://tools.ietf.org/html/rfc3339
218+
.. _`Date/Time Format Syntax`: http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax

0 commit comments

Comments
 (0)