@@ -244,9 +244,9 @@ Assume you have the following plain-old-PHP object::
244244
245245 class MyObj
246246 {
247- public $foo;
247+ public string $foo;
248248
249- private $bar;
249+ private string $bar;
250250
251251 public function getBar()
252252 {
@@ -303,10 +303,10 @@ Then, create your groups definition:
303303 class MyObj
304304 {
305305 #[Groups(['group1', 'group2'])]
306- public $foo;
306+ public string $foo;
307307
308308 #[Groups(['group4'])]
309- public $anotherProperty;
309+ public string $anotherProperty;
310310
311311 #[Groups(['group3'])]
312312 public function getBar() // is* methods are also supported
@@ -449,10 +449,10 @@ Option 1: Using ``@Ignore`` Annotation
449449
450450 class MyClass
451451 {
452- public $foo;
452+ public string $foo;
453453
454454 #[Ignore]
455- public $bar;
455+ public string $bar;
456456 }
457457
458458 .. code-block :: yaml
@@ -1237,8 +1237,8 @@ You can change this behavior by setting the ``AbstractObjectNormalizer::SKIP_NUL
12371237to ``true ``::
12381238
12391239 $dummy = new class {
1240- public $foo;
1241- public $bar = 'notNull';
1240+ public ?string $foo = null ;
1241+ public string $bar = 'notNull';
12421242 };
12431243
12441244 $normalizer = new ObjectNormalizer();
@@ -1313,8 +1313,8 @@ Circular references are common when dealing with entity relations::
13131313
13141314 class Organization
13151315 {
1316- private $name;
1317- private $members;
1316+ private string $name;
1317+ private array $members;
13181318
13191319 public function setName($name)
13201320 {
@@ -1339,10 +1339,10 @@ Circular references are common when dealing with entity relations::
13391339
13401340 class Member
13411341 {
1342- private $name;
1343- private $organization;
1342+ private string $name;
1343+ private Organization $organization;
13441344
1345- public function setName($name)
1345+ public function setName(string $name)
13461346 {
13471347 $this->name = $name;
13481348 }
@@ -1412,12 +1412,12 @@ structure::
14121412
14131413 class MyObj
14141414 {
1415- public $foo;
1415+ public string $foo;
14161416
14171417 /**
14181418 * @var self
14191419 */
1420- public $child;
1420+ public MyObj $child;
14211421 }
14221422
14231423 $level1 = new MyObj();
@@ -1445,7 +1445,7 @@ Here, we set it to 2 for the ``$child`` property:
14451445 class MyObj
14461446 {
14471447 #[MaxDepth(2)]
1448- public $child;
1448+ public MyObj $child;
14491449
14501450 // ...
14511451 }
@@ -1507,10 +1507,10 @@ having unique identifiers::
15071507
15081508 class Foo
15091509 {
1510- public $id;
1510+ public int $id;
15111511
15121512 #[MaxDepth(1)]
1513- public $child;
1513+ public MyObj $child;
15141514 }
15151515
15161516 $level1 = new Foo();
@@ -1606,8 +1606,8 @@ context option::
16061606 class MyObj
16071607 {
16081608 public function __construct(
1609- private $foo,
1610- private $bar,
1609+ private string $foo,
1610+ private string $bar,
16111611 ) {
16121612 }
16131613 }
@@ -1646,8 +1646,8 @@ parameter of the ``ObjectNormalizer``::
16461646
16471647 class ObjectOuter
16481648 {
1649- private $inner;
1650- private $date;
1649+ private ObjectInner $inner;
1650+ private \DateTimeInterface $date;
16511651
16521652 public function getInner()
16531653 {
@@ -1672,8 +1672,8 @@ parameter of the ``ObjectNormalizer``::
16721672
16731673 class ObjectInner
16741674 {
1675- public $foo;
1676- public $bar;
1675+ public string $foo;
1676+ public string $bar;
16771677 }
16781678
16791679 $normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor());
0 commit comments