From 1fbacaf0467d8f805898f227250986ee09364907 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 19 May 2021 17:13:46 +0200 Subject: [PATCH 0001/1913] Bump Symfony PHP requirements to 8.0.2 --- components/property_info.rst | 4 ++-- configuration/secrets.rst | 9 +-------- quick_tour/the_big_picture.rst | 2 +- reference/configuration/framework.rst | 5 ----- reference/configuration/security.rst | 4 +--- security/named_hashers.rst | 6 +----- setup.rst | 5 ++--- 7 files changed, 8 insertions(+), 27 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index b6684d948d8..5a4e62b6cd2 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -122,7 +122,7 @@ class exposes public methods to extract several types of information: * :ref:`List of properties `: :method:`Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface::getProperties` * :ref:`Property type `: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getTypes` - (including typed properties since PHP 7.4) + (including typed properties) * :ref:`Property description `: :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getShortDescription` and :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getLongDescription` * :ref:`Property access details `: :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isReadable` and :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isWritable` * :ref:`Property initializable through the constructor `: :method:`Symfony\\Component\\PropertyInfo\\PropertyInitializableExtractorInterface::isInitializable` @@ -357,7 +357,7 @@ Using PHP reflection, the :class:`Symfony\\Component\\PropertyInfo\\Extractor\\R provides list, type and access information from setter and accessor methods. It can also give the type of a property (even extracting it from the constructor arguments), and if it is initializable through the constructor. It supports -return and scalar types for PHP 7:: +return and scalar types:: use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; diff --git a/configuration/secrets.rst b/configuration/secrets.rst index 8db723d63de..bcb7e82c533 100644 --- a/configuration/secrets.rst +++ b/configuration/secrets.rst @@ -14,10 +14,7 @@ store them by using Symfony's secrets management system - sometimes called a .. note:: - The Secrets system requires the sodium PHP extension that is bundled - with PHP 7.2. If you're using an earlier PHP version, you can - install the `libsodium`_ PHP extension or use the - `paragonie/sodium_compat`_ package. + The Secrets system requires the Sodium PHP extension. .. _secrets-generate-keys: @@ -317,7 +314,3 @@ The secrets system is enabled by default and some of its behavior can be configu // ->decryptionEnvVar('base64:default::SYMFONY_DECRYPTION_SECRET') ; }; - - -.. _`libsodium`: https://pecl.php.net/package/libsodium -.. _`paragonie/sodium_compat`: https://github.com/paragonie/sodium_compat diff --git a/quick_tour/the_big_picture.rst b/quick_tour/the_big_picture.rst index b6ad8eaafdd..34ebc1e1b96 100644 --- a/quick_tour/the_big_picture.rst +++ b/quick_tour/the_big_picture.rst @@ -14,7 +14,7 @@ safe & easy!) and offers long-term support. Downloading Symfony ------------------- -First, make sure you've installed `Composer`_ and have PHP 7.1.3 or higher. +First, make sure you've installed `Composer`_ and have PHP 8.0.2 or higher. Ready? In a terminal, run: diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index cfd85b374a7..f4ef18635e4 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1656,11 +1656,6 @@ The possible values for this option are: user consciously made the request (by clicking a link or submitting a form with the ``GET`` method). -.. note:: - - This option is available starting from PHP 7.3, but Symfony has a polyfill - so you can use it with any older PHP version as well. - cookie_secure ............. diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index fa9acdaa6a8..72b6f9b5fec 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -327,8 +327,7 @@ Using the Sodium Password Hasher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It uses the `Argon2 key derivation function`_ and it's the hasher recommended -by Symfony. Argon2 support was introduced in PHP 7.2, but if you use an earlier -PHP version, you can install the `libsodium`_ PHP extension. +by Symfony. The hashed passwords are ``96`` characters long, but due to the hashing requirements saved in the resulting hash this may change in the future, so make @@ -853,7 +852,6 @@ role inheritance rules by creating a role hierarchy, as explained in :ref:`security-role-hierarchy`. .. _`PBKDF2`: https://en.wikipedia.org/wiki/PBKDF2 -.. _`libsodium`: https://pecl.php.net/package/libsodium .. _`Session Fixation`: https://owasp.org/www-community/attacks/Session_fixation .. _`Argon2 key derivation function`: https://en.wikipedia.org/wiki/Argon2 .. _`bcrypt password hashing function`: https://en.wikipedia.org/wiki/Bcrypt diff --git a/security/named_hashers.rst b/security/named_hashers.rst index 06f31852020..033986cf861 100644 --- a/security/named_hashers.rst +++ b/security/named_hashers.rst @@ -110,9 +110,7 @@ be done with named hashers: .. note:: - If you are running PHP 7.2+ or have the `libsodium`_ extension installed, - then the recommended hashing algorithm to use is - :ref:`Sodium `. + The recommended hashing algorithm to use is :ref:`Sodium `. This creates a hasher named ``harsh``. In order for a ``User`` instance to use it, the class must implement @@ -188,5 +186,3 @@ you must register a service for it in order to use it as a named hasher: This creates a hasher named ``app_hasher`` from a service with the ID ``App\Security\Hasher\MyCustomPasswordHasher``. - -.. _`libsodium`: https://pecl.php.net/package/libsodium diff --git a/setup.rst b/setup.rst index bca61758e65..f3218bf608f 100644 --- a/setup.rst +++ b/setup.rst @@ -17,8 +17,8 @@ Technical Requirements Before creating your first Symfony application you must: -* Install PHP 7.2.5 or higher and these PHP extensions (which are installed and - enabled by default in most PHP 7 installations): `Ctype`_, `iconv`_, `JSON`_, +* Install PHP 8.0.2 or higher and these PHP extensions (which are installed and + enabled by default in most PHP 8 installations): `Ctype`_, `iconv`_, `PCRE`_, `Session`_, `SimpleXML`_, and `Tokenizer`_; * `Install Composer`_, which is used to install PHP packages. @@ -315,7 +315,6 @@ Learn More .. _`Contrib recipe repository`: https://github.com/symfony/recipes-contrib .. _`Symfony Recipes documentation`: https://github.com/symfony/recipes/blob/master/README.rst .. _`iconv`: https://www.php.net/book.iconv -.. _`JSON`: https://www.php.net/book.json .. _`Session`: https://www.php.net/book.session .. _`Ctype`: https://www.php.net/book.ctype .. _`Tokenizer`: https://www.php.net/book.tokenizer From cae061883c301031dfda501af024360fd95a3619 Mon Sep 17 00:00:00 2001 From: Giulio Lastra Date: Mon, 24 May 2021 11:35:41 +0200 Subject: [PATCH 0002/1913] Changed version for composer create-project Version was 5.3 instead of 6.0 --- setup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.rst b/setup.rst index f3218bf608f..70a8fcb31ac 100644 --- a/setup.rst +++ b/setup.rst @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton:"5.3.x@dev" my_project_name + $ composer create-project symfony/website-skeleton:"6.0.x@dev" my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton:"5.3.x@dev" my_project_name + $ composer create-project symfony/skeleton:"6.0.x@dev" my_project_name No matter which command you run to create the Symfony application. All of them will create a new ``my_project_name/`` directory, download some dependencies From 1d71a6ea12976bda911b45e210802098192f8339 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 28 May 2021 17:17:39 +0200 Subject: [PATCH 0003/1913] [Inflector] Removed the component --- _build/redirection_map | 1 + components/inflector.rst | 12 ------------ components/property_access.rst | 4 ++-- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 components/inflector.rst diff --git a/_build/redirection_map b/_build/redirection_map index 1069505a81a..165e1c96132 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -515,3 +515,4 @@ /frontend/encore/shared-entry /frontend/encore/split-chunks /testing/functional_tests_assertions /testing#testing-application-assertions /security/named_encoders /security/named_hashers +/components/inflector /components/string#inflector diff --git a/components/inflector.rst b/components/inflector.rst deleted file mode 100644 index c42d6ebaeaa..00000000000 --- a/components/inflector.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. index:: - single: Inflector - single: Components; Inflector - -The Inflector Component -======================= - -.. deprecated:: 5.1 - - The Inflector component was deprecated in Symfony 5.1 and its code was moved - into the :doc:`String ` component. - :ref:`Read the new Inflector docs `. diff --git a/components/property_access.rst b/components/property_access.rst index 9d3f4e355fc..c8b674293a1 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -400,7 +400,7 @@ The PropertyAccess component checks for methods called ``add()``. Both methods must be defined. For instance, in the previous example, the component looks for the ``addChild()`` and ``removeChild()`` methods to access to the ``children`` property. -`The Inflector component`_ is used to find the singular of a property name. +`The String component`_ inflector is used to find the singular of a property name. If available, *adder* and *remover* methods have priority over a *setter* method. @@ -538,4 +538,4 @@ Or you can pass parameters directly to the constructor (not the recommended way) // enable handling of magic __call, __set but not __get: $propertyAccessor = new PropertyAccessor(PropertyAccessor::MAGIC_CALL | PropertyAccessor::MAGIC_SET); -.. _The Inflector component: https://github.com/symfony/inflector +.. _`The String component`: https://github.com/symfony/string From 63a817813668802f1fcfab0ceded0ee830c3fea8 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 2 Jul 2021 10:36:00 +0200 Subject: [PATCH 0004/1913] Fix: Update DOCtor-RST config file for Symfony 6.0 --- .doctor-rst.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index f63b8689521..b75b04b524a 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -53,16 +53,16 @@ rules: # master versionadded_directive_major_version: - major_version: 5 + major_version: 6 versionadded_directive_min_version: - min_version: '5.0' + min_version: '6.0' deprecated_directive_major_version: - major_version: 5 + major_version: 6 deprecated_directive_min_version: - min_version: '5.0' + min_version: '6.0' # do not report as violation whitelist: From 882c8f27a38616fe18bc5c2f77fc0315ab453d53 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 15 Jul 2021 16:02:03 +0200 Subject: [PATCH 0005/1913] Update Contracts to 3.0 version --- components/contracts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/contracts.rst b/components/contracts.rst index 1f1cc3f6adc..a1ae32192f6 100644 --- a/components/contracts.rst +++ b/components/contracts.rst @@ -61,7 +61,7 @@ convention. For example: { "...": "...", "provide": { - "symfony/cache-implementation": "1.0" + "symfony/cache-implementation": "3.0" } } From 6aa61a12784baee99049b9f259774d7e711987ff Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 15 Jul 2021 14:50:46 +0200 Subject: [PATCH 0006/1913] Remove 5.x versionadded directives --- best_practices.rst | 2 +- cache.rst | 9 -- components/asset.rst | 4 - components/browser_kit.rst | 8 -- .../cache/adapters/array_cache_adapter.rst | 4 - .../adapters/couchbasebucket_adapter.rst | 4 - components/config/definition.rst | 7 - components/console/helpers/cursor.rst | 5 - components/console/helpers/questionhelper.rst | 9 -- components/console/helpers/table.rst | 4 - components/console/single_command_tool.rst | 5 - components/dependency_injection.rst | 2 - components/dom_crawler.rst | 8 -- components/filesystem.rst | 4 - components/http_foundation.rst | 22 --- components/http_foundation/sessions.rst | 22 --- components/intl.rst | 8 -- components/ldap.rst | 5 - components/lock.rst | 24 +--- components/options_resolver.rst | 15 --- components/phpunit_bridge.rst | 32 ----- components/process.rst | 8 -- components/property_access.rst | 12 +- components/property_info.rst | 4 - components/runtime.rst | 10 -- components/security/authentication.rst | 2 - components/security/authorization.rst | 9 -- components/security/secure_tools.rst | 6 +- components/semaphore.rst | 4 - components/serializer.rst | 12 -- components/string.rst | 40 ------ components/uid.rst | 41 ------ components/var_dumper.rst | 4 - components/yaml/yaml_format.rst | 6 - configuration.rst | 5 - configuration/env_var_processors.rst | 5 - console.rst | 18 --- console/coloring.rst | 8 -- console/input.rst | 4 - console/lockable_trait.rst | 4 - console/style.rst | 4 - contributing/documentation/format.rst | 16 +-- deployment/proxies.rst | 13 -- doctrine/events.rst | 4 - event_dispatcher.rst | 10 -- form/bootstrap5.rst | 4 - form/data_mappers.rst | 4 - form/form_themes.rst | 12 -- forms.rst | 4 - http_cache.rst | 5 - http_client.rst | 34 ----- logging/processors.rst | 4 - mailer.rst | 44 ------ messenger.rst | 125 +++--------------- notifier.rst | 41 ------ notifier/chatters.rst | 24 ---- notifier/texters.rst | 8 -- profiler/data_collector.rst | 4 - rate_limiter.rst | 9 -- reference/configuration/framework.rst | 105 +-------------- reference/configuration/kernel.rst | 4 - reference/configuration/security.rst | 43 +----- reference/configuration/swiftmailer.rst | 4 - reference/constraints/AtLeastOneOf.rst | 4 - reference/constraints/Blank.rst | 4 - reference/constraints/CardScheme.rst | 4 - reference/constraints/Choice.rst | 4 - reference/constraints/Compound.rst | 10 -- reference/constraints/Count.rst | 8 -- reference/constraints/Country.rst | 4 - reference/constraints/Currency.rst | 4 - reference/constraints/Date.rst | 4 - reference/constraints/DateTime.rst | 4 - reference/constraints/Email.rst | 4 - reference/constraints/Expression.rst | 4 - .../constraints/ExpressionLanguageSyntax.rst | 4 - reference/constraints/Hostname.rst | 8 -- reference/constraints/Iban.rst | 4 - reference/constraints/Ip.rst | 4 - reference/constraints/IsFalse.rst | 4 - reference/constraints/IsNull.rst | 4 - reference/constraints/IsTrue.rst | 4 - reference/constraints/Isbn.rst | 16 --- reference/constraints/Isin.rst | 4 - reference/constraints/Issn.rst | 4 - reference/constraints/Language.rst | 8 -- reference/constraints/Length.rst | 23 +--- reference/constraints/Locale.rst | 4 - reference/constraints/Luhn.rst | 4 - reference/constraints/NotBlank.rst | 4 - reference/constraints/NotNull.rst | 4 - reference/constraints/Range.rst | 8 -- reference/constraints/Regex.rst | 4 - reference/constraints/Sequentially.rst | 4 - reference/constraints/Time.rst | 4 - reference/constraints/Timezone.rst | 4 - reference/constraints/Type.rst | 4 - reference/constraints/Ulid.rst | 4 - reference/constraints/Unique.rst | 4 - reference/constraints/UniqueEntity.rst | 4 - reference/constraints/Url.rst | 4 - reference/constraints/Uuid.rst | 8 -- reference/dic_tags.rst | 26 +--- reference/forms/types/choice.rst | 5 - reference/forms/types/color.rst | 4 - reference/forms/types/integer.rst | 6 - reference/forms/types/language.rst | 4 - reference/forms/types/money.rst | 4 - .../forms/types/options/choice_filter.rst.inc | 4 - .../options/extra_fields_message.rst.inc | 4 - .../forms/types/options/label_html.rst.inc | 4 - .../forms/types/options/priority.rst.inc | 4 - .../forms/types/options/rounding_mode.rst.inc | 6 - reference/forms/types/percent.rst | 8 -- reference/forms/types/ulid.rst | 4 - reference/forms/types/uuid.rst | 4 - reference/twig_reference.rst | 20 --- routing.rst | 35 +---- security.rst | 33 +---- security/access_control.rst | 4 - security/authenticator_manager.rst | 19 +-- security/csrf.rst | 4 - security/custom_authentication_provider.rst | 4 - security/impersonating_user.rst | 5 - security/json_login_setup.rst | 2 - security/login_link.rst | 4 - security/remember_me.rst | 8 -- security/user_checkers.rst | 4 - security/user_provider.rst | 11 -- security/voters.rst | 4 - serializer.rst | 4 - service_container.rst | 6 - service_container/alias_private.rst | 7 - service_container/autowiring.rst | 8 -- service_container/calls.rst | 6 - service_container/configurators.rst | 1 - service_container/factories.rst | 1 - service_container/injection_types.rst | 1 - service_container/optional_dependencies.rst | 1 - service_container/parent_services.rst | 1 - service_container/service_decoration.rst | 6 - .../service_subscribers_locators.rst | 1 - session.rst | 78 ----------- session/database.rst | 5 - templates.rst | 4 - testing.rst | 19 --- translation.rst | 14 -- translation/debug.rst | 9 +- translation/lint.rst | 8 -- validation.rst | 4 - validation/custom_constraint.rst | 10 -- validation/sequence_provider.rst | 4 - workflow.rst | 34 +---- workflow/dumping-workflows.rst | 4 - 154 files changed, 63 insertions(+), 1560 deletions(-) diff --git a/best_practices.rst b/best_practices.rst index 4928c79a6f9..51d3e61e2b7 100644 --- a/best_practices.rst +++ b/best_practices.rst @@ -368,7 +368,7 @@ Use the ``auto`` Password Hasher The :ref:`auto password hasher ` automatically selects the best possible encoder/hasher depending on your PHP installation. -Starting from Symfony 5.3, the default auto hasher is ``bcrypt``. +Currently, the default auto hasher is ``bcrypt``. Use Voters to Implement Fine-grained Security Restrictions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cache.rst b/cache.rst index 632f5f4905f..6025593c386 100644 --- a/cache.rst +++ b/cache.rst @@ -107,10 +107,6 @@ The Cache component comes with a series of adapters pre-configured: * :doc:`cache.adapter.redis ` * :ref:`cache.adapter.redis_tag_aware ` (Redis adapter optimized to work with tags) -.. versionadded:: 5.2 - - ``cache.adapter.redis_tag_aware`` has been introduced in Symfony 5.2. - Some of these adapters could be configured via shortcuts. Using these shortcuts will create pools with service IDs that follow the pattern ``cache.[type]``. @@ -725,11 +721,6 @@ Clear all caches everywhere: Encrypting the Cache -------------------- -.. versionadded:: 5.1 - - The :class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller` - class was introduced in Symfony 5.1. - To encrypt the cache using ``libsodium``, you can use the :class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller`. diff --git a/components/asset.rst b/components/asset.rst index 5044ef2dab9..6cf0264dd3d 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -179,10 +179,6 @@ with the :doc:`HttpClient component `:: $manifestUrl = 'https://cdn.example.com/rev-manifest.json'; $package = new Package(new RemoteJsonManifestVersionStrategy($manifestUrl, $httpClient)); -.. versionadded:: 5.1 - - The ``RemoteJsonManifestVersionStrategy`` was introduced in Symfony 5.1. - Custom Version Strategies ......................... diff --git a/components/browser_kit.rst b/components/browser_kit.rst index 475c84b9365..b93697f7bb9 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -90,10 +90,6 @@ convert the request parameters into a JSON string and set the needed HTTP header // this encodes parameters as JSON and sets the required CONTENT_TYPE and HTTP_ACCEPT headers $crawler = $client->jsonRequest('GET', '/', ['some_parameter' => 'some_value']); -.. versionadded:: 5.3 - - The ``jsonRequest()`` method was introduced in Symfony 5.3. - The :method:`Symfony\\Component\\BrowserKit\\AbstractBrowser::xmlHttpRequest` method, which defines the same arguments as the ``request()`` method, is a shortcut to make AJAX requests:: @@ -178,10 +174,6 @@ provides access to the form properties (e.g. ``$form->getUri()``, Custom Header Handling ~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 5.2 - - The ``getHeaders()`` method was introduced in Symfony 5.2. - The optional HTTP headers passed to the ``request()`` method follows the FastCGI request format (uppercase, underscores instead of dashes and prefixed with ``HTTP_``). Before saving those headers to the request, they are lower-cased, with ``HTTP_`` diff --git a/components/cache/adapters/array_cache_adapter.rst b/components/cache/adapters/array_cache_adapter.rst index c7b06f40753..baa7f840590 100644 --- a/components/cache/adapters/array_cache_adapter.rst +++ b/components/cache/adapters/array_cache_adapter.rst @@ -30,7 +30,3 @@ method:: // is reached, cache follows the LRU model (least recently used items are deleted) $maxItems = 0 ); - -.. versionadded:: 5.1 - - The ``maxLifetime`` and ``maxItems`` options were introduced in Symfony 5.1. diff --git a/components/cache/adapters/couchbasebucket_adapter.rst b/components/cache/adapters/couchbasebucket_adapter.rst index 7043a7c3e95..2ebb42c5f9f 100644 --- a/components/cache/adapters/couchbasebucket_adapter.rst +++ b/components/cache/adapters/couchbasebucket_adapter.rst @@ -7,10 +7,6 @@ Couchbase Cache Adapter ======================= -.. versionadded:: 5.1 - - The CouchbaseBucketAdapter was introduced in Symfony 5.1. - This adapter stores the values in-memory using one (or more) `Couchbase server`_ instances. Unlike the :ref:`APCu adapter `, and similarly to the :ref:`Memcached adapter `, it is not limited to the current server's diff --git a/components/config/definition.rst b/components/config/definition.rst index dfe9f8e166a..bc57336391d 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -435,13 +435,6 @@ The following example shows these methods in practice:: Deprecating the Option ---------------------- -.. versionadded:: 5.1 - - The signature of the ``setDeprecated()`` method changed from - ``setDeprecated(?string $message)`` to - ``setDeprecated(string $package, string $version, ?string $message)`` - in Symfony 5.1. - You can deprecate options using the :method:`Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::setDeprecated` method:: diff --git a/components/console/helpers/cursor.rst b/components/console/helpers/cursor.rst index da450925fc3..deffbef9be9 100644 --- a/components/console/helpers/cursor.rst +++ b/components/console/helpers/cursor.rst @@ -4,11 +4,6 @@ Cursor Helper ============= -.. versionadded:: 5.1 - - The :class:`Symfony\\Component\\Console\\Cursor` class was introduced - in Symfony 5.1. - The :class:`Symfony\\Component\\Console\\Cursor` allows you to change the cursor position in a console command. This allows you to write on any position of the output: diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 96ed044d0bc..b1ae67dfd7f 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -117,10 +117,6 @@ from a predefined list:: // ... do something with the color } -.. versionadded:: 5.2 - - Support for using PHP objects as choice values was introduced in Symfony 5.2. - The option which should be selected by default is provided with the third argument of the constructor. The default is ``null``, which means that no option is the default one. @@ -242,11 +238,6 @@ You can also specify if you want to not trim the answer by setting it directly w Accept Multiline Answers ~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 5.2 - - The ``setMultiline()`` and ``isMultiline()`` methods were introduced in - Symfony 5.2. - By default, the question helper stops reading user input when it receives a newline character (i.e., when the user hits ``ENTER`` once). However, you may specify that the response to a question should allow multiline answers by passing ``true`` to diff --git a/components/console/helpers/table.rst b/components/console/helpers/table.rst index 5e1735ce1a4..ae16799c18c 100644 --- a/components/console/helpers/table.rst +++ b/components/console/helpers/table.rst @@ -265,10 +265,6 @@ Here is a full list of things you can customize: This method can also be used to override a built-in style. -.. versionadded:: 5.2 - - The option to style table cells was introduced in Symfony 5.2. - In addition to the built-in table styles, you can also apply different styles to each table cell via :class:`Symfony\\Component\\Console\\Helper\\TableCellStyle`:: diff --git a/components/console/single_command_tool.rst b/components/console/single_command_tool.rst index 500d679d1e1..d4e36d55492 100644 --- a/components/console/single_command_tool.rst +++ b/components/console/single_command_tool.rst @@ -7,11 +7,6 @@ Building a single Command Application When building a command line tool, you may not need to provide several commands. In such case, having to pass the command name each time is tedious. -.. versionadded:: 5.1 - - The :class:`Symfony\\Component\\Console\\SingleCommandApplication` class was - introduced in Symfony 5.1. - Fortunately, it is possible to remove this need by declaring a single command application:: diff --git a/components/dependency_injection.rst b/components/dependency_injection.rst index b303e96d484..91aacc91b01 100644 --- a/components/dependency_injection.rst +++ b/components/dependency_injection.rst @@ -299,12 +299,10 @@ config files: $services = $configurator->services(); $services->set('mailer', 'Mailer') - // the param() method was introduced in Symfony 5.2. ->args([param('mailer.transport')]) ; $services->set('newsletter_manager', 'NewsletterManager') - // In versions earlier to Symfony 5.1 the service() function was called ref() ->call('setMailer', [service('mailer')]) ; }; diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 8df1b8c8f67..4a3eba6610b 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -192,10 +192,6 @@ Get all the child or ancestor nodes:: $crawler->filter('body')->children(); $crawler->filter('body > p')->ancestors(); -.. versionadded:: 5.3 - - The ``ancestors()`` method was introduced in Symfony 5.3. - Get all the direct child nodes matching a CSS selector:: $crawler->filter('body')->children('p.lorem'); @@ -633,10 +629,6 @@ the whole form or specific field(s):: Resolving a URI ~~~~~~~~~~~~~~~ -.. versionadded:: 5.1 - - The :class:`Symfony\\Component\\DomCrawler\\UriResolver` helper class was added in Symfony 5.1. - The :class:`Symfony\\Component\\DomCrawler\\UriResolver` class takes an URI (relative, absolute, fragment, etc.) and turns it into an absolute URI against another given base URI:: diff --git a/components/filesystem.rst b/components/filesystem.rst index 447c95f7ff5..aa7cef95894 100644 --- a/components/filesystem.rst +++ b/components/filesystem.rst @@ -287,10 +287,6 @@ exception on failure:: // returns a path like : /tmp/prefix_wyjgtF.png $filesystem->tempnam('/tmp', 'prefix_', '.png'); -.. versionadded:: 5.1 - - The option to set a suffix in ``tempnam()`` was introduced in Symfony 5.1. - ``dumpFile`` ~~~~~~~~~~~~ diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 9fa9ab6e33c..9553f417eda 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -198,10 +198,6 @@ If the request body is a JSON string, it can be accessed using $data = $request->toArray(); -.. versionadded:: 5.2 - - The ``toArray()`` method was introduced in Symfony 5.2. - Identifying a Request ~~~~~~~~~~~~~~~~~~~~~ @@ -288,10 +284,6 @@ this complexity and defines some methods for the most common tasks:: HeaderUtils::parseQuery('foo[bar.baz]=qux'); // => ['foo' => ['bar.baz' => 'qux']] -.. versionadded:: 5.2 - - The ``parseQuery()`` method was introduced in Symfony 5.2. - Accessing ``Accept-*`` Headers Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -475,10 +467,6 @@ a new object with the modified property:: ->withDomain('.example.com') ->withSecure(true); -.. versionadded:: 5.1 - - The ``with*()`` methods were introduced in Symfony 5.1. - Managing the HTTP Cache ~~~~~~~~~~~~~~~~~~~~~~~ @@ -523,11 +511,6 @@ call:: 'etag' => 'abcdef', ]); -.. versionadded:: 5.1 - - The ``must_revalidate``, ``no_cache``, ``no_store``, ``no_transform`` and - ``proxy_revalidate`` directives were introduced in Symfony 5.1. - To check if the Response validators (``ETag``, ``Last-Modified``) match a conditional value specified in the client Request, use the :method:`Symfony\\Component\\HttpFoundation\\Response::isNotModified` @@ -766,11 +749,6 @@ Symfony offers two methods to interact with this preference: * :method:`Symfony\\Component\\HttpFoundation\\Request::preferSafeContent`; * :method:`Symfony\\Component\\HttpFoundation\\Response::setContentSafe`; -.. versionadded:: 5.1 - - The ``preferSafeContent()`` and ``setContentSafe()`` methods were introduced - in Symfony 5.1. - The following example shows how to detect if the user agent prefers "safe" content:: if ($request->preferSafeContent()) { diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index 5756a38fc58..d6d32501966 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -166,14 +166,6 @@ and "Remember Me" login settings or other user based state information. :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBag` This is the standard default implementation. -:class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\NamespacedAttributeBag` - This implementation allows for attributes to be stored in a structured namespace. - - .. deprecated:: 5.3 - - The ``NamespacedAttributeBag`` class is deprecated since Symfony 5.3. - If you need this feature, you will have to implement the class yourself. - :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBagInterface` has the API @@ -242,20 +234,6 @@ So any processing of this might quickly get ugly, even adding a token to the arr $tokens['c'] = $value; $session->set('tokens', $tokens); -.. deprecated:: 5.3 - - The ``NamespacedAttributeBag`` class is deprecated since Symfony 5.3. - If you need this feature, you will have to implement the class yourself. - -With structured namespacing, the key can be translated to the array -structure like this using a namespace character (which defaults to ``/``):: - - // ... - use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag; - - $session = new Session(new NativeSessionStorage(), new NamespacedAttributeBag()); - $session->set('tokens/c', $value); - Flash Messages ~~~~~~~~~~~~~~ diff --git a/components/intl.rst b/components/intl.rst index 217b9618bc2..304b0143bc6 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -250,10 +250,6 @@ can change if the number is used in cash transactions or in other scenarios $fractionDigits = Currencies::getFractionDigits('SEK'); // returns: 2 $cashFractionDigits = Currencies::getCashFractionDigits('SEK'); // returns: 0 -.. versionadded:: 5.3 - - The ``getCashFractionDigits()`` method was introduced in Symfony 5.3. - Some currencies require to round numbers to the nearest increment of some value (e.g. 5 cents). This increment might be different if numbers are formatted for cash transactions or other scenarios (e.g. accounting):: @@ -268,10 +264,6 @@ cash transactions or other scenarios (e.g. accounting):: $roundingIncrement = Currencies::getRoundingIncrement('CAD'); // returns: 0 $cashRoundingIncrement = Currencies::getCashRoundingIncrement('CAD'); // returns: 5 -.. versionadded:: 5.3 - - The ``getCashRoundingIncrement()`` method was introduced in Symfony 5.3. - All methods (except for ``getFractionDigits()``, ``getCashFractionDigits()``, ``getRoundingIncrement()`` and ``getCashRoundingIncrement()``) accept the translation locale as the last, optional parameter, which defaults to the diff --git a/components/ldap.rst b/components/ldap.rst index 08caf52b3e8..21ef7a8bcfb 100644 --- a/components/ldap.rst +++ b/components/ldap.rst @@ -160,11 +160,6 @@ delete existing ones:: // Removing an existing entry $entryManager->remove(new Entry('cn=Test User,dc=symfony,dc=com')); -.. versionadded:: 5.3 - - The option to make attribute names case-insensitive in ``getAttribute()`` - and ``hasAttribute()`` was introduced in Symfony 5.3. - Batch Updating ______________ diff --git a/components/lock.rst b/components/lock.rst index 118c7015771..12e4aed8c83 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -123,14 +123,9 @@ they can be decorated with the ``RetryTillSaveStore`` class:: When the provided store does not implement the :class:`Symfony\\Component\\Lock\\BlockingStoreInterface` interface, the ``Lock`` class will retry to acquire the lock in a non-blocking way until the -lock is acquired. - -.. deprecated:: 5.2 - - As of Symfony 5.2, you don't need to use the ``RetryTillSaveStore`` class - anymore. The ``Lock`` class now provides the default logic to acquire locks - in blocking mode when the store does not implement the - ``BlockingStoreInterface`` interface. +lock is acquired. However, the ``Lock`` class also provides the default logic to +acquire locks in blocking mode when the store does not implement the +``BlockingStoreInterface`` interface. Expiring Locks -------------- @@ -242,11 +237,6 @@ or until ``Lock::release()`` is called. Shared Locks ------------ -.. versionadded:: 5.2 - - Shared locks (and the associated ``acquireRead()`` method and - ``SharedLockStoreInterface``) were introduced in Symfony 5.2. - A shared or `readers–writer lock`_ is a synchronization primitive that allows concurrent access for read-only operations, while write operations require exclusive access. This means that multiple threads can read the data in parallel @@ -410,10 +400,6 @@ support blocking, and expects a TTL to avoid stalled locks:: MongoDbStore ~~~~~~~~~~~~ -.. versionadded:: 5.1 - - The ``MongoDbStore`` was introduced in Symfony 5.1. - The MongoDbStore saves locks on a MongoDB server ``>=2.2``, it requires a ``\MongoDB\Collection`` or ``\MongoDB\Client`` from `mongodb/mongodb`_ or a `MongoDB Connection String`_. @@ -510,10 +496,6 @@ locks:: In opposite to the ``PdoStore``, the ``PostgreSqlStore`` does not need a table to store locks and does not expire. -.. versionadded:: 5.2 - - The ``PostgreSqlStore`` was introduced in Symfony 5.2. - .. _lock-store-redis: RedisStore diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 5b32a612a51..0be9639814d 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -720,10 +720,6 @@ In same way, parent options can access to the nested options as normal arrays:: Prototype Options ~~~~~~~~~~~~~~~~~ -.. versionadded:: 5.3 - - Prototype options were introduced in Symfony 5.3. - There are situations where you will have to resolve and validate a set of options that may repeat many times within another option. Let's imagine a ``connections`` option that will accept an array of database connections @@ -769,13 +765,6 @@ connections. Deprecating the Option ~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 5.1 - - The signature of the ``setDeprecated()`` method changed from - ``setDeprecated(string $option, ?string $message)`` to - ``setDeprecated(string $option, string $package, string $version, $message)`` - in Symfony 5.1. - Once an option is outdated or you decided not to maintain it anymore, you can deprecate it using the :method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::setDeprecated` method:: @@ -870,10 +859,6 @@ method:: } } -.. versionadded:: 5.1 - - The ``define()`` and ``info()`` methods were introduced in Symfony 5.1. - Performance Tweaks ~~~~~~~~~~~~~~~~~~ diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index adde598b1ec..bfbab0afdaf 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -313,11 +313,6 @@ Then, you can run the following command to use that file and ignore those deprec $ SYMFONY_DEPRECATIONS_HELPER='baselineFile=./tests/allowed.json' ./vendor/bin/simple-phpunit -.. versionadded:: 5.2 - - The ``baselineFile`` and ``generateBaseline`` options were introduced in - Symfony 5.2. - Disabling the Verbose Output ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -329,10 +324,6 @@ It's also possible to change verbosity per deprecation type. For example, using ``quiet[]=indirect&quiet[]=other`` will hide details for deprecations of types "indirect" and "other". -.. versionadded:: 5.1 - - The ``quiet`` option was introduced in Symfony 5.1. - Disabling the Deprecation Helper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -375,20 +366,12 @@ the compiling and warming up of the container: $ php bin/console debug:container --deprecations -.. versionadded:: 5.1 - - The ``--deprecations`` option was introduced in Symfony 5.1. - Log Deprecations ~~~~~~~~~~~~~~~~ For turning the verbose output off and write it to a log file instead you can use ``SYMFONY_DEPRECATIONS_HELPER='logFile=/path/deprecations.log'``. -.. versionadded:: 5.3 - - The ``logFile`` option was introduced in Symfony 5.3. - Write Assertions about Deprecations ----------------------------------- @@ -424,11 +407,6 @@ times (order matters):: } } -.. deprecated:: 5.1 - - Symfony versions previous to 5.1 also included a ``@expectedDeprecation`` - annotation to test deprecations, but it was deprecated in favor of the method. - Display the Full Stack Trace ---------------------------- @@ -935,11 +913,6 @@ If you have installed the bridge through Composer, you can run it by calling e.g of PHPUnit to be considered. This is useful when testing a framework that does not support the latest version(s) of PHPUnit. -.. versionadded:: 5.2 - - The ``SYMFONY_MAX_PHPUNIT_VERSION`` env variable was introduced in - Symfony 5.2. - .. tip:: If you still need to use ``prophecy`` (but not ``symfony/yaml``), @@ -954,11 +927,6 @@ If you have installed the bridge through Composer, you can run it by calling e.g env variable. This is specially useful for installing PHPUnit plugins without having to add them to your main ``composer.json`` file. -.. versionadded:: 5.3 - - The ``SYMFONY_PHPUNIT_REQUIRE`` env variable was introduced in - Symfony 5.3. - Code Coverage Listener ---------------------- diff --git a/components/process.rst b/components/process.rst index 1182b1c32a1..f396c9760f7 100644 --- a/components/process.rst +++ b/components/process.rst @@ -105,10 +105,6 @@ with a non-zero code):: Configuring Process Options --------------------------- -.. versionadded:: 5.2 - - The feature to configure process options was introduced in Symfony 5.2. - Symfony uses the PHP :phpfunction:`proc_open` function to run the processes. You can configure the options passed to the ``other_options`` argument of ``proc_open()`` using the ``setOptions()`` method:: @@ -452,10 +448,6 @@ check regularly:: You can get the process start time using the ``getStartTime()`` method. - .. versionadded:: 5.1 - - The ``getStartTime()`` method was introduced in Symfony 5.1. - .. _reference-process-signal: Process Idle Timeout diff --git a/components/property_access.rst b/components/property_access.rst index c8b674293a1..0a474f061a4 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -215,10 +215,10 @@ The ``getValue()`` method can also use the magic ``__get()`` method:: var_dump($propertyAccessor->getValue($person, 'Wouter')); // [...] -.. versionadded:: 5.2 +.. note:: - The magic ``__get()`` method can be disabled since in Symfony 5.2. - see `Enable other Features`_. + The ``__get()`` method support is enabled by default. + See `Enable other Features`_ if you want to disable it. .. _components-property-access-magic-call: @@ -356,10 +356,10 @@ see `Enable other Features`_:: var_dump($person->getWouter()); // [...] -.. versionadded:: 5.2 +.. note:: - The magic ``__set()`` method can be disabled since in Symfony 5.2. - see `Enable other Features`_. + The ``__set()`` method support is enabled by default. + See `Enable other Features`_ if you want to disable it. Writing to Array Properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/property_info.rst b/components/property_info.rst index 5a4e62b6cd2..0e50679c366 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -441,10 +441,6 @@ If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be checked but you will get only the properties considered by the Serializer Component (notably the ``@Ignore`` annotation is taken into account). -.. versionadded:: 5.2 - - Support for the ``null`` value in ``serializer_groups`` was introduced in Symfony 5.2. - DoctrineExtractor ~~~~~~~~~~~~~~~~~ diff --git a/components/runtime.rst b/components/runtime.rst index e716ec6eb38..345d8f8cbc5 100644 --- a/components/runtime.rst +++ b/components/runtime.rst @@ -9,10 +9,6 @@ The Runtime Component to make sure the application can run with runtimes like PHP-FPM, ReactPHP, Swoole, etc. without any changes. -.. versionadded:: 5.3 - - The Runtime component was introduced in Symfony 5.3. - Installation ------------ @@ -362,12 +358,6 @@ logic could be versioned as a part of a normal package. If the application author decides to use this component, the package maintainer of the Runtime class will have more control and can fix bugs and add features. -.. note:: - - Before Symfony 5.3, the Symfony bootstrap logic was part of a Flex recipe. - Since recipes are rarely updated by users, bug patches would rarely be - installed. - The Runtime component is designed to be totally generic and able to run any application outside of the global state in 6 steps: diff --git a/components/security/authentication.rst b/components/security/authentication.rst index 9cca9f18d9f..629012a748c 100644 --- a/components/security/authentication.rst +++ b/components/security/authentication.rst @@ -130,8 +130,6 @@ password was valid:: use Symfony\Component\Security\Core\User\InMemoryUserProvider; use Symfony\Component\Security\Core\User\UserChecker; - // The 'InMemoryUser' class was introduced in Symfony 5.3. - // In previous versions it was called 'User' $userProvider = new InMemoryUserProvider( [ 'admin' => [ diff --git a/components/security/authorization.rst b/components/security/authorization.rst index ffc4edc278a..bc5906a5342 100644 --- a/components/security/authorization.rst +++ b/components/security/authorization.rst @@ -54,10 +54,6 @@ recognizes several strategies: ``priority`` grants or denies access by the first voter that does not abstain; - .. versionadded:: 5.1 - - The ``priority`` version strategy was introduced in Symfony 5.1. - Usage of the available options in detail:: use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; @@ -117,11 +113,6 @@ It also supports the attributes ``IS_ANONYMOUS``, ``IS_REMEMBERED``, ``IS_IMPERSONATOR`` to grant access based on a specific state of authentication. -.. versionadded:: 5.1 - - The ``IS_ANONYMOUS``, ``IS_REMEMBERED`` and ``IS_IMPERSONATOR`` - attributes were introduced in Symfony 5.1. - :: use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; diff --git a/components/security/secure_tools.rst b/components/security/secure_tools.rst index a9d6e0fec3a..47c17e09380 100644 --- a/components/security/secure_tools.rst +++ b/components/security/secure_tools.rst @@ -7,9 +7,9 @@ also use them if you want to solve the problem they address. .. note:: - The functions described in this article were introduced in PHP 5.6 or 7. - For older PHP versions, a polyfill is provided by the - `Symfony Polyfill Component`_. + The functions described in this article are available in modern PHP versions. + If your project uses a legacy PHP version, you can use them thanks to some + of the polyfills provided by the `Symfony Polyfill Component`_. Comparing Strings ~~~~~~~~~~~~~~~~~ diff --git a/components/semaphore.rst b/components/semaphore.rst index ebae3df89e8..82d97c27977 100644 --- a/components/semaphore.rst +++ b/components/semaphore.rst @@ -8,10 +8,6 @@ The Semaphore Component The Semaphore Component manages `semaphores`_, a mechanism to provide exclusive access to a shared resource. -.. versionadded:: 5.2 - - The Semaphore Component was introduced in Symfony 5.2. - Installation ------------ diff --git a/components/serializer.rst b/components/serializer.rst index 9c8b73a04a1..78fbdf9284e 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -899,14 +899,6 @@ The Serializer component provides several built-in normalizers: Also it can denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid` or :class:`Symfony\\Component\\Uid\\Ulid`. The format does not matter. -.. versionadded:: 5.2 - - The ``UidNormalizer`` was introduced in Symfony 5.2. - -.. versionadded:: 5.3 - - The ``UidNormalizer`` normalization formats were introduced in Symfony 5.3. - .. _component-serializer-encoders: Encoders @@ -1004,10 +996,6 @@ Option Description D ``output_utf8_bom`` Outputs special `UTF-8 BOM`_ along with encoded data ``false`` ======================= ===================================================== ========================== -.. versionadded:: 5.3 - - The ``csv_end_of_line`` option was introduced in Symfony 5.3. - The ``XmlEncoder`` ~~~~~~~~~~~~~~~~~~ diff --git a/components/string.rst b/components/string.rst index 48f17f0b3e9..1c9d4245076 100644 --- a/components/string.rst +++ b/components/string.rst @@ -8,10 +8,6 @@ The String Component The String component provides a single object-oriented API to work with three "unit systems" of strings: bytes, code points and grapheme clusters. -.. versionadded:: 5.0 - - The String component was introduced in Symfony 5.0. - Installation ------------ @@ -129,10 +125,6 @@ to make your code more concise:: // creates a UnicodeString object $foo = s('अनुच्छेद'); -.. versionadded:: 5.1 - - The ``s()`` function was introduced in Symfony 5.1. - There are also some specialized constructors:: // ByteString can create a random string of the given length @@ -146,10 +138,6 @@ There are also some specialized constructors:: $foo = UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947); // equivalent to: $foo = new UnicodeString('नमस्ते'); -.. versionadded:: 5.1 - - The second argument of ``ByteString::fromRandom()`` was introduced in Symfony 5.1. - Methods to Transform String Objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -354,10 +342,6 @@ Methods to Search and Replace return '['.$match[0].']'; }); // result = '[1][2][3]' -.. versionadded:: 5.1 - - The ``containsAny()`` method was introduced in Symfony 5.1. - Methods to Join, Split, Truncate and Reverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -388,10 +372,6 @@ Methods to Join, Split, Truncate and Reverse // even if that generates a string longer than the desired length u('Lorem Ipsum')->truncate(8, '…', false); // 'Lorem Ipsum' -.. versionadded:: 5.1 - - The third argument of ``truncate()`` was introduced in Symfony 5.1. - :: // breaks the string into lines of the given length @@ -414,10 +394,6 @@ Methods to Join, Split, Truncate and Reverse u('foo bar')->reverse(); // 'rab oof' u('さよなら')->reverse(); // 'らなよさ' -.. versionadded:: 5.1 - - The ``reverse()`` method was introduced in Symfony 5.1. - Methods Added by ByteString ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -488,18 +464,6 @@ that only includes safe ASCII characters:: return str_replace('❤️', 'love', $string); }); -.. versionadded:: 5.1 - - The feature to define additional substitutions was introduced in Symfony 5.1. - -.. versionadded:: 5.2 - - The feature to use a PHP closure to define substitutions was introduced in Symfony 5.2. - -.. versionadded:: 5.3 - - The feature to fallback to the parent locale's symbols map was introduced in Symfony 5.3. - The separator between words is a dash (``-``) by default, but you can define another separator as the second argument:: @@ -544,10 +508,6 @@ the injected slugger is the same as the request locale:: Inflector --------- -.. versionadded:: 5.1 - - The inflector feature was introduced in Symfony 5.1. - In some scenarios such as code generation and code introspection, you need to convert words from/to singular/plural. For example, to know the property associated with an *adder* method, you must convert from plural diff --git a/components/uid.rst b/components/uid.rst index d6b3692be45..8a5c9d8cd7a 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -8,10 +8,6 @@ The UID Component The UID component provides utilities to work with `unique identifiers`_ (UIDs) such as UUIDs and ULIDs. -.. versionadded:: 5.1 - - The UID component was introduced in Symfony 5.1. - Installation ------------ @@ -67,11 +63,6 @@ to create each type of UUID:: // It's defined in http://gh.peabody.io/uuidv6/ $uuid = Uuid::v6(); // $uuid is an instance of Symfony\Component\Uid\UuidV6 -.. versionadded:: 5.3 - - The ``Uuid::NAMESPACE_*`` constants and the namespace string values (``'dns'``, - ``'url'``, etc.) were introduced in Symfony 5.3. - If your UUID value is already generated in another format, use any of the following methods to create a ``Uuid`` object from it:: @@ -82,11 +73,6 @@ following methods to create a ``Uuid`` object from it:: $uuid = Uuid::fromBase58('TuetYWNHhmuSQ3xPoVLv9M'); $uuid = Uuid::fromRfc4122('d9e7a184-5d5b-11ea-a62a-3499710062d0'); -.. versionadded:: 5.3 - - The ``fromBinary()``, ``fromBase32()``, ``fromBase58()`` and ``fromRfc4122()`` - methods were introduced in Symfony 5.3. - Converting UUIDs ~~~~~~~~~~~~~~~~ @@ -133,11 +119,6 @@ UUID objects created with the ``Uuid`` class can use the following methods // * int < 0 if $uuid1 is less than $uuid4 $uuid1->compare($uuid4); // e.g. int(4) -.. versionadded:: 5.3 - - The ``getDateTime()`` method was introduced in Symfony 5.3. In previous - versions it was called ``getTime()``. - Storing UUIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -162,10 +143,6 @@ type, which converts to/from UUID objects automatically:: // ... } -.. versionadded:: 5.2 - - The UUID type was introduced in Symfony 5.2. - There is no generator to assign UUIDs automatically as the value of your entity primary keys, but you can use the following:: @@ -264,11 +241,6 @@ following methods to create a ``Ulid`` object from it:: $ulid = Ulid::fromBase58('1BKocMc5BnrVcuq2ti4Eqm'); $ulid = Ulid::fromRfc4122('0171069d-593d-97d3-8b3e-23d06de5b308'); -.. versionadded:: 5.3 - - The ``fromBinary()``, ``fromBase32()``, ``fromBase58()`` and ``fromRfc4122()`` - methods were introduced in Symfony 5.3. - Converting ULIDs ~~~~~~~~~~~~~~~~ @@ -302,11 +274,6 @@ ULID objects created with the ``Ulid`` class can use the following methods:: // this method returns $ulid1 <=> $ulid2 $ulid1->compare($ulid2); // e.g. int(-1) -.. versionadded:: 5.3 - - The ``getDateTime()`` method was introduced in Symfony 5.3. In previous - versions it was called ``getTime()``. - Storing ULIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -361,10 +328,6 @@ entity primary keys:: } -.. versionadded:: 5.2 - - The ULID type and generator were introduced in Symfony 5.2. - When using built-in Doctrine repository methods (e.g. ``findOneBy()``), Doctrine knows how to convert these ULID types to build the SQL query (e.g. ``->findOneBy(['user' => $user->getUlid()])``). However, when using DQL @@ -397,10 +360,6 @@ of the ULID parameters:: Generating and Inspecting UUIDs/ULIDs in the Console ---------------------------------------------------- -.. versionadded:: 5.3 - - The commands to inspect and generate UUIDs/ULIDs were introduced in Symfony 5.3. - This component provides several commands to generate and inspect UUIDs/ULIDs in the console. They are not enabled by default, so you must add the following configuration in your application before using these commands: diff --git a/components/var_dumper.rst b/components/var_dumper.rst index b661bd7a44a..76a20c289be 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -191,10 +191,6 @@ Then you can use the following command to start a server out-of-the-box: Configuring the Dump Server with Environment Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 5.2 - - The ``VAR_DUMPER_FORMAT=server`` feature was introduced in Symfony 5.2. - If you prefer to not modify the application configuration (e.g. to quickly debug a project given to you) use the ``VAR_DUMPER_FORMAT`` env var. diff --git a/components/yaml/yaml_format.rst b/components/yaml/yaml_format.rst index 0cca9901836..f38addb8281 100644 --- a/components/yaml/yaml_format.rst +++ b/components/yaml/yaml_format.rst @@ -124,12 +124,6 @@ Numbers # an octal 0o14 -.. deprecated:: 5.1 - - In YAML 1.1, octal numbers use the notation ``0...``, whereas in YAML 1.2 - the notation changes to ``0o...``. Symfony 5.1 added support for YAML 1.2 - notation and deprecated support for YAML 1.1 notation. - .. code-block:: yaml # an hexadecimal diff --git a/configuration.rst b/configuration.rst index 3a42a45680f..f44344fed89 100644 --- a/configuration.rst +++ b/configuration.rst @@ -919,11 +919,6 @@ parameters at once by type-hinting any of its constructor arguments with the Using PHP ConfigBuilders ------------------------ -.. versionadded:: 5.3 - - The "ConfigBuilders" feature was introduced in Symfony 5.3 as an - :doc:`experimental feature `. - Writing PHP config is sometimes difficult because you end up with large nested arrays and you have no autocompletion help from your favorite IDE. A way to address this is to use "ConfigBuilders". They are objects that will help you diff --git a/configuration/env_var_processors.rst b/configuration/env_var_processors.rst index a12b63a7a3e..1895a01b7cc 100644 --- a/configuration/env_var_processors.rst +++ b/configuration/env_var_processors.rst @@ -151,11 +151,6 @@ Symfony provides the following env var processors: }; ``env(not:FOO)`` - - .. versionadded:: 5.3 - - The ``not:`` env var processor was introduced in Symfony 5.3. - Casts ``FOO`` to a bool (just as ``env(bool:...)`` does) except it returns the inverted value (falsy values are returned as ``true``, truthy values are returned as ``false``): diff --git a/console.rst b/console.rst index 80ae5fd7cd5..40793b89b09 100644 --- a/console.rst +++ b/console.rst @@ -64,15 +64,6 @@ want a command to create a user:: } } -.. versionadded:: 5.1 - - The ``Command::SUCCESS`` and ``Command::FAILURE`` constants were introduced - in Symfony 5.1. - -.. versionadded:: 5.3 - - The ``Command::INVALID`` constant was introduced in Symfony 5.3 - Configuring the Command ----------------------- @@ -397,15 +388,6 @@ console:: If you are using a :doc:`single-command application `, call ``setAutoExit(false)`` on it to get the command result in ``CommandTester``. -.. versionadded:: 5.2 - - The ``setAutoExit()`` method for single-command applications was introduced - in Symfony 5.2. - -.. versionadded:: 5.4 - - The ``assertCommandIsSuccessful()`` method was introduced in Symfony 5.4. - .. tip:: You can also test a whole console application by using diff --git a/console/coloring.rst b/console/coloring.rst index 7e77a090b25..32d86087ebb 100644 --- a/console/coloring.rst +++ b/console/coloring.rst @@ -50,14 +50,6 @@ Any hex color is supported for foreground and background colors. Besides that, t ``gray``, ``bright-red``, ``bright-green``, ``bright-yellow``, ``bright-blue``, ``bright-magenta``, ``bright-cyan`` and ``bright-white``. -.. versionadded:: 5.2 - - True (hex) color support was introduced in Symfony 5.2 - -.. versionadded:: 5.3 - - Support for bright colors was introduced in Symfony 5.3. - .. note:: If the terminal doesn't support true colors, the nearest named color is used. diff --git a/console/input.rst b/console/input.rst index 3bbba7e5fce..fa0ae899c0e 100644 --- a/console/input.rst +++ b/console/input.rst @@ -221,10 +221,6 @@ There are five option variants you can use: Accept either the flag (e.g. ``--yell``) or its negation (e.g. ``--no-yell``). -.. versionadded:: 5.3 - - The ``InputOption::VALUE_NEGATABLE`` constant was introduced in Symfony 5.3. - You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or ``VALUE_OPTIONAL`` like this:: diff --git a/console/lockable_trait.rst b/console/lockable_trait.rst index e3c26372cfe..02f635f5788 100644 --- a/console/lockable_trait.rst +++ b/console/lockable_trait.rst @@ -43,8 +43,4 @@ that adds two convenient methods to lock and release commands:: } } -.. versionadded:: 5.1 - - The ``Command::SUCCESS`` constant was introduced in Symfony 5.1. - .. _`locks`: https://en.wikipedia.org/wiki/Lock_(computer_science) diff --git a/console/style.rst b/console/style.rst index c680e3703df..b4bf70e2820 100644 --- a/console/style.rst +++ b/console/style.rst @@ -342,10 +342,6 @@ Result Methods 'Consectetur adipiscing elit', ]); -.. versionadded:: 5.2 - - The ``info()`` method was introduced in Symfony 5.2. - :method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::warning` It displays the given string or array of strings highlighted as a warning message (with a red background and the ``[WARNING]`` label). It's meant to be diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index 2c465096f0b..c2b6d16fba3 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -174,32 +174,32 @@ If you are documenting a brand new feature, a change or a deprecation that's been made in Symfony, you should precede your description of the change with the corresponding directive and a short description: -For a new feature or a behavior change use the ``.. versionadded:: 5.x`` +For a new feature or a behavior change use the ``.. versionadded:: 6.x`` directive: .. code-block:: rst - .. versionadded:: 5.2 + .. versionadded:: 6.2 - ... ... ... was introduced in Symfony 5.2. + ... ... ... was introduced in Symfony 6.2. If you are documenting a behavior change, it may be helpful to *briefly* describe how the behavior has changed: .. code-block:: rst - .. versionadded:: 5.2 + .. versionadded:: 6.2 - ... ... ... was introduced in Symfony 5.2. Prior to this, + ... ... ... was introduced in Symfony 6.2. Prior to this, ... ... ... ... ... ... ... ... . -For a deprecation use the ``.. deprecated:: 5.x`` directive: +For a deprecation use the ``.. deprecated:: 6.x`` directive: .. code-block:: rst - .. deprecated:: 5.2 + .. deprecated:: 6.2 - ... ... ... was deprecated in Symfony 5.2. + ... ... ... was deprecated in Symfony 6.2. Whenever a new major version of Symfony is released (e.g. 6.0, 7.0, etc), a new branch of the documentation is created from the ``master`` branch. diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 62d5c182c1e..065044a1b24 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -81,12 +81,6 @@ and what headers your reverse proxy uses to send information: ; }; -.. deprecated:: 5.2 - - In previous Symfony versions, the above example used ``HEADER_X_FORWARDED_ALL`` - to trust all "X-Forwarded-" headers, but that constant is deprecated since - Symfony 5.2 in favor of the individual ``HEADER_X_FORWARDED_*`` constants. - .. caution:: Enabling the ``Request::HEADER_X_FORWARDED_HOST`` option exposes the @@ -97,13 +91,6 @@ The Request object has several ``Request::HEADER_*`` constants that control exac *which* headers from your reverse proxy are trusted. The argument is a bit field, so you can also pass your own value (e.g. ``0b00110``). -.. versionadded:: 5.2 - - The feature to configure trusted proxies and headers with ``trusted_proxies`` - and ``trusted_headers`` options was introduced in Symfony 5.2. In earlier - Symfony versions you needed to use the ``Request::setTrustedProxies()`` - method in the ``public/index.php`` file. - .. caution:: The "trusted proxies" feature does not work as expected when using the diff --git a/doctrine/events.rst b/doctrine/events.rst index abe574a1867..f8029b3fe2b 100644 --- a/doctrine/events.rst +++ b/doctrine/events.rst @@ -524,10 +524,6 @@ can do it in the service configuration: ; }; -.. versionadded:: 5.3 - - Subscriber priority was introduced in Symfony 5.3. - .. tip:: Symfony loads (and instantiates) Doctrine subscribers whenever the diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 794a09bb83b..62880a973af 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -220,8 +220,6 @@ a "main" request or a "sub request":: { public function onKernelRequest(RequestEvent $event) { - // The isMainRequest() method was introduced in Symfony 5.3. - // In previous versions it was called isMasterRequest() if (!$event->isMainRequest()) { // don't do anything if it's not the main request return; @@ -331,10 +329,6 @@ or can get everything which partial matches the event name: $ php bin/console debug:event-dispatcher kernel // matches "kernel.exception", "kernel.response" etc. $ php bin/console debug:event-dispatcher Security // matches "Symfony\Component\Security\Http\Event\CheckPassportEvent" -.. versionadded:: 5.3 - - The ability to match partial event names was introduced in Symfony 5.3. - The :doc:`new authenticator-based Security ` system adds an event dispatcher per firewall. Use the ``--dispatcher`` option to get the registered listeners for a particular event dispatcher: @@ -343,10 +337,6 @@ get the registered listeners for a particular event dispatcher: $ php bin/console debug:event-dispatcher --dispatcher=security.event_dispatcher.main -.. versionadded:: 5.3 - - The ``dispatcher`` option was introduced in Symfony 5.3. - Learn more ---------- diff --git a/form/bootstrap5.rst b/form/bootstrap5.rst index 599f49bcb47..7b758794d57 100644 --- a/form/bootstrap5.rst +++ b/form/bootstrap5.rst @@ -1,10 +1,6 @@ Bootstrap 5 Form Theme ====================== -.. versionadded:: 5.3 - - The Bootstrap 5 Form Theme was introduced in Symfony 5.3. - Symfony provides several ways of integrating Bootstrap into your application. The most straightforward way is to add the required ```` and `` The major benefit of submitting the whole form to just extract the updated From 72443757f33dabb988cdeccd3f98127e4f7bbe82 Mon Sep 17 00:00:00 2001 From: Benjamin Zaslavsky Date: Thu, 20 Apr 2023 10:25:46 +0200 Subject: [PATCH 0801/1913] [HttpClient] Add doc for multiple `base_uri` as array --- http_client.rst | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/http_client.rst b/http_client.rst index f507573ce2c..e0742183175 100644 --- a/http_client.rst +++ b/http_client.rst @@ -731,6 +731,59 @@ The ``RetryableHttpClient`` uses a decide if the request should be retried, and to define the waiting time between each retry. +Retry Over Several Base URIs +............................ + +.. versionadded:: 6.3 + + The multiple ``base_uri`` feature was added in Symfony 6.3. + +The ``RetryableHttpClient`` can be configured to use multiple base URIs. This +feature provides increased flexibility and reliability for making HTTP +requests. Pass an array of base URIs as option ``base_uri`` when making a +request:: + + $response = $client->request('GET', 'some-page', [ + 'base_uri' => [ + // first request will use this base URI + 'https://example.com/a/', + // if first request fails, the following base URI will be used + 'https://example.com/b/', + ], + ]); + +When the number of retries is higher than the number of base URIs, the +last base URI will be used for the remaining retries. + +If you want to shuffle the order of base URIs for each retry attempt, nest the +base URIs you want to shuffle in an additional array:: + + $response = $client->request('GET', 'some-page', [ + 'base_uri' => [ + [ + // a single random URI from this array will be used for the first request + 'https://example.com/a/', + 'https://example.com/b/', + ], + // non-nested base URIs are used in order + 'https://example.com/c/', + ], + ]); + +This feature allows for a more randomized approach to handling retries, +reducing the likelihood of repeatedly hitting the same failed base URI. + +By using a nested array for the base URI, you can use this feature +to distribute the load among many nodes in a cluster of servers. + +You can also configure the array of base URIs using the ``withOptions()`` +method:: + + $client = $client->withOptions(['base_uri' => [ + 'https://example.com/a/', + 'https://example.com/b/', + ]]); + HTTP Proxies ~~~~~~~~~~~~ From 7ccec465fddd3ef50535d97f0ba8f3933efc49f4 Mon Sep 17 00:00:00 2001 From: MatTheCat Date: Fri, 21 Apr 2023 14:21:06 +0200 Subject: [PATCH 0802/1913] Fix XML tag array attribute example --- service_container/tags.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/service_container/tags.rst b/service_container/tags.rst index 94fb0e9e1c8..b37827f0cb2 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -481,8 +481,10 @@ To answer this, change the service declaration: - sendmail - anotherAlias + + sendmail + anotherAlias + From 93d4c89dd06659d6731c23b2cae19e62df89be4e Mon Sep 17 00:00:00 2001 From: Jeremy Jumeau Date: Fri, 21 Apr 2023 14:23:49 +0200 Subject: [PATCH 0803/1913] Fix syntax in code example with promoted attribute --- service_container/service_decoration.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst index b68da08d47a..7dc3b9fe866 100644 --- a/service_container/service_decoration.rst +++ b/service_container/service_decoration.rst @@ -153,7 +153,8 @@ automatically changed to ``'.inner'``): class DecoratingMailer { public function __construct( - private #[MapDecorated] $inner, + #[MapDecorated] + private $inner, ) { } From 8a9c669d262b3acab74e79894675de7e2f75312a Mon Sep 17 00:00:00 2001 From: Ldiro <35108257+Ldiro@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:51:21 +0200 Subject: [PATCH 0804/1913] Delete depreciations code examples from workflow-and-state-machine.rst Hi ! Some code examples contains depreciations since sf 6.2 or are not explicit enough in my humble opinion. Here's a little change that I propose to make this page a little bit more clear / up to date. --- workflow/workflow-and-state-machine.rst | 44 ++++++++----------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/workflow/workflow-and-state-machine.rst b/workflow/workflow-and-state-machine.rst index 5dcd1f77755..3884af25059 100644 --- a/workflow/workflow-and-state-machine.rst +++ b/workflow/workflow-and-state-machine.rst @@ -249,51 +249,28 @@ Below is the configuration for the pull request state machine. ->to(['review']); }; -In a Symfony application using the -:ref:`default services.yaml configuration `, -you can get this state machine by injecting the Workflow registry service:: - - // ... - use App\Entity\PullRequest; - use Symfony\Component\Workflow\Registry; - - class SomeService - { - public function __construct( - private Registry $workflows, - ) { - } - - public function someMethod(PullRequest $pullRequest) - { - $stateMachine = $this->workflows->get($pullRequest, 'pull_request'); - $stateMachine->apply($pullRequest, 'wait_for_review'); - // ... - } - - // ... - } - Symfony automatically creates a service for each workflow (:class:`Symfony\\Component\\Workflow\\Workflow`) or state machine (:class:`Symfony\\Component\\Workflow\\StateMachine`) you -have defined in your configuration. This means that you can use ``workflow.pull_request`` -or ``state_machine.pull_request`` respectively in your service definitions -to access the proper service:: +have defined in your configuration. You can use the workflow inside a class by using +:doc:`service autowiring ` and using +``camelCased workflow name + Workflow`` as parameter name. If it is a state +machine type, use ``camelCased workflow name + StateMachine``:: // ... use App\Entity\PullRequest; - use Symfony\Component\Workflow\StateMachine; + use Symfony\Component\Workflow\WorkflowInterface; class SomeService { public function __construct( - private StateMachine $stateMachine, + // Symfony will inject the 'pull_request' state machine configured before + private WorkflowInterface $pullRequestWorkflow, ) { } public function someMethod(PullRequest $pullRequest) { - $this->stateMachine->apply($pullRequest, 'wait_for_review', [ + $this->pullRequestWorkflow->apply($pullRequest, 'wait_for_review', [ 'log_comment' => 'My logging comment for the wait for review transition.', ]); // ... @@ -302,6 +279,11 @@ to access the proper service:: // ... } + +.. versionadded:: 6.2 + + All workflows and state machines services are tagged since in Symfony 6.2. + Automatic and Manual Validation ------------------------------- From e753954862ff188c59f839837789f96da7eeca0b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 24 Apr 2023 19:36:40 +0200 Subject: [PATCH 0805/1913] [Validator] Update the name of a level in PasswordStrength constraint --- reference/constraints/PasswordStrength.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/reference/constraints/PasswordStrength.rst b/reference/constraints/PasswordStrength.rst index 2625cbc0f40..ce18f95c4f6 100644 --- a/reference/constraints/PasswordStrength.rst +++ b/reference/constraints/PasswordStrength.rst @@ -1,6 +1,10 @@ PasswordStrength ================ +.. versionadded:: 6.3 + + The ``PasswordStrength`` constraint was introduced in Symfony 6.3. + Validates that the given password has reached the minimum strength required by the constraint. @@ -15,7 +19,7 @@ Basic Usage The following constraint ensures that the ``rawPassword`` property of the ``User`` class reaches the minimum strength required by the constraint. -By default, the minimum required score is 2. +By default, the minimum required score is ``2``. .. configuration-block:: @@ -77,11 +81,12 @@ Available Options ``minScore`` ~~~~~~~~~~~~ -**type**: ``integer`` **default**: ``PasswordStrength::STRENGTH_REASONABLE`` (``2``) +**type**: ``integer`` **default**: ``PasswordStrength::STRENGTH_MEDIUM`` (``2``) The minimum required strength of the password. Available constants are: + * ``PasswordStrength::STRENGTH_WEAK`` = ``1`` -* ``PasswordStrength::STRENGTH_REASONABLE`` = ``2`` +* ``PasswordStrength::STRENGTH_MEDIUM`` = ``2`` * ``PasswordStrength::STRENGTH_STRONG`` = ``3`` * ``PasswordStrength::STRENGTH_VERY_STRONG`` = ``4`` From a2756508070354f26878d54244d80097aabcd5f9 Mon Sep 17 00:00:00 2001 From: Mickael Perraud Date: Wed, 26 Apr 2023 08:32:43 +0200 Subject: [PATCH 0806/1913] [Notifier] Add links to push bridges' README --- notifier.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/notifier.rst b/notifier.rst index 62feb32c5b0..e651e5b6dcd 100644 --- a/notifier.rst +++ b/notifier.rst @@ -405,7 +405,7 @@ integration with these push services: ================= ==================================== ================================================================================= Service Package DSN ================= ==================================== ================================================================================= -Engagespot ``symfony/engagespot-notifier`` ``engagespot://API_KEY@default?campaign_name=CAMPAIGN_NAME`` +`Engagespot`_ ``symfony/engagespot-notifier`` ``engagespot://API_KEY@default?campaign_name=CAMPAIGN_NAME`` `Expo`_ ``symfony/expo-notifier`` ``expo://Token@default`` `OneSignal`_ ``symfony/one-signal-notifier`` ``onesignal://APP_ID:API_KEY@default?defaultRecipientId=DEFAULT_RECIPIENT_ID`` ================= ==================================== ================================================================================= @@ -947,6 +947,7 @@ is dispatched. Listeners receive a .. _`Clickatell`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Clickatell/README.md .. _`ContactEveryone`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/ContactEveryone/README.md .. _`Discord`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Discord/README.md +.. _`Engagespot`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Engagespot/README.md .. _`Esendex`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Esendex/README.md .. _`Expo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Expo/README.md .. _`FakeChat`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/FakeChat/README.md @@ -970,11 +971,8 @@ is dispatched. Listeners receive a .. _`Mobyt`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Mobyt/README.md .. _`Nexmo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md .. _`Octopush`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Octopush/README.md -<<<<<<< HEAD .. _`OrangeSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OrangeSms/README.md -======= .. _`OneSignal`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OneSignal/README.md ->>>>>>> 5.4 .. _`OvhCloud`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OvhCloud/README.md .. _`RFC 3986`: https://www.ietf.org/rfc/rfc3986.txt .. _`RocketChat`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RocketChat/README.md From 4863ee5ded377e4ec34d99a71e1d7563b12ad1d4 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Apr 2023 09:00:40 +0200 Subject: [PATCH 0807/1913] Fix: Order --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index e651e5b6dcd..d28f69b1919 100644 --- a/notifier.rst +++ b/notifier.rst @@ -971,8 +971,8 @@ is dispatched. Listeners receive a .. _`Mobyt`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Mobyt/README.md .. _`Nexmo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md .. _`Octopush`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Octopush/README.md -.. _`OrangeSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OrangeSms/README.md .. _`OneSignal`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OneSignal/README.md +.. _`OrangeSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OrangeSms/README.md .. _`OvhCloud`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OvhCloud/README.md .. _`RFC 3986`: https://www.ietf.org/rfc/rfc3986.txt .. _`RocketChat`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RocketChat/README.md From aaff1e01ecf23cc5bd49a452783a66463f6f3228 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Apr 2023 09:02:13 +0200 Subject: [PATCH 0808/1913] Fix: Remove merge conflict --- notifier.rst | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/notifier.rst b/notifier.rst index 7c3d3c7f2f3..8cf2e0bc907 100644 --- a/notifier.rst +++ b/notifier.rst @@ -420,25 +420,15 @@ The push channel is used to send notifications to users by using :class:`Symfony\\Component\\Notifier\\Texter` classes. Symfony provides integration with these push services: -<<<<<<< HEAD -============== ==================================== ================================================================================= -Service Package DSN -============== ==================================== ================================================================================= -Engagespot ``symfony/engagespot-notifier`` ``engagespot://API_KEY@default?campaign_name=CAMPAIGN_NAME`` -Expo ``symfony/expo-notifier`` ``expo://Token@default`` -OneSignal ``symfony/one-signal-notifier`` ``onesignal://APP_ID:API_KEY@default?defaultRecipientId=DEFAULT_RECIPIENT_ID`` -PagerDuty ``symfony/pager-duty-notifier`` ``pagerduty://TOKEN@SUBDOMAIN`` -Pushover ``symfony/pushover-notifier`` ``pushover://USER_KEY:APP_TOKEN@default`` -============== ==================================== ================================================================================= -======= ================= ==================================== ================================================================================= Service Package DSN ================= ==================================== ================================================================================= `Engagespot`_ ``symfony/engagespot-notifier`` ``engagespot://API_KEY@default?campaign_name=CAMPAIGN_NAME`` `Expo`_ ``symfony/expo-notifier`` ``expo://Token@default`` `OneSignal`_ ``symfony/one-signal-notifier`` ``onesignal://APP_ID:API_KEY@default?defaultRecipientId=DEFAULT_RECIPIENT_ID`` +PagerDuty ``symfony/pager-duty-notifier`` ``pagerduty://TOKEN@SUBDOMAIN`` +Pushover ``symfony/pushover-notifier`` ``pushover://USER_KEY:APP_TOKEN@default`` ================= ==================================== ================================================================================= ->>>>>>> 6.2 .. versionadded:: 6.1 From 0f65b2c8b088ec49a595e523f77766bed4b17a11 Mon Sep 17 00:00:00 2001 From: Mickael Perraud Date: Wed, 26 Apr 2023 09:07:35 +0200 Subject: [PATCH 0809/1913] [Notifier] Add links to push bridges' README --- notifier.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index 8cf2e0bc907..1a601eb7cf7 100644 --- a/notifier.rst +++ b/notifier.rst @@ -426,8 +426,8 @@ Service Package DSN `Engagespot`_ ``symfony/engagespot-notifier`` ``engagespot://API_KEY@default?campaign_name=CAMPAIGN_NAME`` `Expo`_ ``symfony/expo-notifier`` ``expo://Token@default`` `OneSignal`_ ``symfony/one-signal-notifier`` ``onesignal://APP_ID:API_KEY@default?defaultRecipientId=DEFAULT_RECIPIENT_ID`` -PagerDuty ``symfony/pager-duty-notifier`` ``pagerduty://TOKEN@SUBDOMAIN`` -Pushover ``symfony/pushover-notifier`` ``pushover://USER_KEY:APP_TOKEN@default`` +`PagerDuty`_ ``symfony/pager-duty-notifier`` ``pagerduty://TOKEN@SUBDOMAIN`` +`Pushover`_ ``symfony/pushover-notifier`` ``pushover://USER_KEY:APP_TOKEN@default`` ================= ==================================== ================================================================================= .. versionadded:: 6.1 @@ -1002,7 +1002,9 @@ is dispatched. Listeners receive a .. _`OneSignal`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OneSignal/README.md .. _`OrangeSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OrangeSms/README.md .. _`OvhCloud`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OvhCloud/README.md +.. _`PagerDuty`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/PagerDuty/README.md .. _`Plivo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Plivo/README.md +.. _`Pushover`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Pushover/README.md .. _`RingCentral`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RingCentral/README.md .. _`RFC 3986`: https://www.ietf.org/rfc/rfc3986.txt .. _`RocketChat`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RocketChat/README.md From 7fed88b3698f82a3d5bb9115118df93dc01a643c Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Apr 2023 09:23:39 +0200 Subject: [PATCH 0810/1913] Sort --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index ab50022f61f..2086c08979e 100644 --- a/notifier.rst +++ b/notifier.rst @@ -976,6 +976,7 @@ is dispatched. Listeners receive a .. _`OvhCloud`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OvhCloud/README.md .. _`RFC 3986`: https://www.ietf.org/rfc/rfc3986.txt .. _`RocketChat`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RocketChat/README.md +.. _`SMSFactor`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/SmsFactor/README.md .. _`Sendberry`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Sendberry/README.md .. _`Sendinblue`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Sendinblue/README.md .. _`Sinch`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Sinch/README.md @@ -984,7 +985,6 @@ is dispatched. Listeners receive a .. _`SmsBiuras`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/SmsBiuras/README.md .. _`Smsapi`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Smsapi/README.md .. _`Smsc`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Smsc/README.md -.. _`SMSFactor`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/SmsFactor/README.md .. _`SpotHit`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/SpotHit/README.md .. _`Telegram`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Telegram/README.md .. _`Telnyx`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Telnyx/README.md From 2d158857fa900b0429959be2e056a128fce6f270 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Apr 2023 09:24:21 +0200 Subject: [PATCH 0811/1913] Sort --- notifier.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index 3eaf5037e8d..0480405cc4a 100644 --- a/notifier.rst +++ b/notifier.rst @@ -986,8 +986,8 @@ is dispatched. Listeners receive a .. _`Iqsms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Iqsms/README.md .. _`iSendPro`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Isendpro/README.md .. _`KazInfoTeh`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/KazInfoTeh/README.md -.. _`LightSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/LightSms/README.md .. _`LINE Notify`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/LineNotify/README.md +.. _`LightSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/LightSms/README.md .. _`LinkedIn`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/LinkedIn/README.md .. _`Mailjet`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Mailjet/README.md .. _`Mastodon`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Mastodon/README.md @@ -1005,8 +1005,8 @@ is dispatched. Listeners receive a .. _`PagerDuty`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/PagerDuty/README.md .. _`Plivo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Plivo/README.md .. _`Pushover`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Pushover/README.md -.. _`RingCentral`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RingCentral/README.md .. _`RFC 3986`: https://www.ietf.org/rfc/rfc3986.txt +.. _`RingCentral`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RingCentral/README.md .. _`RocketChat`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/RocketChat/README.md .. _`SMSFactor`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/SmsFactor/README.md .. _`Sendberry`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Sendberry/README.md From e77ba0eb61cf1531630ff5df25fa13ba24d7295b Mon Sep 17 00:00:00 2001 From: stiteca Date: Wed, 19 Apr 2023 22:54:22 +0200 Subject: [PATCH 0812/1913] Update rounding_mode.rst.inc Add PercentType into default \NumberFormatter::ROUND_HALFUP types --- reference/forms/types/options/rounding_mode.rst.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/forms/types/options/rounding_mode.rst.inc b/reference/forms/types/options/rounding_mode.rst.inc index 6262bd7a719..6333c751ff7 100644 --- a/reference/forms/types/options/rounding_mode.rst.inc +++ b/reference/forms/types/options/rounding_mode.rst.inc @@ -7,7 +7,7 @@ and ``\NumberFormatter::ROUND_HALFUP`` for ``MoneyType`` and ``NumberType`` * IntegerType **default**: ``\NumberFormatter::ROUND_DOWN`` -* MoneyType and NumberType +* MoneyType, NumberType and PercentType **default**: ``\NumberFormatter::ROUND_HALFUP`` From 2cc5a970a950e97af26a5c948b36d3311c04fb7a Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sun, 23 Apr 2023 10:45:53 +0200 Subject: [PATCH 0813/1913] [Security] Document `SecurityTokenValueResolver` for Security Token --- controller/value_resolver.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/controller/value_resolver.rst b/controller/value_resolver.rst index 89875f64c2a..37902d8a5be 100644 --- a/controller/value_resolver.rst +++ b/controller/value_resolver.rst @@ -169,6 +169,17 @@ In addition, some components, bridges and official bundles provide other value r user has a user class not matching the type-hinted class, an ``AccessDeniedException`` is thrown by the resolver to prevent access to the controller. +:class:`Symfony\\Component\\Security\\Http\\Controller\\SecurityTokenValueResolver` + Injects the object that represents the current logged in token if type-hinted + with ``TokenInterface`` or a class extending it. + + If the argument is not nullable and there is no logged in token, an ``HttpException`` with status code 401 + is thrown by the resolver to prevent access to the controller. + + .. versionadded:: 6.3 + + The ``SecurityTokenValueResolver`` was introduced in Symfony 6.3. + :class:`Symfony\\Bridge\\Doctrine\\ArgumentResolver\\EntityValueResolver` Automatically query for an entity and pass it as an argument to your controller. From 164b9dcbf843df096e282572a7875976b62b4f8a Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Apr 2023 10:39:15 +0200 Subject: [PATCH 0814/1913] Minor --- controller/value_resolver.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/value_resolver.rst b/controller/value_resolver.rst index 37902d8a5be..8f37ed09fe7 100644 --- a/controller/value_resolver.rst +++ b/controller/value_resolver.rst @@ -173,8 +173,8 @@ In addition, some components, bridges and official bundles provide other value r Injects the object that represents the current logged in token if type-hinted with ``TokenInterface`` or a class extending it. - If the argument is not nullable and there is no logged in token, an ``HttpException`` with status code 401 - is thrown by the resolver to prevent access to the controller. + If the argument is not nullable and there is no logged in token, an ``HttpException`` + with status code 401 is thrown by the resolver to prevent access to the controller. .. versionadded:: 6.3 From fde527f90a6f0939d1efb710c67217d0105bc108 Mon Sep 17 00:00:00 2001 From: Quentin Dreyer Date: Wed, 26 Apr 2023 11:10:43 +0200 Subject: [PATCH 0815/1913] fix: update AsMessageHandler fromTransport case --- messenger.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messenger.rst b/messenger.rst index 1110378c3e7..a1d76eb3e57 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2032,7 +2032,7 @@ To do this, add the ``from_transport`` option to each handler. For example:: use App\Message\UploadedImage; - #[AsMessageHandler(from_transport: 'image_transport')] + #[AsMessageHandler(fromTransport: 'image_transport')] class ThumbnailUploadedImageHandler { public function __invoke(UploadedImage $uploadedImage) @@ -2046,7 +2046,7 @@ And similarly:: // src/MessageHandler/NotifyAboutNewUploadedImageHandler.php // ... - #[AsMessageHandler(from_transport: 'async_priority_normal')] + #[AsMessageHandler(fromTransport: 'async_priority_normal')] class NotifyAboutNewUploadedImageHandler { // ... From 2fe03a4329ce934c758877311d0df38574b05583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 14 Apr 2023 16:14:45 +0200 Subject: [PATCH 0816/1913] [Serializer] Add `debug:serializer` command --- serializer.rst | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/serializer.rst b/serializer.rst index 22b0a7b567c..94be1fa0540 100644 --- a/serializer.rst +++ b/serializer.rst @@ -491,6 +491,50 @@ value: $framework->serializer()->nameConverter('serializer.name_converter.camel_case_to_snake_case'); }; +Debugging the Serializer +------------------------ + +Use the ``debug:serializer`` command to dump the serializer metadata of a +given class: + +.. code-block:: terminal + + $ php bin/console debug:serializer 'App\Entity\Book' + + App\Entity\Book + --------------- + + +----------+------------------------------------------------------------+ + | Property | Options | + +----------+------------------------------------------------------------+ + | name | [ | + | | "groups" => [ | + | | "book:read", | + | | "book:write", | + | | ] | + | | "maxDepth" => 1, | + | | "serializedName" => "book_name" | + | | "ignore" => false | + | | "normalizationContexts" => [], | + | | "denormalizationContexts" => [] | + | | ] | + | isbn | [ | + | | "groups" => [ | + | | "book:read", | + | | ] | + | | "maxDepth" => null, | + | | "serializedName" => null | + | | "ignore" => false | + | | "normalizationContexts" => [], | + | | "denormalizationContexts" => [] | + | | ] | + +----------+------------------------------------------------------------+ + +.. versionadded:: 6.3 + + The debug:serializer`` command was introduced in Symfony 6.3. + + Going Further with the Serializer --------------------------------- From 07794a2cbb269c802e57220b45f916245791243c Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Apr 2023 19:44:18 +0200 Subject: [PATCH 0817/1913] Fix build --- deployment/proxies.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index b2412b052e6..18377068cd6 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -82,12 +82,6 @@ and what headers your reverse proxy uses to send information: ; }; -.. deprecated:: 5.2 - - In previous Symfony versions, the above example used ``HEADER_X_FORWARDED_ALL`` - to trust all "X-Forwarded-" headers, but that constant is deprecated since - Symfony 5.2 in favor of the individual ``HEADER_X_FORWARDED_*`` constants. - .. caution:: Enabling the ``Request::HEADER_X_FORWARDED_HOST`` option exposes the From b68944c295306cce5de546541614127f07b7310d Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sun, 23 Apr 2023 11:18:29 +0200 Subject: [PATCH 0818/1913] [HttpClient] Add `JsonMockResponse` --- http_client.rst | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/http_client.rst b/http_client.rst index e0742183175..1a51ee90084 100644 --- a/http_client.rst +++ b/http_client.rst @@ -740,7 +740,7 @@ Retry Over Several Base URIs The ``RetryableHttpClient`` can be configured to use multiple base URIs. This feature provides increased flexibility and reliability for making HTTP -requests. Pass an array of base URIs as option ``base_uri`` when making a +requests. Pass an array of base URIs as option ``base_uri`` when making a request:: $response = $client->request('GET', 'some-page', [ @@ -752,7 +752,7 @@ request:: ], ]); -When the number of retries is higher than the number of base URIs, the +When the number of retries is higher than the number of base URIs, the last base URI will be used for the remaining retries. If you want to shuffle the order of base URIs for each retry attempt, nest the @@ -770,13 +770,13 @@ base URIs you want to shuffle in an additional array:: ], ]); -This feature allows for a more randomized approach to handling retries, +This feature allows for a more randomized approach to handling retries, reducing the likelihood of repeatedly hitting the same failed base URI. -By using a nested array for the base URI, you can use this feature +By using a nested array for the base URI, you can use this feature to distribute the load among many nodes in a cluster of servers. -You can also configure the array of base URIs using the ``withOptions()`` +You can also configure the array of base URIs using the ``withOptions()`` method:: $client = $client->withOptions(['base_uri' => [ @@ -2032,6 +2032,30 @@ Then configure Symfony to use your callback: ; }; +To return json, you would normally do:: + + use Symfony\Component\HttpClient\Response\MockResponse; + + $response = new MockResponse(json_encode([ + 'foo' => 'bar', + ]), [ + 'response_headers' => [ + 'content-type' => 'application/json', + ], + ]); + +You can use :class:`Symfony\\Component\\HttpClient\\Response\\JsonMockResponse` instead:: + + use Symfony\Component\HttpClient\Response\JsonMockResponse; + + $response = new JsonMockResponse([ + 'foo' => 'bar', + ]); + +.. versionadded:: 6.3 + + The ``JsonMockResponse`` was introduced in Symfony 6.3. + Testing Request Data ~~~~~~~~~~~~~~~~~~~~ From b478e211735d72f4ccbcfbfcb6b35c9bee9fc54e Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Thu, 20 Apr 2023 11:33:34 -0400 Subject: [PATCH 0819/1913] [HttpFoundation] document `Request::getPayload()` --- components/http_foundation.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 0711d4764e3..6f6cb5b524e 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -216,6 +216,18 @@ If the request body is a JSON string, it can be accessed using $data = $request->toArray(); +If the request data could be ``$_POST`` data *or* a JSON string, you can use +the :method:`Symfony\\Component\\HttpFoundation\\Request::getPayload` method +which returns an instance of :class:`Symfony\\Component\\HttpFoundation\\InputBag` +wrapping this data:: + + $data = $request->getPayload(); + +.. versionadded:: 6.3 + + The :method:`Symfony\\Component\\HttpFoundation\\Request::getPayload` + method was introduced in Symfony 6.3. + Identifying a Request ~~~~~~~~~~~~~~~~~~~~~ From 0df46f729b83e3d5865325a20e8fb4eac08c0ca1 Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Fri, 21 Apr 2023 13:57:57 +0200 Subject: [PATCH 0820/1913] [Routing] Backed Enum as route parameter --- routing.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/routing.rst b/routing.rst index be3e6bf49a9..799112bcaf1 100644 --- a/routing.rst +++ b/routing.rst @@ -1245,6 +1245,35 @@ A possible solution is to change the parameter requirements to be more permissiv as the token and the format will be empty. This can be solved by replacing the ``.+`` requirement by ``[^.]+`` to allow any character except dots. +Backed Enum as Parameter +~~~~~~~~~~~~~~~~~~~~~~~~ + +PHP 8.1 add support for Backed Enum, they can be used as route parameter and +automatically converted to their value by Symfony. + +.. versionadded:: 6.3 + + Using a `\BackedEnum` as route parameter is available since Symfony 6.3. + +.. code-block:: php-attributes + + // src/Controller/DefaultController.php + namespace App\Controller; + + use App\Enum\SuitsEnum; + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\Routing\Annotation\Route; + + class DefaultController extends AbstractController + { + #[Route('/cards/{suit}', name: 'cards_suit')] + public function list(SuitsEnum $suit = SuitsEnum::Diamonds): Response + { + // ... + } + } + .. _routing-alias: Route Aliasing From bfe27fc4af0da54a6e69eb75adf2eee10202b558 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 28 Apr 2023 16:47:51 +0200 Subject: [PATCH 0821/1913] Tweaks --- routing.rst | 59 +++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/routing.rst b/routing.rst index 799112bcaf1..20ab592854d 100644 --- a/routing.rst +++ b/routing.rst @@ -985,6 +985,35 @@ Check out the :ref:`Doctrine param conversion documentation Date: Tue, 2 May 2023 09:33:38 +0200 Subject: [PATCH 0822/1913] Fix the file name of a controller in a code example --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index 20ab592854d..3d47668a9b6 100644 --- a/routing.rst +++ b/routing.rst @@ -997,7 +997,7 @@ convert them automatically to their scalar values. .. code-block:: php-attributes - // src/Controller/DefaultController.php + // src/Controller/OrderController.php namespace App\Controller; use App\Enum\OrderStatusEnum; From 24f8c0fabcd1e868b449d0515633cb46d46074c4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 2 May 2023 13:48:00 +0200 Subject: [PATCH 0823/1913] Remove mentions of httplug's factories --- http_client.rst | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/http_client.rst b/http_client.rst index 1a51ee90084..693fc3dc59e 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1619,47 +1619,10 @@ The `HTTPlug`_ v1 specification was published before PSR-18 and is superseded by it. As such, you should not use it in newly written code. The component is still interoperable with libraries that require it thanks to the :class:`Symfony\\Component\\HttpClient\\HttplugClient` class. Similarly to -:class:`Symfony\\Component\\HttpClient\\Psr18Client` implementing relevant parts of PSR-17, -``HttplugClient`` also implements the factory methods defined in the related -``php-http/message-factory`` package. +:class:`Symfony\\Component\\HttpClient\\Psr18Client`, ``HttplugClient`` also +implements relevant parts of PSR-17. -.. code-block:: terminal - - # Let's suppose php-http/httplug is already required by the lib you want to use - - # installs an efficient implementation of response and stream factories - # with autowiring aliases provided by Symfony Flex - $ composer require nyholm/psr7 - - # alternatively, install the php-http/discovery package to auto-discover - # any already installed implementations from common vendors: - # composer require php-http/discovery - -Let's say you want to instantiate a class with the following constructor, -that requires HTTPlug dependencies:: - - use Http\Client\HttpClient; - use Http\Message\RequestFactory; - use Http\Message\StreamFactory; - - class SomeSdk - { - public function __construct( - HttpClient $httpClient, - RequestFactory $requestFactory, - StreamFactory $streamFactory - ) - // [...] - } - -Because ``HttplugClient`` implements the three interfaces, you can use it this way:: - - use Symfony\Component\HttpClient\HttplugClient; - - $httpClient = new HttplugClient(); - $apiClient = new SomeSdk($httpClient, $httpClient, $httpClient); - -If you'd like to work with promises, ``HttplugClient`` also implements the +If you'd like to work with promises, ``HttplugClient`` implements the ``HttpAsyncClient`` interface. To use it, you need to install the ``guzzlehttp/promises`` package: From 91bbf2a31d1de07633a6efa9de9b00c87d626e92 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 3 May 2023 09:59:16 +0200 Subject: [PATCH 0824/1913] Remove trailing whitespace --- doctrine.rst | 4 ++-- form/create_custom_field_type.rst | 2 +- form/form_collections.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doctrine.rst b/doctrine.rst index f3f7b624995..cca47d1b0f4 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -390,8 +390,8 @@ Take a look at the previous example in more detail: .. _doctrine-entity-manager: -* **line 13** The ``EntityManagerInterface $entityManager`` argument tells Symfony - to :ref:`inject the Entity Manager service ` into +* **line 13** The ``EntityManagerInterface $entityManager`` argument tells Symfony + to :ref:`inject the Entity Manager service ` into the controller method. This object is responsible for saving objects to, and fetching objects from, the database. diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index 003de0c6f3a..6729e0974ad 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -268,7 +268,7 @@ to define, validate and process their values:: // optionally you can transform the given values for the options to // simplify the further processing of those options - $resolver->setNormalizer('allowed_states', static function (Options $options, $states): ?array + $resolver->setNormalizer('allowed_states', static function (Options $options, $states): ?array { if (null === $states) { return $states; diff --git a/form/form_collections.rst b/form/form_collections.rst index e320d85989f..4fd05bc311d 100644 --- a/form/form_collections.rst +++ b/form/form_collections.rst @@ -355,7 +355,7 @@ Then create the controller: .. code-block:: javascript // assets/controllers/form-collection_controller.js - + import { Controller } from '@hotwired/stimulus'; export default class extends Controller { @@ -371,7 +371,7 @@ Then create the controller: const item = document.createElement('li'); item.innerHTML = this.prototypeValue.replace(/__name__/g, this.indexValue); this.collectionContainerTarget.appendChild(item); - this.indexValue++; + this.indexValue++; } } From 4fd5f27920e020dd058be16227bc6233ab761dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 14 Apr 2023 16:17:53 +0200 Subject: [PATCH 0825/1913] [Mailer] Document `EsmtpTransport::setAuthenticators()` --- mailer.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mailer.rst b/mailer.rst index 8552a13f999..ab4b334700e 100644 --- a/mailer.rst +++ b/mailer.rst @@ -286,6 +286,29 @@ the application or when using a self-signed certificate:: $dsn = 'smtp://user:pass@smtp.example.com?verify_peer=0'; +Overriding default SMTP authenticators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, SMTP transports will try to login using all authentication methods +available on the SMTP server, one after the other. In some cases, it may be useful +to redefine the supported authentication methods to ensure that the preferred method +will be used first. +This can be done from ``EsmtpTransport`` constructor or using the ``setAuthenticators()`` method:: + + use Symfony\Component\Mailer\Transport\Smtp\Auth\XOAuth2Authenticator; + use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; + + $transport = new EsmtpTransport( + host: 'oauth-smtp.domain.tld', + authenticators: [new XOAuth2Authenticator()] + ); + $transport->setAuthenticators([new XOAuth2Authenticator()]); + + .. versionadded:: 6.3 + + The ``$authenticators`` constructor parameter and the ``setAuthenticators()`` method + were introduced in Symfony 6.3. + Other Options ~~~~~~~~~~~~~ From ac0ea0c7805ba96bd8fdebc0ee608b78b9cc6836 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 5 May 2023 16:10:15 +0200 Subject: [PATCH 0826/1913] Tweaks --- mailer.rst | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mailer.rst b/mailer.rst index ab4b334700e..c40cf65d24f 100644 --- a/mailer.rst +++ b/mailer.rst @@ -290,24 +290,31 @@ Overriding default SMTP authenticators ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, SMTP transports will try to login using all authentication methods -available on the SMTP server, one after the other. In some cases, it may be useful -to redefine the supported authentication methods to ensure that the preferred method -will be used first. -This can be done from ``EsmtpTransport`` constructor or using the ``setAuthenticators()`` method:: +available on the SMTP server, one after the other. In some cases, it may be +useful to redefine the supported authentication methods to ensure that the +preferred method will be used first. + +This can be done from ``EsmtpTransport`` constructor or using the +``setAuthenticators()`` method:: use Symfony\Component\Mailer\Transport\Smtp\Auth\XOAuth2Authenticator; use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; + // Choose one of these two options: + + // Option 1: pass the authenticators to the constructor $transport = new EsmtpTransport( host: 'oauth-smtp.domain.tld', authenticators: [new XOAuth2Authenticator()] ); + + // Option 2: call a method to redefine the authenticators $transport->setAuthenticators([new XOAuth2Authenticator()]); - .. versionadded:: 6.3 +.. versionadded:: 6.3 - The ``$authenticators`` constructor parameter and the ``setAuthenticators()`` method - were introduced in Symfony 6.3. + The ``$authenticators`` constructor parameter and the ``setAuthenticators()`` + method were introduced in Symfony 6.3. Other Options ~~~~~~~~~~~~~ From f6984ab62248747635cb3f83a4b74357818ff953 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 5 May 2023 16:49:43 +0200 Subject: [PATCH 0827/1913] [FrameworkBundle] Update the http_method_override default value explanation --- reference/configuration/framework.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 5a71b31b122..aff01af4c9c 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -176,7 +176,7 @@ bootstrap the Symfony framework on a cache hit. http_method_override ~~~~~~~~~~~~~~~~~~~~ -**type**: ``boolean`` **default**: ``true`` +**type**: ``boolean`` **default**: (see explanation below) This determines whether the ``_method`` request parameter is used as the intended HTTP method on POST requests. If enabled, the @@ -184,6 +184,13 @@ intended HTTP method on POST requests. If enabled, the method gets called automatically. It becomes the service container parameter named ``kernel.http_method_override``. +The **default value** is: + +* ``true``, if you have an existing application that you've upgraded from an older + Symfony version without resyncing the :doc:`Symfony Flex ` recipes; +* ``false``, if you've created a new Symfony application or updated the Symfony + Flex recipes. This is also the default value starting from Symfony 7.0. + .. seealso:: :ref:`Changing the Action and HTTP Method ` of From 71a4ef468a5312692451db6bc2729d5c6e80dad8 Mon Sep 17 00:00:00 2001 From: Christian Kolb Date: Fri, 5 May 2023 17:44:20 +0200 Subject: [PATCH 0828/1913] Rename context flag --- components/serializer.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 84b5e8775b6..1b165134f52 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -1242,11 +1242,11 @@ to ``true``:: $result = $normalizer->normalize($dummy, 'json', [AbstractObjectNormalizer::SKIP_NULL_VALUES => true]); // ['bar' => 'notNull'] -Preventing ``null`` Value Fallback for Nullable Properties ----------------------------------------------------------- +Require all Properties +---------------------- By default, the Serializer will add ``null`` to nullable properties when the parameters for those are not provided. -You can change this behavior by setting the ``AbstractNormalizer::PREVENT_NULLABLE_FALLBACK`` context option +You can change this behavior by setting the ``AbstractNormalizer::REQUIRE_ALL_PROPERTIES`` context option to ``true``:: class Dummy @@ -1261,7 +1261,7 @@ to ``true``:: $data = ['foo' => 'notNull']; $normalizer = new ObjectNormalizer(); - $result = $normalizer->denormalize($data, Dummy::class, 'json', [AbstractNormalizer::PREVENT_NULLABLE_FALLBACK => true]); + $result = $normalizer->denormalize($data, Dummy::class, 'json', [AbstractNormalizer::REQUIRE_ALL_PROPERTIES => true]); // throws Symfony\Component\Serializer\Exception\MissingConstructorArgumentException .. versionadded:: 6.3 From 7a20fdf335d271351dc8fbe571397911182a71f9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 10 May 2023 12:32:23 +0200 Subject: [PATCH 0829/1913] [Intl] Document the compress binary --- components/intl.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/components/intl.rst b/components/intl.rst index f4560427a91..67813ef7951 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -402,6 +402,21 @@ platforms:: Combine this emoji transliterator with the :ref:`Symfony String slugger ` to improve the slugs of contents that include emojis (e.g. for URLs). +The data needed to store the transliteration of all emojis (~5,000) into all +languages take a considerable disk space. If you need to save disk space (e.g. +because you deploy to some service with tight size constraints), run this command +(e.g. as an automated script after ``composer install``) to compress the internal +Symfony emoji files using the PHP ``zlib`` extension: + +.. code-block:: terminal + + # adjust the path to the 'compress' binary based on your application installation + $ php ./vendor/symfony/intl/Resources/bin/compress + +.. versionadded:: 6.3 + + The ``compress`` binary was introduced in Symfony 6.3. + Learn more ---------- From 5b53159eb1ba7d572234074f2cbab1d4a7644ec7 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon Date: Fri, 25 Nov 2022 09:50:01 +0100 Subject: [PATCH 0830/1913] [Security] Document `access_token.token_handler.oidc_user_info` --- security/access_token.rst | 437 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 437 insertions(+) diff --git a/security/access_token.rst b/security/access_token.rst index d5d607dbcb0..2e6438a633e 100644 --- a/security/access_token.rst +++ b/security/access_token.rst @@ -343,6 +343,443 @@ and configure the service ID as the ``success_handler``: ``failure_handler`` option and create a class that implements :class:`Symfony\\Component\\Security\\Http\\Authentication\\AuthenticationFailureHandlerInterface`. +Using OpenID Connect (OIDC) +--------------------------- + +`OpenID Connect (OIDC)`_ is the third generation of OpenID technology and it's a RESTful HTTP API that uses +JSON as its data format. OpenID Connect is an authentication layer on top of the OAuth 2.0 authorization framework. +It allows to verify the identity of an end user based on the authentication performed by an authorization server. + +.. caution:: + + This feature is experimental and could change or be removed at any time without prior notice. + +1) Configure the OidcUserInfoTokenHandler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 6.3 + + The ``OidcUserInfoTokenHandler`` class was introduced in Symfony 6.3. + +.. note:: + + The ``OidcUserInfoTokenHandler`` requires ``symfony/http-client`` package: + + .. code-block:: terminal + + $ composer require symfony/http-client + +Symfony provides a generic OidcUserInfoTokenHandler to call your OIDC server and retrieve the user info: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + access_token: + token_handler: + oidc_user_info: + client: + base_uri: https://www.example.com/realms/demo/protocol/openid-connect/userinfo + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + $security->firewall('main') + ->accessToken() + ->tokenHandler() + ->oidcUserInfo() + ->client() + ->baseUri('https://www.example.com/realms/demo/protocol/openid-connect/userinfo') + ; + }; + +.. tip:: + + Following the `OpenID Connect Specification`_, the `sub` claim + is used as user identifier by default. To use another claim, + specify it on the configuration: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + access_token: + token_handler: + oidc_user_info: + claim: email + client: + base_uri: https://www.example.com/realms/demo/protocol/openid-connect/userinfo + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + $security->firewall('main') + ->accessToken() + ->tokenHandler() + ->oidcUserInfo() + ->claim('email') + ->client() + ->baseUri('https://www.example.com/realms/demo/protocol/openid-connect/userinfo') + ; + }; + +.. tip:: + + The ``oidc_user_info`` token handler automatically creates + an HTTP client with the specified configuration. If you + prefer using your own client, you can specify the service + name via the ``client`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + access_token: + token_handler: + oidc_user_info: + client: oidc.client + + .. code-block:: xml + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + $security->firewall('main') + ->accessToken() + ->tokenHandler() + ->oidcUserInfo() + ->client('oidc.client') + ; + }; + +By default, the ``OidcUserInfoTokenHandler`` creates an OidcUser with the claims. To create your own User from the +claims, you must :doc:`create your own UserProvider `:: + + // src/Security/Core/User/OidcUserProvider.php + use Symfony\Component\Security\Core\User\AttributesBasedUserProviderInterface; + + class OidcUserProvider implements AttributesBasedUserProviderInterface + { + public function loadUserByIdentifier(string $identifier, array $attributes = []): UserInterface + { + // do some magic + } + } + +2) Configure the OidcTokenHandler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 6.3 + + The ``OidcTokenHandler`` class was introduced in Symfony 6.3. + +.. note:: + + The ``OidcTokenHandler`` requires ``web-token/jwt-signature``, ``web-token/jwt-checker`` and + ``web-token/jwt-signature-algorithm-ecdsa`` packages: + + .. code-block:: terminal + + $ composer require web-token/jwt-signature + $ composer require web-token/jwt-checker + $ composer require web-token/jwt-signature-algorithm-ecdsa + +Symfony provides a generic OidcTokenHandler to decode your token, validate it and retrieve the user info from it: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + access_token: + token_handler: + oidc: + signature: + # Algorithm used to sign the JWS + algorithm: 'HS256' + # A JSON-encoded JWK + key: '{"kty":"...","k":"..."}' + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + $security->firewall('main') + ->accessToken() + ->tokenHandler() + ->oidc() + ->signature() + ->algorithm('HS256') + ->key('{"kty":"...","k":"..."}') + ; + }; + +.. tip:: + + Following the `OpenID Connect Specification`_, the `sub` claim + is used by default as user identifier. To use another claim, + specify it on the configuration: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + access_token: + token_handler: + oidc: + claim: email + signature: + algorithm: 'HS256' + key: '{"kty":"...","k":"..."}' + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + $security->firewall('main') + ->accessToken() + ->tokenHandler() + ->oidc() + ->claim('email') + ->signature() + ->algorithm('HS256') + ->key('{"kty":"...","k":"..."}') + ; + }; + +.. tip:: + + The ``oidc`` token handler also check for the token audience. + By default, this audience is optional. To enable this check, + add the ``audience`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + access_token: + token_handler: + oidc: + audience: 'My audience' + signature: + algorithm: 'HS256' + key: '{"kty":"...","k":"..."}' + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + use Symfony\Config\SecurityConfig; + + return static function (SecurityConfig $security) { + $security->firewall('main') + ->accessToken() + ->tokenHandler() + ->oidc() + ->audience('My audience') + ->signature() + ->algorithm('HS256') + ->key('{"kty":"...","k":"..."}') + ; + }; + +By default, the OidcTokenHandler creates an OidcUser with the claims. To create your own User from the claims, +you must :doc:`create your own UserProvider `:: + + // src/Security/Core/User/OidcUserProvider.php + use Symfony\Component\Security\Core\User\AttributesBasedUserProviderInterface; + + class OidcUserProvider implements AttributesBasedUserProviderInterface + { + public function loadUserByIdentifier(string $identifier, array $attributes = []): UserInterface + { + // do some magic + } + } + .. _`JSON Web Tokens (JWT)`: https://datatracker.ietf.org/doc/html/rfc7519 .. _`SAML2 (XML structures)`: https://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html .. _`RFC6750`: https://datatracker.ietf.org/doc/html/rfc6750 +.. _`OpenID Connect Specification`: https://openid.net/specs/openid-connect-core-1_0.html +.. _`OpenID Connect (OIDC)`: https://en.wikipedia.org/wiki/OpenID#OpenID_Connect_(OIDC) From 51e170b6c2185e7d9f089f39222504c0ebd7d31e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 10 May 2023 13:03:57 +0200 Subject: [PATCH 0831/1913] Tweaks --- security/access_token.rst | 83 ++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/security/access_token.rst b/security/access_token.rst index 8bc7cc62b3e..6114d076637 100644 --- a/security/access_token.rst +++ b/security/access_token.rst @@ -343,9 +343,11 @@ and configure the service ID as the ``success_handler``: Using OpenID Connect (OIDC) --------------------------- -`OpenID Connect (OIDC)`_ is the third generation of OpenID technology and it's a RESTful HTTP API that uses -JSON as its data format. OpenID Connect is an authentication layer on top of the OAuth 2.0 authorization framework. -It allows to verify the identity of an end user based on the authentication performed by an authorization server. +`OpenID Connect (OIDC)`_ is the third generation of OpenID technology and it's a +RESTful HTTP API that uses JSON as its data format. OpenID Connect is an +authentication layer on top of the OAuth 2.0 authorization framework. It allows +to verify the identity of an end user based on the authentication performed by +an authorization server. .. caution:: @@ -358,15 +360,15 @@ It allows to verify the identity of an end user based on the authentication perf The ``OidcUserInfoTokenHandler`` class was introduced in Symfony 6.3. -.. note:: +The ``OidcUserInfoTokenHandler`` requires the ``symfony/http-client`` package to +make the needed HTTP requests. If you haven't installed it yet, run this command: - The ``OidcUserInfoTokenHandler`` requires ``symfony/http-client`` package: - - .. code-block:: terminal +.. code-block:: terminal - $ composer require symfony/http-client + $ composer require symfony/http-client -Symfony provides a generic OidcUserInfoTokenHandler to call your OIDC server and retrieve the user info: +Symfony provides a generic ``OidcUserInfoTokenHandler`` to call your OIDC server +and retrieve the user info: .. configuration-block:: @@ -422,11 +424,8 @@ Symfony provides a generic OidcUserInfoTokenHandler to call your OIDC server and ; }; -.. tip:: - - Following the `OpenID Connect Specification`_, the `sub` claim - is used as user identifier by default. To use another claim, - specify it on the configuration: +Following the `OpenID Connect Specification`_, the ``sub`` claim is used as user +identifier by default. To use another claim, specify it on the configuration: .. configuration-block:: @@ -484,12 +483,9 @@ Symfony provides a generic OidcUserInfoTokenHandler to call your OIDC server and ; }; -.. tip:: - - The ``oidc_user_info`` token handler automatically creates - an HTTP client with the specified configuration. If you - prefer using your own client, you can specify the service - name via the ``client`` option: +The ``oidc_user_info`` token handler automatically creates an HTTP client with +the specified configuration. If you prefer using your own client, you can +specify the service name via the ``client`` option: .. configuration-block:: @@ -541,8 +537,9 @@ Symfony provides a generic OidcUserInfoTokenHandler to call your OIDC server and ; }; -By default, the ``OidcUserInfoTokenHandler`` creates an OidcUser with the claims. To create your own User from the -claims, you must :doc:`create your own UserProvider `:: +By default, the ``OidcUserInfoTokenHandler`` creates an ``OidcUser`` with the +claims. To create your own user object from the claims, you must +:doc:`create your own UserProvider `:: // src/Security/Core/User/OidcUserProvider.php use Symfony\Component\Security\Core\User\AttributesBasedUserProviderInterface; @@ -551,7 +548,7 @@ claims, you must :doc:`create your own UserProvider `: { public function loadUserByIdentifier(string $identifier, array $attributes = []): UserInterface { - // do some magic + // implement your own logic to load and return the user object } } @@ -562,18 +559,18 @@ claims, you must :doc:`create your own UserProvider `: The ``OidcTokenHandler`` class was introduced in Symfony 6.3. -.. note:: +The ``OidcTokenHandler`` requires ``web-token/jwt-signature``, +``web-token/jwt-checker`` and ``web-token/jwt-signature-algorithm-ecdsa`` +packages. If you haven't installed them yet, run these commands: - The ``OidcTokenHandler`` requires ``web-token/jwt-signature``, ``web-token/jwt-checker`` and - ``web-token/jwt-signature-algorithm-ecdsa`` packages: - - .. code-block:: terminal +.. code-block:: terminal - $ composer require web-token/jwt-signature - $ composer require web-token/jwt-checker - $ composer require web-token/jwt-signature-algorithm-ecdsa + $ composer require web-token/jwt-signature + $ composer require web-token/jwt-checker + $ composer require web-token/jwt-signature-algorithm-ecdsa -Symfony provides a generic OidcTokenHandler to decode your token, validate it and retrieve the user info from it: +Symfony provides a generic ``OidcTokenHandler`` to decode your token, validate +it and retrieve the user info from it: .. configuration-block:: @@ -633,11 +630,9 @@ Symfony provides a generic OidcTokenHandler to decode your token, validate it an ; }; -.. tip:: - - Following the `OpenID Connect Specification`_, the `sub` claim - is used by default as user identifier. To use another claim, - specify it on the configuration: +Following the `OpenID Connect Specification`_, the ``sub`` claim is used by +default as user identifier. To use another claim, specify it on the +configuration: .. configuration-block:: @@ -697,11 +692,8 @@ Symfony provides a generic OidcTokenHandler to decode your token, validate it an ; }; -.. tip:: - - The ``oidc`` token handler also check for the token audience. - By default, this audience is optional. To enable this check, - add the ``audience`` option: +The ``oidc`` token handler also checks for the token audience. By default, this +audience is optional. To enable this check, add the ``audience`` option: .. configuration-block:: @@ -761,8 +753,9 @@ Symfony provides a generic OidcTokenHandler to decode your token, validate it an ; }; -By default, the OidcTokenHandler creates an OidcUser with the claims. To create your own User from the claims, -you must :doc:`create your own UserProvider `:: +By default, the ``OidcTokenHandler`` creates an ``OidcUser`` with the claims. To +create your own User from the claims, you must +:doc:`create your own UserProvider `:: // src/Security/Core/User/OidcUserProvider.php use Symfony\Component\Security\Core\User\AttributesBasedUserProviderInterface; @@ -771,7 +764,7 @@ you must :doc:`create your own UserProvider `:: { public function loadUserByIdentifier(string $identifier, array $attributes = []): UserInterface { - // do some magic + // implement your own logic to load and return the user object } } From d59f96070b5c51f7116a4f2e53c4b61fe986e1de Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Wed, 10 May 2023 22:16:14 +0200 Subject: [PATCH 0832/1913] Remove versionadded 5.2 on 6.x branch --- form/form_customization.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/form/form_customization.rst b/form/form_customization.rst index 1df12a0bc9c..7b4844247f5 100644 --- a/form/form_customization.rst +++ b/form/form_customization.rst @@ -127,10 +127,6 @@ fields, so you no longer have to deal with form themes: {% endfor %} -.. versionadded:: 5.2 - - The ``field_*()`` helpers were introduced in Symfony 5.2. - Form Rendering Variables ------------------------ From 2cc8f4b27b9fd82094f3c100599d5ed4ede0573f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 12 May 2023 13:08:49 +0200 Subject: [PATCH 0833/1913] Minor tweak --- components/intl.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/intl.rst b/components/intl.rst index 67813ef7951..5ec6c4b7011 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -406,7 +406,7 @@ The data needed to store the transliteration of all emojis (~5,000) into all languages take a considerable disk space. If you need to save disk space (e.g. because you deploy to some service with tight size constraints), run this command (e.g. as an automated script after ``composer install``) to compress the internal -Symfony emoji files using the PHP ``zlib`` extension: +Symfony emoji data files using the PHP ``zlib`` extension: .. code-block:: terminal From ae34e2c12fa9f85185292dcd9b4bd033517babcc Mon Sep 17 00:00:00 2001 From: Jon Green Date: Mon, 15 May 2023 15:04:49 +0100 Subject: [PATCH 0834/1913] Add missing `use` statement to databases & doctrine page --- doctrine.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doctrine.rst b/doctrine.rst index cca47d1b0f4..d84b20f6583 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -813,6 +813,7 @@ with any PHP model:: use App\Entity\Product; use App\Repository\ProductRepository; + use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; // ... From 09914bc571397b0e9e14dd3033f88918cad812f3 Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Wed, 10 May 2023 22:06:36 +0200 Subject: [PATCH 0835/1913] [OptionsResolver] add `ignoreUndefined()` --- components/options_resolver.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/options_resolver.rst b/components/options_resolver.rst index fb459f3d9cd..47c15317957 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -842,6 +842,29 @@ the option:: This closure receives as argument the value of the option after validating it and before normalizing it when the option is being resolved. +Ignore not defined Options +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, all options are resolved, validated and an :class:`Symfony\\Component\\OptionsResolver\\Exception\\UndefinedOptionsException` +is thrown if an unknown option is passed. You can ignore not defined options by using the +:method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::ignoreUndefined` method:: + + // ... + $resolver + ->setDefined(['hostname']) + ->setIgnoreUndefined(true) + ; + + // option "version" will be ignored + $resolver->resolve([ + 'hostname' => 'acme/package', + 'version' => '1.2.3' + ]); + +.. versionadded:: 6.3 + + The ``ignoreUndefined`` method was introduced in Symfony 6.3. + Chaining Option Configurations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 90ff99b876be20fead963396a6e8c20394933de5 Mon Sep 17 00:00:00 2001 From: pavdovlatov <129055488+pavdovlatov@users.noreply.github.com> Date: Wed, 17 May 2023 14:20:58 +0300 Subject: [PATCH 0836/1913] Fixed typo in messenger.rst --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index a1d76eb3e57..ba8e4a76936 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2484,7 +2484,7 @@ of the process. For each, the event class is the event name: .. versionadded:: 6.2 - The ``WorkerRateLimitedEvent`` was introduced in Symfony 6.3. + The ``WorkerRateLimitedEvent`` was introduced in Symfony 6.2. Multiple Buses, Command & Event Buses ------------------------------------- From 1b989b8e1ae798c3e706efb14c489cf61df4ab72 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2023 12:27:57 +0200 Subject: [PATCH 0837/1913] [OptionsResolver] Minor tweak --- components/options_resolver.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 47c15317957..1d72bdae1e5 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -845,8 +845,9 @@ and before normalizing it when the option is being resolved. Ignore not defined Options ~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default, all options are resolved, validated and an :class:`Symfony\\Component\\OptionsResolver\\Exception\\UndefinedOptionsException` -is thrown if an unknown option is passed. You can ignore not defined options by using the +By default, all options are resolved and validated, resulting in a +:class:`Symfony\\Component\\OptionsResolver\\Exception\\UndefinedOptionsException` +if an unknown option is passed. You can ignore not defined options by using the :method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::ignoreUndefined` method:: // ... @@ -863,7 +864,7 @@ is thrown if an unknown option is passed. You can ignore not defined options by .. versionadded:: 6.3 - The ``ignoreUndefined`` method was introduced in Symfony 6.3. + The ``ignoreUndefined()`` method was introduced in Symfony 6.3. Chaining Option Configurations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 0ce171c00aafb36c1b4cc38ef0b808570f6b8548 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2023 12:35:34 +0200 Subject: [PATCH 0838/1913] [HttpClient] Document the crypto_method option --- reference/configuration/framework.rst | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 937ed629d79..46453bbdf64 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1027,9 +1027,21 @@ ciphers **type**: ``string`` -A list of the names of the ciphers allowed for the SSL/TLS connections. They +A list of the names of the ciphers allowed for the TLS connections. They can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256'``). +crypto_method +............. + +**type**: ``integer`` + +The minimum version of TLS to accept. The value must be one of the +``STREAM_CRYPTO_METHOD_TLSv*_CLIENT`` constants defined by PHP. + +.. versionadded:: 6.3 + + The ``crypto_method`` option was introduced in Symfony 6.3. + delay ..... @@ -1183,7 +1195,7 @@ peer_fingerprint **type**: ``array`` -When negotiating a TLS or SSL connection, the server sends a certificate +When negotiating a TLS connection, the server sends a certificate indicating its identity. A public key is extracted from this certificate and if it does not exactly match any of the public keys provided in this option, the connection is aborted before sending or receiving any data. @@ -1265,7 +1277,7 @@ verify_peer **type**: ``boolean`` **default**: ``true`` -If ``true``, the certificate sent by other servers when negotiating a TLS or SSL +If ``true``, the certificate sent by other servers when negotiating a TLS connection is verified for authenticity. Authenticating the certificate is not enough to be sure about the server, so you should combine this with the ``verify_host`` option. From cf9788c39d52cc456a96f7e054bb3b9d0a55e37c Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 22 May 2023 15:50:11 +0200 Subject: [PATCH 0839/1913] [HttpKernel] Add `#[MapQueryParameter]`, `#[MapQueryString]` and `#[MapRequestPayload]` --- controller.rst | 152 +++++++++++++++++++++++++++++++++++++++ reference/attributes.rst | 3 + 2 files changed, 155 insertions(+) diff --git a/controller.rst b/controller.rst index 9f861a75708..db3e635a8fa 100644 --- a/controller.rst +++ b/controller.rst @@ -336,6 +336,157 @@ object. To access it in your controller, add it as an argument and :ref:`Keep reading ` for more information about using the Request object. +.. _controller_map-request: + +Automatic Mapping Of The Request +-------------------------------- + +It is possible to automatically map request's payload and/or query parameters to +your controller's action arguments with attributes. + +Mapping Query Parameters Individually +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Let's say a user sends you a request with the following query string: +``https://example.com/dashboard?firstName=John&lastName=Smith&age=27``. +Thanks to the :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryParameter` +attribute, arguments of your controller's action can be automatically fulfilled:: + + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Attribute\MapQueryParameter; + + // ... + + public function dashboard( + #[MapQueryParameter] string $firstName, + #[MapQueryParameter] string $lastName, + #[MapQueryParameter] int $age, + ): Response + { + // ... + } + +``#[MapQueryParameter]`` can take an optional argument called ``filter``. You can use the +`Validate Filters`_ constants defined in PHP:: + + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Attribute\MapQueryParameter; + + // ... + + public function dashboard( + #[MapQueryParameter(filter: \FILTER_VALIDATE_REGEXP, options: ['regexp' => '/^\w++$/'])] string $firstName, + #[MapQueryParameter] string $lastName, + #[MapQueryParameter(filter: \FILTER_VALIDATE_INT)] int $age, + ): Response + { + // ... + } + +.. versionadded:: 6.3 + + The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryParameter` attribute + was introduced in Symfony 6.3. + +Mapping The Whole Query String +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Another possibility is to map the entire query string into an object that will hold +available query parameters. Let's say you declare the following DTO with its +optional validation constraints:: + + namespace App\Model; + + use Symfony\Component\Validator\Constraints as Assert; + + class UserDTO + { + public function __construct( + #[Assert\NotBlank] + public string $firstName, + + #[Assert\NotBlank] + public string $lastName, + + #[Assert\GreaterThan(18)] + public int $age, + ) { + } + } + +You can then use the :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString` +attribute in your controller:: + + use App\Model\UserDto; + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Attribute\MapQueryString; + + // ... + + public function dashboard( + #[MapQueryString] UserDTO $userDto + ): Response + { + // ... + } + +.. versionadded:: 6.3 + + The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString` attribute + was introduced in Symfony 6.3. + +Mapping Request Payload +~~~~~~~~~~~~~~~~~~~~~~~ + +When creating an API and dealing with other HTTP methods than ``GET`` (like +``POST`` or ``PUT``), user's data are not stored in the query string +but directly in the request payload, like this: + +.. code-block:: json + + { + "firstName": "John", + "lastName": "Smith", + "age": 28 + } + +In this case, it is also possible to directly map this payload to your DTO by +using the :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload` +attribute:: + + use App\Model\UserDto; + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; + + // ... + + public function dashboard( + #[MapRequestPayload] UserDTO $userDto + ): Response + { + // ... + } + +This attribute allows you to customize the serialization context as well +as the class responsible of doing the mapping between the request and +your DTO:: + + public function dashboard( + #[MapRequestPayload( + serializationContext: ['...'], + resolver: App\Resolver\UserDtoResolver + )] + UserDTO $userDto + ): Response + { + // ... + } + +.. versionadded:: 6.3 + + The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload` attribute + was introduced in Symfony 6.3. + Managing the Session -------------------- @@ -604,3 +755,4 @@ Learn more about Controllers .. _`Early hints`: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103 .. _`SAPI`: https://www.php.net/manual/en/function.php-sapi-name.php .. _`FrankenPHP`: https://frankenphp.dev +.. _`Validate Filters`: https://www.php.net/manual/en/filter.filters.validate.php diff --git a/reference/attributes.rst b/reference/attributes.rst index f76c9674016..5598691682e 100644 --- a/reference/attributes.rst +++ b/reference/attributes.rst @@ -57,6 +57,9 @@ HttpKernel * :class:`Symfony\\Component\\HttpKernel\\Attribute\\AsPinnedValueResolver` * :ref:`Cache ` * :ref:`MapDateTime ` +* :ref:`MapQueryParameter ` +* :ref:`MapQueryString ` +* :ref:`MapRequestPayload ` * :class:`Symfony\\Component\\HttpKernel\\Attribute\\ValueResolver` * :ref:`WithHttpStatus ` * :ref:`WithLogLevel ` From a0bb5bf1e84362226a141768cead7ef167a73f05 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2023 14:58:59 +0200 Subject: [PATCH 0840/1913] [Validator] Update the ignoreNull option of UniqueEntity constraint --- reference/constraints/UniqueEntity.rst | 87 ++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 9f3d810eb01..328ea8790da 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -253,11 +253,98 @@ each with a single field. **type**: ``boolean`` **default**: ``true`` +``ignoreNull`` +~~~~~~~~~~~~~~ + +**type**: ``boolean`` | ``string`` | ``array`` **default**: ``true`` + If this option is set to ``true``, then the constraint will allow multiple entities to have a ``null`` value for a field without failing validation. If set to ``false``, only one ``null`` value is allowed - if a second entity also has a ``null`` value, validation would fail. +In addition to ignoring the ``null`` values of all unique fields, you can also use +this option to specify one or more fields to only ignore ``null`` values on them: + +.. configuration-block:: + + .. code-block:: php-attributes + + // src/Entity/User.php + namespace App\Entity; + + use Doctrine\ORM\Mapping as ORM; + use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + use Symfony\Component\Validator\Constraints as Assert; + + #[ORM\Entity] + #[UniqueEntity(fields: ['email', 'phoneNumber'], ignoreNull: 'phoneNumber')] + class User + { + // ... + } + + .. code-block:: yaml + + # config/validator/validation.yaml + App\Entity\User: + constraints: + - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: + fields: ['email', 'phoneNumber'] + ignoreNull: 'phoneNumber' + properties: + # ... + + .. code-block:: xml + + + + + + + + + + + + + + + + .. code-block:: php + + // src/Entity/User.php + namespace App\Entity; + + use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + use Symfony\Component\Validator\Constraints as Assert; + + class User + { + public static function loadValidatorMetadata(ClassMetadata $metadata) + { + $metadata->addConstraint(new UniqueEntity([ + 'fields' => ['email', 'phoneNumber'], + 'ignoreNull' => 'phoneNumber', + ])); + + // ... + } + } + +.. caution:: + + If you ``ignoreNull`` on fields that are part of a unique index in your + database, you might see insertion errors when your application attempts to + persist entities that the ``UniqueEntity`` constraint considers valid. + +.. versionadded:: 6.3 + + The option to ignore ``null`` values for specific fields was introduced + in Symfony 6.3. + ``message`` ~~~~~~~~~~~ From 3f996caf1c2c09daa377490ae193a13404f49000 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 May 2023 12:19:05 +0200 Subject: [PATCH 0841/1913] [HttpClient] Support file uploads by nesting resource streams in body option --- http_client.rst | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/http_client.rst b/http_client.rst index 693fc3dc59e..295ed2668ee 100644 --- a/http_client.rst +++ b/http_client.rst @@ -607,22 +607,23 @@ A generator or any ``Traversable`` can also be used instead of a closure. $decodedPayload = $response->toArray(); -To submit a form with file uploads, it is your responsibility to encode the body -according to the ``multipart/form-data`` content-type. The -:doc:`Symfony Mime ` component makes it a few lines of code:: +To submit a form with file uploads, pass the file handle to the ``body`` option:: - use Symfony\Component\Mime\Part\DataPart; - use Symfony\Component\Mime\Part\Multipart\FormDataPart; + $fileHandle = fopen('/path/to/the/file' 'r'); + $client->request('POST', 'https://...', ['body' => ['the_file' => $fileHandle]]); - $formFields = [ - 'regular_field' => 'some value', - 'file_field' => DataPart::fromPath('/path/to/uploaded/file'), - ]; - $formData = new FormDataPart($formFields); - $client->request('POST', 'https://...', [ - 'headers' => $formData->getPreparedHeaders()->toArray(), - 'body' => $formData->bodyToIterable(), - ]); +By default, this code will populate the filename and content-type with the data +of the opened file, but you can configure both with the PHP streaming configuration:: + + stream_context_set_option($fileHandle, 'http', 'filename', 'the-name.txt'); + stream_context_set_option($fileHandle, 'http', 'content_type', 'my/content-type'); + +.. versionadded:: 6.3 + + The feature to upload files using handles was introduced in Symfony 6.3. + In previous Symfony versions you had to encode the body contents according + to the ``multipart/form-data`` content-type using the :doc:`Symfony Mime ` + component. .. tip:: From cf36166923459de18e643d928f414c9f2508b565 Mon Sep 17 00:00:00 2001 From: Dan Barrett Date: Wed, 24 May 2023 14:54:04 +1000 Subject: [PATCH 0842/1913] [Performance] Update parameter to compile-time prefix --- performance.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/performance.rst b/performance.rst index 29f88614d05..3d1875d45b4 100644 --- a/performance.rst +++ b/performance.rst @@ -60,7 +60,7 @@ container into a single file, which could improve performance when using # config/services.yaml parameters: # ... - container.dumper.inline_factories: true + .container.dumper.inline_factories: true .. code-block:: xml @@ -72,7 +72,7 @@ container into a single file, which could improve performance when using - true + true @@ -81,10 +81,15 @@ container into a single file, which could improve performance when using // config/services.php // ... - $container->parameters()->set('container.dumper.inline_factories', true); + $container->parameters()->set('.container.dumper.inline_factories', true); .. _performance-use-opcache: +.. tip:: + + The ``.`` prefix denotes a parameter that is only used during compilation of the container. + See :ref:`Configuration Parameters ` for more details. + Use the OPcache Byte Code Cache ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From be256a1acc52427ddc9918134e46936748365cc9 Mon Sep 17 00:00:00 2001 From: Jorick <48644518+JorickPepin@users.noreply.github.com> Date: Wed, 24 May 2023 09:52:21 +0200 Subject: [PATCH 0843/1913] [Doctrine] Replace entityManager by objectManager --- doctrine.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doctrine.rst b/doctrine.rst index d84b20f6583..164ed72ed09 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -784,13 +784,13 @@ control behavior: If true, then when ``findOneBy()`` is used, any values that are ``null`` will not be used for the query. -``entityManager`` +``objectManager`` By default, the ``EntityValueResolver`` uses the *default* - entity manager, but you can configure this:: + object manager, but you can configure this:: #[Route('/product/{id}')] public function show( - #[MapEntity(entityManager: ['foo'])] + #[MapEntity(objectManager: 'foo')] Product $product ): Response { } From dcdf4a1328a5872763026f2c81f5e69a85591a7c Mon Sep 17 00:00:00 2001 From: Wouter van der Loop Date: Wed, 24 May 2023 13:45:16 +0200 Subject: [PATCH 0844/1913] [Notifier] Add Novu Notifier Bridge --- notifier.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notifier.rst b/notifier.rst index 0480405cc4a..08b7c08fbce 100644 --- a/notifier.rst +++ b/notifier.rst @@ -425,6 +425,7 @@ Service Package DSN =============== ==================================== ============================================================================== `Engagespot`_ ``symfony/engagespot-notifier`` ``engagespot://API_KEY@default?campaign_name=CAMPAIGN_NAME`` `Expo`_ ``symfony/expo-notifier`` ``expo://Token@default`` +`Novu`_ ``symfony/novu-notifier`` ``novu://API_KEY@default`` `OneSignal`_ ``symfony/one-signal-notifier`` ``onesignal://APP_ID:API_KEY@default?defaultRecipientId=DEFAULT_RECIPIENT_ID`` `PagerDuty`_ ``symfony/pager-duty-notifier`` ``pagerduty://TOKEN@SUBDOMAIN`` `Pushover`_ ``symfony/pushover-notifier`` ``pushover://USER_KEY:APP_TOKEN@default`` @@ -438,6 +439,10 @@ Service Package DSN The PagerDuty and Pushover integrations were introduced in Symfony 6.3. +.. versionadded:: 6.4 + + The Novu integration was introduced in Symfony 6.4. + To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: @@ -998,6 +1003,7 @@ is dispatched. Listeners receive a .. _`MicrosoftTeams`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/README.md .. _`Mobyt`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Mobyt/README.md .. _`Nexmo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md +.. _`Novu`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Novu/README.md .. _`Octopush`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/Octopush/README.md .. _`OneSignal`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OneSignal/README.md .. _`OrangeSms`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Notifier/Bridge/OrangeSms/README.md From ed6c5a20578afe2977e2a88804691df504659de6 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 22 May 2023 16:01:17 +0200 Subject: [PATCH 0845/1913] [HttpKernel] Add customization options to `#[MapQueryString]` and `#[MapRequestPayload]` --- controller.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/controller.rst b/controller.rst index db3e635a8fa..1f88729204d 100644 --- a/controller.rst +++ b/controller.rst @@ -430,6 +430,16 @@ attribute in your controller:: // ... } +You can customize the validation groups used during the mapping thanks to the +``validationGroups`` option:: + + public function dashboard( + #[MapQueryString(validationGroups: ['strict', 'edit'])] UserDTO $userDto + ): Response + { + // ... + } + .. versionadded:: 6.3 The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString` attribute @@ -482,6 +492,16 @@ your DTO:: // ... } +You can also customize the validation groups used as well as supported +payload formats:: + + public function dashboard( + #[MapRequestPayload(acceptFormat: 'json', validationGroups: ['strict', 'read'])] UserDTO $userDto + ): Response + { + // ... + } + .. versionadded:: 6.3 The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload` attribute From ace8e03ba10092fff16f738cc3631916c410b0f9 Mon Sep 17 00:00:00 2001 From: Allison Guilhem Date: Wed, 1 Feb 2023 09:08:53 +0100 Subject: [PATCH 0846/1913] [HttpFoundation] update doc creation session table --- session.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/session.rst b/session.rst index b1da1a9a0eb..a399cff2796 100644 --- a/session.rst +++ b/session.rst @@ -880,7 +880,13 @@ Preparing the Database to Store Sessions ........................................ Before storing sessions in the database, you must create the table that stores -the information. The session handler provides a method called +the information. + +With Doctrine installed, the session table will be automatically generated when +you run the make:migration command if the database targeted by doctrine is identical to +the one used by this component. + +Or if you prefer to create the table yourself and the table has not already been created, the session handler provides a method called :method:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler::createTable` to set up this table for you according to the database engine used:: @@ -890,7 +896,9 @@ to set up this table for you according to the database engine used:: // the table could not be created for some reason } -If you prefer to set up the table yourself, it's recommended to generate an +If the table already exists an exception will be thrown. + +If you would rather set up the table yourself, it's recommended to generate an empty database migration with the following command: .. code-block:: terminal @@ -904,6 +912,10 @@ file and run the migration with the following command: $ php bin/console doctrine:migrations:migrate +If needed, you can also add this table to your schema by calling +:method:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler::configureSchema` method +in your code. + .. _mysql: MariaDB/MySQL From 4f56d81f7e27fe81b7fa13d6fd7ed2f8c3cc6295 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 25 May 2023 09:52:39 +0200 Subject: [PATCH 0847/1913] Tweaks --- session.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/session.rst b/session.rst index a399cff2796..2945c31e846 100644 --- a/session.rst +++ b/session.rst @@ -883,10 +883,11 @@ Before storing sessions in the database, you must create the table that stores the information. With Doctrine installed, the session table will be automatically generated when -you run the make:migration command if the database targeted by doctrine is identical to -the one used by this component. +you run the ``make:migration`` command if the database targeted by doctrine is +identical to the one used by this component. -Or if you prefer to create the table yourself and the table has not already been created, the session handler provides a method called +Or if you prefer to create the table yourself and the table has not already been +created, the session handler provides a method called :method:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler::createTable` to set up this table for you according to the database engine used:: @@ -913,8 +914,8 @@ file and run the migration with the following command: $ php bin/console doctrine:migrations:migrate If needed, you can also add this table to your schema by calling -:method:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler::configureSchema` method -in your code. +:method:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler::configureSchema` +method in your code. .. _mysql: From 1ffdcee77211e93aa7909835b22a45e555cebd23 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 25 May 2023 15:23:42 +0200 Subject: [PATCH 0848/1913] [DependencyInjection] Add support for generating lazy closures --- reference/attributes.rst | 4 +- service_container.rst | 50 ++----------- service_container/autowiring.rst | 98 ++++++++++++++++++++++++++ service_container/service_closures.rst | 42 ++--------- 4 files changed, 110 insertions(+), 84 deletions(-) diff --git a/reference/attributes.rst b/reference/attributes.rst index 5598691682e..2cabf9de7bd 100644 --- a/reference/attributes.rst +++ b/reference/attributes.rst @@ -31,9 +31,9 @@ Dependency Injection * :ref:`Autoconfigure ` * :ref:`AutoconfigureTag ` * :ref:`Autowire ` -* :ref:`AutowireCallable ` +* :ref:`AutowireCallable ` * :doc:`AutowireDecorated ` -* :doc:`AutowireServiceClosure ` +* :ref:`AutowireServiceClosure ` * :ref:`Exclude ` * :ref:`TaggedIterator ` * :ref:`TaggedLocator ` diff --git a/service_container.rst b/service_container.rst index c87b83d9f9f..0b7e34a947b 100644 --- a/service_container.rst +++ b/service_container.rst @@ -780,54 +780,14 @@ Our configuration looks like this: ; }; -.. versionadded:: 6.1 - - The ``closure`` argument type was introduced in Symfony 6.1. - -It is also possible to convert a callable into an injected closure -thanks to the -:class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireCallable` -attribute. Let's say our ``MessageHashGenerator`` class now has a ``generate()`` -method:: - - // src/Hash/MessageHashGenerator.php - namespace App\Hash; - - class MessageHashGenerator - { - public function generate(): string - { - // Compute and return a message hash - } - } +.. seealso:: -We can inject the ``generate()`` method of the ``MessageHashGenerator`` -like this:: - - // src/Service/MessageGenerator.php - namespace App\Service; - - use App\Hash\MessageHashGenerator; - use Psr\Log\LoggerInterface; - use Symfony\Component\DependencyInjection\Attribute\AutowireCallable; + Closures can be injected :ref:`by using autowiring ` + and its dedicated attributes. - class MessageGenerator - { - public function __construct( - private LoggerInterface $logger, - #[AutowireCallable(service: MessageHashGenerator::class, method: 'generate')] - private \Closure $generateMessageHash - ) { - // ... - } - - // ... - } - -.. versionadded:: 6.3 +.. versionadded:: 6.1 - The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireCallable` - attribute was introduced in Symfony 6.3. + The ``closure`` argument type was introduced in Symfony 6.1. .. _services-binding: diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 7775935076a..81f877e23fd 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -643,6 +643,104 @@ The ``#[Autowire]`` attribute can also be used for :ref:`parameters messageFormatterResolver)()->format($message); + + // ... + } + } + +.. versionadded:: 6.3 + + The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireServiceClosure` + attribute was introduced in Symfony 6.3. + +It is common that a service accepts a closure with a specific signature. +In this case, you can use the +:class:`Symfony\Component\DependencyInjection\Attribute\\AutowireCallable` attribute +to generate a closure with the same signature as a specific method of a service. When +this closure is called, it will pass all its arguments to the underlying service +function:: + + // src/Service/MessageGenerator.php + namespace App\Service; + + use Symfony\Component\DependencyInjection\Attribute\AutowireCallable; + + class MessageGenerator + { + public function __construct( + #[AutowireCallable(service: 'third_party.remote_message_formatter', method: 'format')] + \Closure $formatCallable + ) { + } + + public function generate(string $message): void + { + $formattedMessage = ($this->formatCallable)($message); + + // ... + } + } + +Finally, you can pass the ``lazy: true`` option to the +:class:`Symfony\Component\DependencyInjection\Attribute\\AutowireCallable` +attribute. By doing so, the callable will automatically be lazy, which means +that the encapsulated service will be instantiated **only** at the +closure's first call. + +.. versionadded:: 6.3 + + The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireCallable` + attribute was introduced in Symfony 6.3. + .. _autowiring-calls: Autowiring other Methods (e.g. Setters and Public Typed Properties) diff --git a/service_container/service_closures.rst b/service_container/service_closures.rst index 28a1d0b0f02..53cf11850b3 100644 --- a/service_container/service_closures.rst +++ b/service_container/service_closures.rst @@ -92,45 +92,13 @@ argument of type ``service_closure``: .. seealso:: - Another way to inject services lazily is via a - :doc:`service locator `. - -Thanks to the -:class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireServiceClosure` -attribute, defining a service wrapped in a closure can directly be done -in the service class, without further configuration:: - - // src/Service/MyService.php - namespace App\Service; - - use Symfony\Component\DependencyInjection\Attribute\AutowireServiceClosure; - use Symfony\Component\Mailer\MailerInterface; - - class MyService - { - public function __construct( - #[AutowireServiceClosure('mailer')] - private \Closure $mailer - ) { - } - - public function doSomething(): void - { - // ... - - $this->getMailer()->send($email); - } + Service closures can be injected :ref:`by using autowiring ` + and its dedicated attributes. - private function getMailer(): MailerInterface - { - return ($this->mailer)(); - } - } - -.. versionadded:: 6.3 +.. seealso:: - The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireServiceClosure` - attribute was introduced in Symfony 6.3. + Another way to inject services lazily is via a + :doc:`service locator `. Using a Service Closure in a Compiler Pass ------------------------------------------ From 6957aee2b1ddaaccef25e4e4266eaa693cf2169e Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 25 May 2023 17:19:58 +0200 Subject: [PATCH 0849/1913] [DependencyInjection] Add support for casting callables into single-method interfaces --- service_container.rst | 124 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/service_container.rst b/service_container.rst index c87b83d9f9f..b7a9ace7f84 100644 --- a/service_container.rst +++ b/service_container.rst @@ -1334,6 +1334,130 @@ the closure:: // services depending on which environment you're on }; +Generating Adapters for Functional Interfaces +--------------------------------------------- + +Functional interfaces are interfaces with a single method. +They are conceptually very similar to a closure except that their only method +has a name. Moreover, they can be used as type-hints across your code. + +The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireCallable` +attribute can be used to generate an adapter for a functional interface. +Let's say you have the following functional interface:: + + // src/Service/MessageFormatterInterface.php + namespace App\Service; + + interface MessageFormatterInterface + { + public function format(string $message, array $parameters): string; + } + +Now, you can define a service implementing this method, among other util ones:: + + // src/Service/MessageFormatterInterface.php + namespace App\Service; + + class MessageUtils + { + // other utils methods... + + public function format($string $message, array $parameters): string + { + // ... + } + } + +We can now use ``#[AutowireCallable]`` with our ``MessageUtils`` service +to inject our functional interface implementation:: + + namespace App\Service\Mail; + + use App\Service\MessageFormatterInterface; + use App\Service\MessageUtils; + use Symfony\Component\DependencyInjection\Attribute\AutowireCallable; + + class Mailer + { + public function __construct( + #[AutowireCallable(service: MessageUtils::class, method: 'formatMessage')] + private MessageFormatterInterface $formatter + ) { + } + + public function sendMail($string $message, array $parameters): string + { + $formattedMessage = $this->formatter->format($message, $parameters); + + // ... + } + } + +.. versionadded:: 6.3 + + The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireCallable` + attribute was introduced in Symfony 6.3. + +Alternatively, generating an adapter for a functional interface can also +be done through configuration: + +.. configuration-block:: + + .. code-block:: yaml + + # config/services.yaml + services: + + # ... + + app.message_formatter: + class: App\Service\MessageFormatterInterface + from_callable: [!service {class: 'App\Service\MessageUtils'}, 'formatMessage'] + + .. code-block:: xml + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + use App\Service\MessageFormatterInterface; + use App\Service\MessageUtils; + + return function(ContainerConfigurator $container) { + // ... + + $container + ->set('app.message_formatter', MessageFormatterInterface::class) + ->fromCallable([inline_service(MessageUtils::class), 'formatMessage']) + ->alias(MessageFormatterInterface::class, 'app.message_formatter') + ; + }; + +By doing so, Symfony will generate a class (also called an *adapter*) +implementing ``MessageFormatterInterface`` that will forward calls of +``MessageFormatterInterface::format()`` to your underlying service's method +``MessageUtils::format()``, with all its arguments. + Learn more ---------- From 7e8b5fe83c68cc79a295d6876d4135457b7af9cc Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 30 May 2023 15:20:24 +0200 Subject: [PATCH 0850/1913] [Uuid] Add few property types --- components/uid.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index 74458ac1717..24f4c59255b 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -236,12 +236,13 @@ type, which converts to/from UUID objects automatically:: use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Types\UuidType; + use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: ProductRepository::class)] class Product { #[ORM\Column(type: UuidType::NAME)] - private $someProperty; + private Uuid $someProperty; // ... } @@ -265,7 +266,7 @@ entity primary keys:: #[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] - private $id; + private ?Uuid $id; public function getId(): ?Uuid { @@ -422,12 +423,13 @@ type, which converts to/from ULID objects automatically:: use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Types\UlidType; + use Symfony\Component\Uid\Ulid; #[ORM\Entity(repositoryClass: ProductRepository::class)] class Product { #[ORM\Column(type: UlidType::NAME)] - private $someProperty; + private Ulid $someProperty; // ... } @@ -451,7 +453,7 @@ entity primary keys:: #[ORM\Column(type: UlidType::NAME, unique: true)] #[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\CustomIdGenerator(class: 'doctrine.ulid_generator')] - private $id; + private ?Ulid $id; public function getId(): ?Ulid { From 472f5794d3c14ea53b6ea15be14b8aba510cf410 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 30 May 2023 16:03:27 +0200 Subject: [PATCH 0851/1913] Add property types and return types in a few places --- bundles/best_practices.rst | 2 +- bundles/configuration.rst | 2 +- bundles/prepend_extension.rst | 2 +- cache.rst | 14 ++--- components/dependency_injection.rst | 2 +- .../_imports-parameters-note.rst.inc | 2 +- components/expression_language.rst | 2 +- components/property_access.rst | 24 ++++----- components/serializer.rst | 16 +++--- components/var_dumper.rst | 2 +- configuration.rst | 14 ++--- configuration/env_var_processors.rst | 12 ++--- configuration/micro_kernel_trait.rst | 2 +- configuration/override_dir_structure.rst | 4 +- configuration/secrets.rst | 2 +- controller/error_pages.rst | 2 +- controller/upload_file.rst | 2 +- controller/value_resolver.rst | 2 +- deployment/proxies.rst | 2 +- doctrine.rst | 2 +- doctrine/events.rst | 6 +-- event_dispatcher.rst | 51 +++++++++--------- form/embedded.rst | 4 +- frontend/custom_version_strategy.rst | 2 +- html_sanitizer.rst | 22 ++++---- http_cache/cache_invalidation.rst | 2 +- http_cache/esi.rst | 4 +- http_cache/ssi.rst | 2 +- http_client.rst | 23 ++++---- lock.rst | 4 +- mailer.rst | 12 ++--- messenger.rst | 30 +++++------ messenger/custom-transport.rst | 2 +- messenger/multiple_buses.rst | 2 +- notifier.rst | 12 ++--- rate_limiter.rst | 6 +-- reference/configuration/framework.rst | 42 +++++++-------- reference/constraints/Compound.rst | 4 +- reference/constraints/UniqueEntity.rst | 11 ++-- reference/formats/expression_language.rst | 6 +-- routing.rst | 2 +- routing/custom_route_loader.rst | 2 +- security.rst | 52 +++++++++--------- security/access_control.rst | 2 +- security/csrf.rst | 2 +- serializer.rst | 13 ++--- service_container.rst | 24 ++++----- service_container/injection_types.rst | 2 +- service_container/service_closures.rst | 2 +- service_container/tags.rst | 6 +-- session.rst | 54 +++++++++---------- templates.rst | 4 +- testing.rst | 2 +- testing/profiling.rst | 2 +- translation.rst | 8 +-- validation.rst | 36 ++++++------- validation/translations.rst | 8 +-- workflow.rst | 34 ++++++------ workflow/dumping-workflows.rst | 2 +- workflow/workflow-and-state-machine.rst | 2 +- 60 files changed, 310 insertions(+), 308 deletions(-) diff --git a/bundles/best_practices.rst b/bundles/best_practices.rst index 10ae34e9d33..72a394362fa 100644 --- a/bundles/best_practices.rst +++ b/bundles/best_practices.rst @@ -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', 'fabien@example.com') ; diff --git a/bundles/configuration.rst b/bundles/configuration.rst index 4ef81743bf5..6933f7eb794 100644 --- a/bundles/configuration.rst +++ b/bundles/configuration.rst @@ -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); }; diff --git a/bundles/prepend_extension.rst b/bundles/prepend_extension.rst index a0c686c4527..8d28080470f 100644 --- a/bundles/prepend_extension.rst +++ b/bundles/prepend_extension.rst @@ -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, diff --git a/cache.rst b/cache.rst index 84d60315fe3..f9d7175cf41 100644 --- a/cache.rst +++ b/cache.rst @@ -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') @@ -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') @@ -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'); @@ -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']) @@ -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 @@ -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) @@ -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') diff --git a/components/dependency_injection.rst b/components/dependency_injection.rst index f805b39db35..6d8672feeef 100644 --- a/components/dependency_injection.rst +++ b/components/dependency_injection.rst @@ -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') diff --git a/components/dependency_injection/_imports-parameters-note.rst.inc b/components/dependency_injection/_imports-parameters-note.rst.inc index d17d6d60b26..1389ca78fe3 100644 --- a/components/dependency_injection/_imports-parameters-note.rst.inc +++ b/components/dependency_injection/_imports-parameters-note.rst.inc @@ -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'); }; diff --git a/components/expression_language.rst b/components/expression_language.rst index 33fdcae8de2..3f79c57707d 100644 --- a/components/expression_language.rst +++ b/components/expression_language.rst @@ -107,7 +107,7 @@ PHP type (including objects):: class Apple { - public $variety; + public string $variety; } $apple = new Apple(); diff --git a/components/property_access.rst b/components/property_access.rst index 7bf4a3d3a9e..3364b667a5c 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -177,7 +177,7 @@ method:: // ... class Person { - public $name; + public string $name; } $person = new Person(); @@ -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; } @@ -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; } diff --git a/components/serializer.rst b/components/serializer.rst index 0b97690650f..e08bd5c1f07 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -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(); @@ -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 @@ -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) diff --git a/components/var_dumper.rst b/components/var_dumper.rst index 3a55d6c21bd..ccde974b9e5 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -144,7 +144,7 @@ the :ref:`dump_destination option ` 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)%', ]); diff --git a/configuration.rst b/configuration.rst index 733dbbac32a..b7ccac2ece7 100644 --- a/configuration.rst +++ b/configuration.rst @@ -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 @@ -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). @@ -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%', @@ -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&bar=%%d'); }; @@ -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)%', @@ -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', '...'); @@ -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 diff --git a/configuration/env_var_processors.rst b/configuration/env_var_processors.rst index 15a91f249de..937c0e341f6 100644 --- a/configuration/env_var_processors.rst +++ b/configuration/env_var_processors.rst @@ -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 @@ -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()); }; @@ -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()); }; @@ -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$') @@ -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)%'); }; @@ -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)%'); }; diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 2a4b8a2b495..ac0d50e1671 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -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() diff --git a/configuration/override_dir_structure.rst b/configuration/override_dir_structure.rst index 7528c250729..4fb5524a2aa 100644 --- a/configuration/override_dir_structure.rst +++ b/configuration/override_dir_structure.rst @@ -67,7 +67,7 @@ Console script:: Web front-controller:: // public/index.php - + // ... $_SERVER['APP_RUNTIME_OPTIONS']['dotenv_path'] = 'another/custom/path/to/.env'; @@ -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') ; diff --git a/configuration/secrets.rst b/configuration/secrets.rst index d2923e13a42..bd52ea0895a 100644 --- a/configuration/secrets.rst +++ b/configuration/secrets.rst @@ -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') diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 0e2463cbfd1..d28c51cce99 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -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'); }; diff --git a/controller/upload_file.rst b/controller/upload_file.rst index f2a39c12262..9bcc17cd7cd 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -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) diff --git a/controller/value_resolver.rst b/controller/value_resolver.rst index b2d93b13148..d9a84aa06ee 100644 --- a/controller/value_resolver.rst +++ b/controller/value_resolver.rst @@ -320,7 +320,7 @@ and adding a priority: use App\ValueResolver\BookingIdValueResolver; - return static function (ContainerConfigurator $containerConfigurator) { + return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(BookingIdValueResolver::class) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 18377068cd6..2b716faa327 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -71,7 +71,7 @@ and what headers your reverse proxy uses to send information: // config/packages/framework.php use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { $framework // the IP address (or range) of your proxy ->trustedProxies('192.0.0.1,10.0.0.0/8') diff --git a/doctrine.rst b/doctrine.rst index 164ed72ed09..ff8eaa2479a 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -282,7 +282,7 @@ methods: // ... + #[ORM\Column(type: Types::TEXT)] - + private $description; + + private string $description; // getDescription() & setDescription() were also added } diff --git a/doctrine/events.rst b/doctrine/events.rst index 9319fdbfca0..53a3dc5b32e 100644 --- a/doctrine/events.rst +++ b/doctrine/events.rst @@ -234,7 +234,7 @@ listener in the Symfony application by creating a new service for it and use App\EventListener\SearchIndexer; - return static function (ContainerConfigurator $container) { + return static function (ContainerConfigurator $container): void { $services = $container->services(); // listeners are applied by default to all Doctrine connections @@ -385,7 +385,7 @@ with the ``doctrine.orm.entity_listener`` tag as follows: use App\Entity\User; use App\EventListener\UserChangedNotifier; - return static function (ContainerConfigurator $container) { + return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set(UserChangedNotifier::class) @@ -531,7 +531,7 @@ Doctrine connection to use) you must do that in the manual service configuration use App\EventListener\DatabaseActivitySubscriber; - return static function (ContainerConfigurator $container) { + return static function (ContainerConfigurator $container): void { $services = $container->services(); $services->set(DatabaseActivitySubscriber::class) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index d09a05a7473..275ec7863fe 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -263,17 +263,17 @@ listen to the same ``kernel.exception`` event:: ]; } - public function processException(ExceptionEvent $event) + public function processException(ExceptionEvent $event): void { // ... } - public function logException(ExceptionEvent $event) + public function logException(ExceptionEvent $event): void { // ... } - public function notifyException(ExceptionEvent $event) + public function notifyException(ExceptionEvent $event): void { // ... } @@ -306,7 +306,7 @@ a "main" request or a "sub request":: class RequestListener { - public function onKernelRequest(RequestEvent $event) + public function onKernelRequest(RequestEvent $event): void { if (!$event->isMainRequest()) { // don't do anything if it's not the main request @@ -357,7 +357,7 @@ name (FQCN) of the corresponding event class:: ]; } - public function onKernelRequest(RequestEvent $event) + public function onKernelRequest(RequestEvent $event): void { // ... } @@ -381,7 +381,7 @@ compiler pass ``AddEventAliasesPass``:: class Kernel extends BaseKernel { - protected function build(ContainerBuilder $container) + protected function build(ContainerBuilder $container): void { $container->addCompilerPass(new AddEventAliasesPass([ MyCustomEvent::class => 'my_custom_event', @@ -519,11 +519,12 @@ A controller that implements this interface looks like this:: use App\Controller\TokenAuthenticatedController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Response; class FooController extends AbstractController implements TokenAuthenticatedController { // An action that needs authentication - public function bar() + public function bar(): Response { // ... } @@ -548,11 +549,11 @@ event subscribers, you can learn more about them at :doc:`/event_dispatcher`:: class TokenSubscriber implements EventSubscriberInterface { public function __construct( - private $tokens + private array $tokens ) { } - public function onKernelController(ControllerEvent $event) + public function onKernelController(ControllerEvent $event): void { $controller = $event->getController(); @@ -570,7 +571,7 @@ event subscribers, you can learn more about them at :doc:`/event_dispatcher`:: } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::CONTROLLER => 'onKernelController', @@ -609,7 +610,7 @@ For example, take the ``TokenSubscriber`` from the previous example and first record the authentication token inside the request attributes. This will serve as a basic flag that this request underwent token authentication:: - public function onKernelController(ControllerEvent $event) + public function onKernelController(ControllerEvent $event): void { // ... @@ -631,7 +632,7 @@ header on the response if it's found:: // add the new use statement at the top of your file use Symfony\Component\HttpKernel\Event\ResponseEvent; - public function onKernelResponse(ResponseEvent $event) + public function onKernelResponse(ResponseEvent $event): void { // check to see if onKernelController marked this as a token "auth'ed" request if (!$token = $event->getRequest()->attributes->get('auth_token')) { @@ -645,7 +646,7 @@ header on the response if it's found:: $response->headers->set('X-CONTENT-HASH', $hash); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::CONTROLLER => 'onKernelController', @@ -673,7 +674,7 @@ end of the method:: { // ... - public function send($subject, $message) + public function send(string $subject, string $message): mixed { // dispatch an event before the method $event = new BeforeSendMailEvent($subject, $message); @@ -711,27 +712,27 @@ this:: class BeforeSendMailEvent extends Event { public function __construct( - private $subject, - private $message, + private string $subject, + private string $message, ) { } - public function getSubject() + public function getSubject(): string { return $this->subject; } - public function setSubject($subject) + public function setSubject(string $subject): string { $this->subject = $subject; } - public function getMessage() + public function getMessage(): string { return $this->message; } - public function setMessage($message) + public function setMessage(string $message) { $this->message = $message; } @@ -747,16 +748,16 @@ And the ``AfterSendMailEvent`` even like this:: class AfterSendMailEvent extends Event { public function __construct( - private $returnValue, + private mixed $returnValue, ) { } - public function getReturnValue() + public function getReturnValue(): mixed { return $this->returnValue; } - public function setReturnValue($returnValue) + public function setReturnValue(mixed $returnValue) { $this->returnValue = $returnValue; } @@ -776,7 +777,7 @@ could listen to the ``mailer.post_send`` event and change the method's return va class MailPostSendSubscriber implements EventSubscriberInterface { - public function onMailerPostSend(AfterSendMailEvent $event) + public function onMailerPostSend(AfterSendMailEvent $event): void { $returnValue = $event->getReturnValue(); // modify the original $returnValue value @@ -784,7 +785,7 @@ could listen to the ``mailer.post_send`` event and change the method's return va $event->setReturnValue($returnValue); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'mailer.post_send' => 'onMailerPostSend', diff --git a/form/embedded.rst b/form/embedded.rst index d4463532e9b..4263bb42b5d 100644 --- a/form/embedded.rst +++ b/form/embedded.rst @@ -22,7 +22,7 @@ creating the ``Category`` class:: class Category { #[Assert\NotBlank] - public $name; + public string $name; } Next, add a new ``category`` property to the ``Task`` class:: @@ -35,7 +35,7 @@ Next, add a new ``category`` property to the ``Task`` class:: #[Assert\Type(type: Category::class)] #[Assert\Valid] - protected $category; + protected ?Category $category = null; // ... diff --git a/frontend/custom_version_strategy.rst b/frontend/custom_version_strategy.rst index a873df8e801..9b86685889b 100644 --- a/frontend/custom_version_strategy.rst +++ b/frontend/custom_version_strategy.rst @@ -178,7 +178,7 @@ the :ref:`version_strategy ` option: use App\Asset\VersionStrategy\GulpBusterVersionStrategy; use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { // ... $framework->assets() ->versionStrategy(GulpBusterVersionStrategy::class) diff --git a/html_sanitizer.rst b/html_sanitizer.rst index 9aa26bbe37e..fccaedd29cd 100644 --- a/html_sanitizer.rst +++ b/html_sanitizer.rst @@ -197,7 +197,7 @@ You can do this by defining a new HTML sanitizer in the configuration: // config/packages/framework.php use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { $framework->htmlSanitizer() ->sanitizer('app.post_sanitizer') ->blockElement('h1') @@ -273,7 +273,7 @@ Safe elements // config/packages/framework.php use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { $framework->htmlSanitizer() ->sanitizer('app.post_sanitizer') // enable either of these @@ -360,7 +360,7 @@ attributes from the `W3C Standard Proposal`_ are allowed. // config/packages/framework.php use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { $framework->htmlSanitizer() ->sanitizer('app.post_sanitizer') // allow the
element and 2 attributes @@ -443,7 +443,7 @@ This can also be used to remove elements from the allow list. // config/packages/framework.php use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { $framework->htmlSanitizer() ->sanitizer('app.post_sanitizer') // remove
, but process the children @@ -521,7 +521,7 @@ on all elements allowed *before this setting*. // config/packages/framework.php use Symfony\Config\FrameworkConfig; - return static function (FrameworkConfig $framework) { + return static function (FrameworkConfig $framework): void { $framework->htmlSanitizer() ->sanitizer('app.post_sanitizer') // allow "src' on