Skip to content

Commit 472f579

Browse files
Add property types and return types in a few places
1 parent b5ac484 commit 472f579

Some content is hidden

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

60 files changed

+310
-308
lines changed

bundles/best_practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ The end user can provide values in any configuration file:
436436
// config/services.php
437437
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
438438
439-
return static function (ContainerConfigurator $container) {
439+
return static function (ContainerConfigurator $container): void {
440440
$container->parameters()
441441
->set('acme_blog.author.email', '[email protected]')
442442
;

bundles/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ as integration of other related components:
4242
// config/packages/framework.php
4343
use Symfony\Config\FrameworkConfig;
4444
45-
return static function (FrameworkConfig $framework) {
45+
return static function (FrameworkConfig $framework): void {
4646
$framework->form()->enabled(true);
4747
};
4848

bundles/prepend_extension.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
139139
// config/packages/acme_something.php
140140
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
141141
142-
return static function (ContainerConfigurator $container) {
142+
return static function (ContainerConfigurator $container): void {
143143
$container->extension('acme_something', [
144144
// ...
145145
'use_acme_goodbye' => false,

cache.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
8585
// config/packages/cache.php
8686
use Symfony\Config\FrameworkConfig;
8787
88-
return static function (FrameworkConfig $framework) {
88+
return static function (FrameworkConfig $framework): void {
8989
$framework->cache()
9090
->app('cache.adapter.filesystem')
9191
->system('cache.adapter.system')
@@ -163,7 +163,7 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
163163
// config/packages/cache.php
164164
use Symfony\Config\FrameworkConfig;
165165
166-
return static function (FrameworkConfig $framework) {
166+
return static function (FrameworkConfig $framework): void {
167167
$framework->cache()
168168
// Only used with cache.adapter.filesystem
169169
->directory('%kernel.cache_dir%/pools')
@@ -264,7 +264,7 @@ You can also create more customized pools:
264264
// config/packages/cache.php
265265
use Symfony\Config\FrameworkConfig;
266266
267-
return static function (FrameworkConfig $framework) {
267+
return static function (FrameworkConfig $framework): void {
268268
$cache = $framework->cache();
269269
$cache->defaultMemcachedProvider('memcached://localhost');
270270
@@ -444,7 +444,7 @@ and use that when configuring the pool.
444444
use Symfony\Component\DependencyInjection\ContainerBuilder;
445445
use Symfony\Config\FrameworkConfig;
446446
447-
return static function (ContainerBuilder $container, FrameworkConfig $framework) {
447+
return static function (ContainerBuilder $container, FrameworkConfig $framework): void {
448448
$framework->cache()
449449
->pool('cache.my_redis')
450450
->adapters(['cache.adapter.redis'])
@@ -524,7 +524,7 @@ Symfony stores the item automatically in all the missing pools.
524524
// config/packages/cache.php
525525
use Symfony\Config\FrameworkConfig;
526526
527-
return static function (FrameworkConfig $framework) {
527+
return static function (FrameworkConfig $framework): void {
528528
$framework->cache()
529529
->pool('my_cache_pool')
530530
->defaultLifetime(31536000) // One year
@@ -616,7 +616,7 @@ to enable this feature. This could be added by using the following configuration
616616
// config/packages/cache.php
617617
use Symfony\Config\FrameworkConfig;
618618
619-
return static function (FrameworkConfig $framework) {
619+
return static function (FrameworkConfig $framework): void {
620620
$framework->cache()
621621
->pool('my_cache_pool')
622622
->tags(true)
@@ -670,7 +670,7 @@ achieved by specifying the adapter.
670670
// config/packages/cache.php
671671
use Symfony\Config\FrameworkConfig;
672672
673-
return static function (FrameworkConfig $framework) {
673+
return static function (FrameworkConfig $framework): void {
674674
$framework->cache()
675675
->pool('my_cache_pool')
676676
->tags('tag_pool')

components/dependency_injection.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ config files:
313313
314314
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
315315
316-
return static function (ContainerConfigurator $container) {
316+
return static function (ContainerConfigurator $container): void {
317317
$container->parameters()
318318
// ...
319319
->set('mailer.transport', 'sendmail')

components/dependency_injection/_imports-parameters-note.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
// config/services.php
3232
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
3333

34-
return static function (ContainerConfigurator $container) {
34+
return static function (ContainerConfigurator $container): void {
3535
$container->import('%kernel.project_dir%/somefile.yaml');
3636
};

components/expression_language.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ PHP type (including objects)::
107107

108108
class Apple
109109
{
110-
public $variety;
110+
public string $variety;
111111
}
112112

113113
$apple = new Apple();

components/property_access.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ method::
177177
// ...
178178
class Person
179179
{
180-
public $name;
180+
public string $name;
181181
}
182182

183183
$person = new Person();
@@ -321,26 +321,26 @@ can use setters, the magic ``__set()`` method or properties to set values::
321321
// ...
322322
class Person
323323
{
324-
public $firstName;
325-
private $lastName;
326-
private $children = [];
324+
public string $firstName;
325+
private string $lastName;
326+
private array $children = [];
327327

328-
public function setLastName($name)
328+
public function setLastName($name): void
329329
{
330330
$this->lastName = $name;
331331
}
332332

333-
public function getLastName()
333+
public function getLastName(): string
334334
{
335335
return $this->lastName;
336336
}
337337

338-
public function getChildren()
338+
public function getChildren(): array
339339
{
340340
return $this->children;
341341
}
342342

343-
public function __set($property, $value)
343+
public function __set($property, $value): void
344344
{
345345
$this->$property = $value;
346346
}
@@ -507,15 +507,15 @@ You can also mix objects and arrays::
507507
// ...
508508
class Person
509509
{
510-
public $firstName;
511-
private $children = [];
510+
public string $firstName;
511+
private array $children = [];
512512

513-
public function setChildren($children)
513+
public function setChildren($children): void
514514
{
515515
$this->children = $children;
516516
}
517517

518-
public function getChildren()
518+
public function getChildren(): array
519519
{
520520
return $this->children;
521521
}

components/serializer.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ It is also possible to serialize only a set of specific attributes::
398398

399399
class User
400400
{
401-
public $familyName;
402-
public $givenName;
403-
public $company;
401+
public string $familyName;
402+
public string $givenName;
403+
public string $company;
404404
}
405405

406406
class Company
407407
{
408-
public $name;
409-
public $address;
408+
public string $name;
409+
public string $address;
410410
}
411411

412412
$company = new Company();
@@ -529,8 +529,8 @@ Given you have the following object::
529529

530530
class Company
531531
{
532-
public $name;
533-
public $address;
532+
public string $name;
533+
public string $address;
534534
}
535535

536536
And in the serialized form, all attributes must be prefixed by ``org_`` like
@@ -925,7 +925,7 @@ faster alternative to the
925925
926926
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
927927
928-
return static function (ContainerConfigurator $container) {
928+
return static function (ContainerConfigurator $container): void {
929929
$container->services()
930930
// ...
931931
->set('get_set_method_normalizer', GetSetMethodNormalizer::class)

components/var_dumper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ the :ref:`dump_destination option <configuration-debug-dump_destination>` of the
144144
// config/packages/debug.php
145145
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
146146
147-
return static function (ContainerConfigurator $container) {
147+
return static function (ContainerConfigurator $container): void {
148148
$container->extension('debug', [
149149
'dump_destination' => 'tcp://%env(VAR_DUMPER_SERVER)%',
150150
]);

0 commit comments

Comments
 (0)