@@ -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
@@ -1229,8 +1229,8 @@ You can change this behavior by setting the ``AbstractObjectNormalizer::SKIP_NUL
12291229to ``true ``::
12301230
12311231 $dummy = new class {
1232- public $foo;
1233- public $bar = 'notNull';
1232+ public ?string $foo = null ;
1233+ public string $bar = 'notNull';
12341234 };
12351235
12361236 $normalizer = new ObjectNormalizer();
@@ -1305,8 +1305,8 @@ Circular references are common when dealing with entity relations::
13051305
13061306 class Organization
13071307 {
1308- private $name;
1309- private $members;
1308+ private string $name;
1309+ private array $members;
13101310
13111311 public function setName($name)
13121312 {
@@ -1331,10 +1331,10 @@ Circular references are common when dealing with entity relations::
13311331
13321332 class Member
13331333 {
1334- private $name;
1335- private $organization;
1334+ private string $name;
1335+ private Organization $organization;
13361336
1337- public function setName($name)
1337+ public function setName(string $name)
13381338 {
13391339 $this->name = $name;
13401340 }
@@ -1404,12 +1404,12 @@ structure::
14041404
14051405 class MyObj
14061406 {
1407- public $foo;
1407+ public string $foo;
14081408
14091409 /**
14101410 * @var self
14111411 */
1412- public $child;
1412+ public MyObj $child;
14131413 }
14141414
14151415 $level1 = new MyObj();
@@ -1437,7 +1437,7 @@ Here, we set it to 2 for the ``$child`` property:
14371437 class MyObj
14381438 {
14391439 #[MaxDepth(2)]
1440- public $child;
1440+ public MyObj $child;
14411441
14421442 // ...
14431443 }
@@ -1499,10 +1499,10 @@ having unique identifiers::
14991499
15001500 class Foo
15011501 {
1502- public $id;
1502+ public int $id;
15031503
15041504 #[MaxDepth(1)]
1505- public $child;
1505+ public MyObj $child;
15061506 }
15071507
15081508 $level1 = new Foo();
@@ -1598,8 +1598,8 @@ context option::
15981598 class MyObj
15991599 {
16001600 public function __construct(
1601- private $foo,
1602- private $bar,
1601+ private string $foo,
1602+ private string $bar,
16031603 ) {
16041604 }
16051605 }
@@ -1638,8 +1638,8 @@ parameter of the ``ObjectNormalizer``::
16381638
16391639 class ObjectOuter
16401640 {
1641- private $inner;
1642- private $date;
1641+ private ObjectInner $inner;
1642+ private \DateTimeInterface $date;
16431643
16441644 public function getInner()
16451645 {
@@ -1664,8 +1664,8 @@ parameter of the ``ObjectNormalizer``::
16641664
16651665 class ObjectInner
16661666 {
1667- public $foo;
1668- public $bar;
1667+ public string $foo;
1668+ public string $bar;
16691669 }
16701670
16711671 $normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor());
0 commit comments