Skip to content

Commit d7bd395

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Add property types and return types in constraints and few other places
2 parents f6f8d5a + 0ed29b2 commit d7bd395

File tree

97 files changed

+510
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+510
-349
lines changed

cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
363363
// config/services.php
364364
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
365365
366-
return function(ContainerConfigurator $container) {
366+
return function(ContainerConfigurator $container): void {
367367
$container->services()
368368
// ...
369369

components/options_resolver.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Imagine you have a ``Mailer`` class which has four options: ``host``,
2323

2424
class Mailer
2525
{
26-
protected $options;
26+
protected array $options;
2727

2828
public function __construct(array $options = [])
2929
{
@@ -37,7 +37,7 @@ check which options are set::
3737
class Mailer
3838
{
3939
// ...
40-
public function sendMail($from, $to)
40+
public function sendMail($from, $to): void
4141
{
4242
$mail = ...;
4343

@@ -908,9 +908,9 @@ can change your code to do the configuration only once per class::
908908
// ...
909909
class Mailer
910910
{
911-
private static $resolversByClass = [];
911+
private static array $resolversByClass = [];
912912

913-
protected $options;
913+
protected array $options;
914914

915915
public function __construct(array $options = [])
916916
{
@@ -926,7 +926,7 @@ can change your code to do the configuration only once per class::
926926
$this->options = self::$resolversByClass[$class]->resolve($options);
927927
}
928928

929-
public function configureOptions(OptionsResolver $resolver)
929+
public function configureOptions(OptionsResolver $resolver): void
930930
{
931931
// ...
932932
}
@@ -941,9 +941,9 @@ method ``clearOptionsConfig()`` and call it periodically::
941941
// ...
942942
class Mailer
943943
{
944-
private static $resolversByClass = [];
944+
private static array $resolversByClass = [];
945945

946-
public static function clearOptionsConfig()
946+
public static function clearOptionsConfig(): void
947947
{
948948
self::$resolversByClass = [];
949949
}

components/serializer.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ exists in your project::
7373
private int $age;
7474
private string $name;
7575
private bool $sportsperson;
76-
private ?\DateTime $createdAt;
76+
private ?\DateTimeInterface $createdAt;
7777

7878
// Getters
7979
public function getAge(): int
@@ -113,7 +113,7 @@ exists in your project::
113113
$this->sportsperson = $sportsperson;
114114
}
115115

116-
public function setCreatedAt(\DateTime $createdAt = null): void
116+
public function setCreatedAt(\DateTimeInterface $createdAt = null): void
117117
{
118118
$this->createdAt = $createdAt;
119119
}
@@ -607,11 +607,11 @@ processes::
607607
class Person
608608
{
609609
public function __construct(
610-
private $firstName,
610+
private string $firstName,
611611
) {
612612
}
613613

614-
public function getFirstName()
614+
public function getFirstName(): string
615615
{
616616
return $this->firstName;
617617
}
@@ -663,7 +663,7 @@ defines a ``Person`` entity with a ``firstName`` property:
663663
{
664664
public function __construct(
665665
#[SerializedName('customer_name')]
666-
private $firstName,
666+
private string $firstName,
667667
) {
668668
}
669669

components/validator/resources.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ In this example, the validation metadata is retrieved executing the
3737

3838
class User
3939
{
40-
protected $name;
40+
protected string $name;
4141

42-
public static function loadValidatorMetadata(ClassMetadata $metadata)
42+
public static function loadValidatorMetadata(ClassMetadata $metadata): void
4343
{
4444
$metadata->addPropertyConstraint('name', new Assert\NotBlank());
4545
$metadata->addPropertyConstraint('name', new Assert\Length([
@@ -99,7 +99,7 @@ prefixed classes included in doc block comments (``/** ... */``). For example::
9999
/**
100100
* @Assert\NotBlank
101101
*/
102-
protected $name;
102+
protected string $name;
103103
}
104104

105105
To enable the annotation loader, call the

components/var_dumper.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ then its dump representation::
372372
373373
class PropertyExample
374374
{
375-
public $publicProperty = 'The `+` prefix denotes public properties,';
376-
protected $protectedProperty = '`#` protected ones and `-` private ones.';
377-
private $privateProperty = 'Hovering a property shows a reminder.';
375+
public string $publicProperty = 'The `+` prefix denotes public properties,';
376+
protected string $protectedProperty = '`#` protected ones and `-` private ones.';
377+
private string $privateProperty = 'Hovering a property shows a reminder.';
378378
}
379379
380380
$var = new PropertyExample();
@@ -391,7 +391,7 @@ then its dump representation::
391391
392392
class DynamicPropertyExample
393393
{
394-
public $declaredProperty = 'This property is declared in the class definition';
394+
public string $declaredProperty = 'This property is declared in the class definition';
395395
}
396396
397397
$var = new DynamicPropertyExample();
@@ -404,7 +404,7 @@ then its dump representation::
404404
405405
class ReferenceExample
406406
{
407-
public $info = "Circular and sibling references are displayed as `#number`.\nHovering them highlights all instances in the same dump.\n";
407+
public string $info = "Circular and sibling references are displayed as `#number`.\nHovering them highlights all instances in the same dump.\n";
408408
}
409409
$var = new ReferenceExample();
410410
$var->aCircularReference = $var;

components/var_exporter.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ following class hierarchy::
5050

5151
abstract class AbstractClass
5252
{
53-
protected $foo;
54-
private $bar;
53+
protected int $foo;
54+
private int $bar;
5555

56-
protected function setBar($bar)
56+
protected function setBar($bar): void
5757
{
5858
$this->bar = $bar;
5959
}

doctrine/resolve_target_entity.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ An Invoice entity::
6565
#[ORM\Table(name: 'invoice')]
6666
class Invoice
6767
{
68-
/**
69-
* @var InvoiceSubjectInterface
70-
*/
7168
#[ORM\ManyToOne(targetEntity: InvoiceSubjectInterface::class)]
72-
protected $subject;
69+
protected InvoiceSubjectInterface $subject;
7370
}
7471

7572
An InvoiceSubjectInterface::

event_dispatcher.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ notify Symfony that it is an event listener by using a special "tag":
9191
9292
use App\EventListener\ExceptionListener;
9393
94-
return function(ContainerConfigurator $container) {
94+
return function(ContainerConfigurator $container): void {
9595
$services = $container->services();
9696
9797
$services->set(ExceptionListener::class)

form/bootstrap5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ configuration:
5757
// config/packages/twig.php
5858
use Symfony\Config\TwigConfig;
5959
60-
return static function(TwigConfig $twig) {
60+
return static function(TwigConfig $twig): void {
6161
$twig->formThemes(['bootstrap_5_layout.html.twig']);
6262
6363
// ...

form/form_collections.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Let's start by creating a ``Task`` entity::
1616

1717
class Task
1818
{
19-
protected $description;
20-
protected $tags;
19+
protected string $description;
20+
protected ArrayCollection $tags;
2121

2222
public function __construct()
2323
{
@@ -53,7 +53,7 @@ objects::
5353

5454
class Tag
5555
{
56-
private $name;
56+
private string $name;
5757

5858
public function getName(): string
5959
{
@@ -466,7 +466,7 @@ you will learn about next!).
466466
// ...
467467
468468
#[ORM\ManyToMany(targetEntity: Tag::class, cascade: ['persist'])]
469-
protected $tags;
469+
protected array $tags;
470470
471471
.. code-block:: yaml
472472

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy