Skip to content

Add property types and return types in a few places #18356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ The end user can provide values in any configuration file:
// config/services.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->parameters()
->set('acme_blog.author.email', '[email protected]')
;
Expand Down
2 changes: 1 addition & 1 deletion bundles/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ as integration of other related components:
// config/packages/framework.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->form()->enabled(true);
};

Expand Down
2 changes: 1 addition & 1 deletion bundles/prepend_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
// config/packages/acme_something.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->extension('acme_something', [
// ...
'use_acme_goodbye' => false,
Expand Down
14 changes: 7 additions & 7 deletions cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ adapter (template) they use by using the ``app`` and ``system`` key like:
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->cache()
->app('cache.adapter.filesystem')
->system('cache.adapter.system')
Expand Down Expand Up @@ -163,7 +163,7 @@ will create pools with service IDs that follow the pattern ``cache.[type]``.
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->cache()
// Only used with cache.adapter.filesystem
->directory('%kernel.cache_dir%/pools')
Expand Down Expand Up @@ -264,7 +264,7 @@ You can also create more customized pools:
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$cache = $framework->cache();
$cache->defaultMemcachedProvider('memcached://localhost');

Expand Down Expand Up @@ -444,7 +444,7 @@ and use that when configuring the pool.
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Config\FrameworkConfig;

return static function (ContainerBuilder $container, FrameworkConfig $framework) {
return static function (ContainerBuilder $container, FrameworkConfig $framework): void {
$framework->cache()
->pool('cache.my_redis')
->adapters(['cache.adapter.redis'])
Expand Down Expand Up @@ -524,7 +524,7 @@ Symfony stores the item automatically in all the missing pools.
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->cache()
->pool('my_cache_pool')
->defaultLifetime(31536000) // One year
Expand Down Expand Up @@ -616,7 +616,7 @@ to enable this feature. This could be added by using the following configuration
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->cache()
->pool('my_cache_pool')
->tags(true)
Expand Down Expand Up @@ -670,7 +670,7 @@ achieved by specifying the adapter.
// config/packages/cache.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->cache()
->pool('my_cache_pool')
->tags('tag_pool')
Expand Down
2 changes: 1 addition & 1 deletion components/dependency_injection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ config files:

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->parameters()
// ...
->set('mailer.transport', 'sendmail')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// config/services.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->import('%kernel.project_dir%/somefile.yaml');
};
2 changes: 1 addition & 1 deletion components/expression_language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PHP type (including objects)::

class Apple
{
public $variety;
public string $variety;
}

$apple = new Apple();
Expand Down
24 changes: 12 additions & 12 deletions components/property_access.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ method::
// ...
class Person
{
public $name;
public string $name;
}

$person = new Person();
Expand Down Expand Up @@ -321,26 +321,26 @@ can use setters, the magic ``__set()`` method or properties to set values::
// ...
class Person
{
public $firstName;
private $lastName;
private $children = [];
public string $firstName;
private string $lastName;
private array $children = [];

public function setLastName($name)
public function setLastName($name): void
{
$this->lastName = $name;
}

public function getLastName()
public function getLastName(): string
{
return $this->lastName;
}

public function getChildren()
public function getChildren(): array
{
return $this->children;
}

public function __set($property, $value)
public function __set($property, $value): void
{
$this->$property = $value;
}
Expand Down Expand Up @@ -507,15 +507,15 @@ You can also mix objects and arrays::
// ...
class Person
{
public $firstName;
private $children = [];
public string $firstName;
private array $children = [];

public function setChildren($children)
public function setChildren($children): void
{
$this->children = $children;
}

public function getChildren()
public function getChildren(): array
{
return $this->children;
}
Expand Down
16 changes: 8 additions & 8 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,15 @@ It is also possible to serialize only a set of specific attributes::

class User
{
public $familyName;
public $givenName;
public $company;
public string $familyName;
public string $givenName;
public string $company;
}

class Company
{
public $name;
public $address;
public string $name;
public string $address;
}

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

class Company
{
public $name;
public $address;
public string $name;
public string $address;
}

And in the serialized form, all attributes must be prefixed by ``org_`` like
Expand Down Expand Up @@ -925,7 +925,7 @@ faster alternative to the

use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->services()
// ...
->set('get_set_method_normalizer', GetSetMethodNormalizer::class)
Expand Down
2 changes: 1 addition & 1 deletion components/var_dumper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ the :ref:`dump_destination option <configuration-debug-dump_destination>` of the
// config/packages/debug.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->extension('debug', [
'dump_destination' => 'tcp://%env(VAR_DUMPER_SERVER)%',
]);
Expand Down
14 changes: 7 additions & 7 deletions configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ configuration files, even if they use a different format:
// config/services.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->import('legacy_config.php');

// glob expressions are also supported to load multiple files
Expand Down Expand Up @@ -242,7 +242,7 @@ reusable configuration value. By convention, parameters are defined under the
use App\Entity\BlogPost;
use App\Enum\PostState;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->parameters()
// the parameter name is an arbitrary string (the 'app.' prefix is recommended
// to better differentiate your parameters from Symfony parameters).
Expand Down Expand Up @@ -321,7 +321,7 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
// config/packages/some_package.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->extension('some_package', [
// any string surrounded by two % is replaced by that parameter value
'email_address' => '%app.admin_email%',
Expand Down Expand Up @@ -358,7 +358,7 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
// config/services.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->parameters()
->set('url_pattern', 'http://symfony.com/?foo=%%s&amp;bar=%%d');
};
Expand Down Expand Up @@ -620,7 +620,7 @@ This example shows how you could configure the application secret using an env v
// config/packages/framework.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->extension('framework', [
// by convention the env var names are always uppercase
'secret' => '%env(APP_SECRET)%',
Expand Down Expand Up @@ -973,7 +973,7 @@ doesn't work for parameters:

use App\Service\MessageGenerator;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->parameters()
->set('app.contents_dir', '...');

Expand Down Expand Up @@ -1030,7 +1030,7 @@ whenever a service/controller defines a ``$projectDir`` argument, use this:

use App\Controller\LuckyController;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$container->services()
->defaults()
// pass this value to any $projectDir argument for any service
Expand Down
12 changes: 6 additions & 6 deletions configuration/env_var_processors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ processor to turn the value of the ``HTTP_PORT`` env var into an integer:

use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->router()
->httpPort('%env(int:HTTP_PORT)%')
// or
Expand Down Expand Up @@ -98,7 +98,7 @@ Symfony provides the following env var processors:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Config\FrameworkConfig;

return static function (ContainerBuilder $container, FrameworkConfig $framework) {
return static function (ContainerBuilder $container, FrameworkConfig $framework): void {
$container->setParameter('env(SECRET)', 'some_secret');
$framework->secret(env('SECRET')->string());
};
Expand Down Expand Up @@ -144,7 +144,7 @@ Symfony provides the following env var processors:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Config\FrameworkConfig;

return static function (ContainerBuilder $container, FrameworkConfig $framework) {
return static function (ContainerBuilder $container, FrameworkConfig $framework): void {
$container->setParameter('env(HTTP_METHOD_OVERRIDE)', 'true');
$framework->httpMethodOverride(env('HTTP_METHOD_OVERRIDE')->bool());
};
Expand Down Expand Up @@ -231,7 +231,7 @@ Symfony provides the following env var processors:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Config\SecurityConfig;

return static function (ContainerBuilder $container, SecurityConfig $security) {
return static function (ContainerBuilder $container, SecurityConfig $security): void {
$container->setParameter('env(HEALTH_CHECK_METHOD)', 'Symfony\Component\HttpFoundation\Request::METHOD_HEAD');
$security->accessControl()
->path('^/health-check$')
Expand Down Expand Up @@ -280,7 +280,7 @@ Symfony provides the following env var processors:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Config\FrameworkConfig;

return static function (ContainerBuilder $container) {
return static function (ContainerBuilder $container): void {
$container->setParameter('env(ALLOWED_LANGUAGES)', '["en","de","es"]');
$container->setParameter('app_allowed_languages', '%env(json:ALLOWED_LANGUAGES)%');
};
Expand Down Expand Up @@ -364,7 +364,7 @@ Symfony provides the following env var processors:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Config\FrameworkConfig;

return static function (ContainerBuilder $container) {
return static function (ContainerBuilder $container): void {
$container->setParameter('env(ALLOWED_LANGUAGES)', 'en,de,es');
$container->setParameter('app_allowed_languages', '%env(csv:ALLOWED_LANGUAGES)%');
};
Expand Down
2 changes: 1 addition & 1 deletion configuration/micro_kernel_trait.rst
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ because the configuration started to get bigger:
// config/framework.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework
->secret('SOME_SECRET')
->profiler()
Expand Down
4 changes: 2 additions & 2 deletions configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Console script::
Web front-controller::

// public/index.php

// ...
$_SERVER['APP_RUNTIME_OPTIONS']['dotenv_path'] = 'another/custom/path/to/.env';

Expand Down Expand Up @@ -236,7 +236,7 @@ configuration option to define your own translations directory (use :ref:`framew
// config/packages/translation.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->translator()
->defaultPath('%kernel.project_dir%/i18n')
;
Expand Down
2 changes: 1 addition & 1 deletion configuration/secrets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ The secrets system is enabled by default and some of its behavior can be configu
// config/packages/framework.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
$framework->secrets()
// ->vaultDirectory('%kernel.project_dir%/config/secrets/%kernel.environment%')
// ->localDotenvFile('%kernel.project_dir%/.env.%kernel.environment%.local')
Expand Down
2 changes: 1 addition & 1 deletion controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ configuration option to point to it:
// config/packages/framework.php
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework) {
return static function (FrameworkConfig $framework): void {
// ...
$framework->errorController('App\Controller\ErrorController::show');
};
Expand Down
2 changes: 1 addition & 1 deletion controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Then, define a service for this class:

use App\Service\FileUploader;

return static function (ContainerConfigurator $container) {
return static function (ContainerConfigurator $container): void {
$services = $container->services();

$services->set(FileUploader::class)
Expand Down
Loading