@@ -198,17 +198,12 @@ You can also :doc:`create your context builders </serializer/custom_context_buil
198198to have autocompletion, validation, and documentation for your custom context values.
199199
200200.. _serializer-using-serialization-groups-annotations :
201+ .. _serializer-using-serialization-groups-attributes :
201202
202- Using Serialization Groups Annotations
203- --------------------------------------
203+ Using Serialization Groups Attributes
204+ -------------------------------------
204205
205- To use annotations, first add support for them via the SensioFrameworkExtraBundle:
206-
207- .. code-block :: terminal
208-
209- $ composer require sensio/framework-extra-bundle
210-
211- Next, add the :ref: `@Groups annotations <component-serializer-attributes-groups-annotations >`
206+ You can add :ref: `#[Groups] attributes <component-serializer-attributes-groups-annotations >`
212207to your class::
213208
214209 // src/Entity/Product.php
@@ -217,29 +212,21 @@ to your class::
217212 use Doctrine\ORM\Mapping as ORM;
218213 use Symfony\Component\Serializer\Annotation\Groups;
219214
220- /**
221- * @ORM\Entity()
222- */
215+ #[ORM\Entity]
223216 class Product
224217 {
225- /**
226- * @ORM\Id
227- * @ORM\GeneratedValue
228- * @ORM\Column(type="integer")
229- * @Groups({"show_product", "list_product"})
230- */
218+ #[ORM\Id]
219+ #[ORM\GeneratedValue]
220+ #[ORM\Column(type: 'integer')]
221+ #[Groups(['show_product', 'list_product'])]
231222 private $id;
232223
233- /**
234- * @ORM\Column(type="string", length=255)
235- * @Groups({"show_product", "list_product"})
236- */
224+ #[ORM\Column(type: 'string', length: 255)]
225+ #[Groups(['show_product', 'list_product'])]
237226 private $name;
238227
239- /**
240- * @ORM\Column(type="integer")
241- * @Groups({"show_product"})
242- */
228+ #[ORM\Column(type: 'integer')]
229+ #[Groups(['show_product'])]
243230 private $description;
244231 }
245232
@@ -257,7 +244,7 @@ You can now choose which groups to use when serializing::
257244
258245 The value of the ``groups `` key can be a single string, or an array of strings.
259246
260- In addition to the ``@ Groups `` annotation , the Serializer component also
247+ In addition to the ``#[ Groups] `` attribute , the Serializer component also
261248supports YAML or XML files. These files are automatically loaded when being
262249stored in one of the following locations:
263250
0 commit comments