From 1fbacaf0467d8f805898f227250986ee09364907 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 19 May 2021 17:13:46 +0200 Subject: [PATCH 0001/2491] 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/2491] 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/2491] [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/2491] 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/2491] 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/2491] 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/2491] [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/2491] 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/2491] 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/2491] 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/2491] [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/2491] [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/2491] 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/2491] 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/2491] [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/2491] 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/2491] 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/2491] 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/2491] [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/2491] 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/2491] 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/2491] [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/2491] 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/2491] [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/2491] [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/2491] [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/2491] 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/2491] 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/2491] 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/2491] 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/2491] [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/2491] 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/2491] [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/2491] 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/2491] [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/2491] [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/2491] 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/2491] 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/2491] 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/2491] 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/2491] [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/2491] 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/2491] [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/2491] [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/2491] [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/2491] [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/2491] [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/2491] [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/2491] [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/2491] [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/2491] [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/2491] [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/2491] 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/2491] [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/2491] [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/2491] [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/2491] 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 + asset ~~~~~ @@ -171,6 +186,11 @@ csrf_token Renders a CSRF token. Use this function if you want :doc:`CSRF protection ` in a regular HTML form not managed by the Symfony Form component. +.. code-block:: twig + + {{ csrf_token(intention = 'my_form') }} + {# output: generates a variable token #} + is_granted ~~~~~~~~~~ @@ -830,6 +850,28 @@ Generates an excerpt of a code file around the given ``line`` number. The ``srcContext`` argument defines the total number of lines to display around the given line number (use ``-1`` to display the whole file). +Let's assume this is the content of a file : + +.. code-block:: text + + a + b + c + d + e + +.. code-block:: twig + + {{ "/path/to/file/file.txt"|file_excerpt(line = 4, srcContext = 1) }} + {# output: + 3.c + 4.d + 5.e #} + + {{ "/path/to/file/file.txt"|file_excerpt(line = 1, srcContext = 0) }} + {# output: + 1.a #} + format_file ~~~~~~~~~~~ @@ -848,6 +890,36 @@ Generates the file path inside an ```` element. If the path is inside the kernel root directory, the kernel root directory path is replaced by ``kernel.project_dir`` (showing the full path in a tooltip on hover). +Example 1 + +.. code-block:: twig + + {{ "path/to/file/file.txt"|format_file(line = 1, text = "my_text") }} + +Output: + +.. code-block:: html + + my_text at line 1 + + +Example 2 + +.. code-block:: twig + + {{ "path/to/file/file.txt"|format_file(line = 3) }} + +Output: + +.. code-block:: html + + + file.txt + / at line 3 + + format_file_from_text ~~~~~~~~~~~~~~~~~~~~~ From 3c4f75387112e4e5f755f7925517edcbf86ab668 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 3 Apr 2025 12:33:55 +0200 Subject: [PATCH 2422/2491] Tweaks and rewords --- reference/configuration/framework.rst | 2 + reference/twig_reference.rst | 84 ++++++++++++--------------- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 8838a6a61b2..2274addf1aa 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -271,6 +271,8 @@ The ``trusted_proxies`` option is needed to get precise information about the client (e.g. their IP address) when running Symfony behind a load balancer or a reverse proxy. See :doc:`/deployment/proxies`. +.. _reference-framework-ide: + ide ~~~ diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 50da312f29f..08ea8f1d581 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -96,22 +96,12 @@ Returns an instance of ``ControllerReference`` to be used with functions like :ref:`render() ` and :ref:`render_esi() `. -.. _reference-twig-function-asset: - .. code-block:: html+twig - {% set myArray = {'a': 'foo', 'b': 'bar'} %} - - - -Output: - -.. code-block:: html + {{ render(controller('App\\Controller\\BlogController:latest', {max: 3})) }} + {# output: the content returned by the controller method; e.g. a rendered Twig template #} - +.. _reference-twig-function-asset: asset ~~~~~ @@ -188,8 +178,9 @@ in a regular HTML form not managed by the Symfony Form component. .. code-block:: twig - {{ csrf_token(intention = 'my_form') }} - {# output: generates a variable token #} + {{ csrf_token('my_form') }} + {# output: a random alphanumeric string like: + a.YOosAd0fhT7BEuUCFbROzrvgkW8kpEmBDQ_DKRMUi2o.Va8ZQKt5_2qoa7dLW-02_PLYwDBx9nnWOluUHUFCwC5Zo0VuuVfQCqtngg #} is_granted ~~~~~~~~~~ @@ -850,7 +841,7 @@ Generates an excerpt of a code file around the given ``line`` number. The ``srcContext`` argument defines the total number of lines to display around the given line number (use ``-1`` to display the whole file). -Let's assume this is the content of a file : +Consider the following as the content of ``file.txt``: .. code-block:: text @@ -862,15 +853,21 @@ Let's assume this is the content of a file : .. code-block:: twig - {{ "/path/to/file/file.txt"|file_excerpt(line = 4, srcContext = 1) }} + {{ '/path/to/file.txt'|file_excerpt(line = 4, srcContext = 1) }} {# output: - 3.c - 4.d - 5.e #} - - {{ "/path/to/file/file.txt"|file_excerpt(line = 1, srcContext = 0) }} +
    +
  1. c
  2. +
  3. d
  4. +
  5. e
  6. +
+ #} + + {{ '/path/to/file.txt'|file_excerpt(line = 1, srcContext = 0) }} {# output: - 1.a #} +
    +
  1. a
  2. +
+ #} format_file ~~~~~~~~~~~ @@ -890,35 +887,28 @@ Generates the file path inside an ```` element. If the path is inside the kernel root directory, the kernel root directory path is replaced by ``kernel.project_dir`` (showing the full path in a tooltip on hover). -Example 1 - .. code-block:: twig - {{ "path/to/file/file.txt"|format_file(line = 1, text = "my_text") }} - -Output: - -.. code-block:: html - - my_text at line 1 - - -Example 2 - -.. code-block:: twig - - {{ "path/to/file/file.txt"|format_file(line = 3) }} + {{ '/path/to/file.txt'|format_file(line = 1, text = "my_text") }} + {# output: + my_text at line 1 + + #} -Output: + {{ "/path/to/file.txt"|format_file(line = 3) }} + {# output: + /path/to/file.txt at line 3 + + #} -.. code-block:: html +.. tip:: - - file.txt - / at line 3 - + If you set the :ref:`framework.ide ` option, the + generated links will change to open the file in that IDE/editor. For example, + when using PhpStorm, the `` Date: Thu, 3 Apr 2025 12:40:55 +0200 Subject: [PATCH 2423/2491] Fix some syntax issues --- reference/twig_reference.rst | 46 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 08ea8f1d581..8ad72575e82 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -96,7 +96,7 @@ Returns an instance of ``ControllerReference`` to be used with functions like :ref:`render() ` and :ref:`render_esi() `. -.. code-block:: html+twig +.. code-block:: twig {{ render(controller('App\\Controller\\BlogController:latest', {max: 3})) }} {# output: the content returned by the controller method; e.g. a rendered Twig template #} @@ -851,23 +851,21 @@ Consider the following as the content of ``file.txt``: d e -.. code-block:: twig +.. code-block:: html+twig {{ '/path/to/file.txt'|file_excerpt(line = 4, srcContext = 1) }} - {# output: -
    -
  1. c
  2. -
  3. d
  4. -
  5. e
  6. -
- #} + {# output: #} +
    +
  1. c
  2. +
  3. d
  4. +
  5. e
  6. +
{{ '/path/to/file.txt'|file_excerpt(line = 1, srcContext = 0) }} - {# output: -
    -
  1. a
  2. -
- #} + {# output: #} +
    +
  1. a
  2. +
format_file ~~~~~~~~~~~ @@ -887,21 +885,19 @@ Generates the file path inside an ```` element. If the path is inside the kernel root directory, the kernel root directory path is replaced by ``kernel.project_dir`` (showing the full path in a tooltip on hover). -.. code-block:: twig +.. code-block:: html+twig {{ '/path/to/file.txt'|format_file(line = 1, text = "my_text") }} - {# output: - my_text at line 1 - - #} + {# output: #} + my_text at line 1 + {{ "/path/to/file.txt"|format_file(line = 3) }} - {# output: - /path/to/file.txt at line 3 - - #} + {# output: #} + /path/to/file.txt at line 3 + .. tip:: From 534c9837e20c0049a2cdcf93f6b93a647a581bae Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 4 Apr 2025 08:31:32 +0200 Subject: [PATCH 2424/2491] Reword --- scheduler.rst | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/scheduler.rst b/scheduler.rst index e9c729ab986..63ec32962cf 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -290,32 +290,25 @@ defined by PHP datetime functions:: You can also define periodic tasks using :ref:`the AsPeriodicTask attribute `. -Be aware that the message isn't passed to the messenger when you start the -scheduler. The message will only be executed after the first frequency period -has passed. - -It's also possible to pass a from and until time for your schedule. For -example, if you want to execute a command every day at 13:00:: +You can also define ``from`` and ``until`` times for your schedule:: + // create a message every day at 13:00 $from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris')); - RecurringMessage::every('1 day', new Message(), from: $from); - -Or if you want to execute a message every day until a specific date:: + RecurringMessage::every('1 day', new Message(), $from); + // create a message every day until a specific date:: $until = '2023-06-12'; - RecurringMessage::every('1 day', new Message(), until: $until); - -And you can even combine the from and until parameters for more granular -control:: + RecurringMessage::every('1 day', new Message(), null, $until); + // combine from and until for more precise control $from = new \DateTimeImmutable('2023-01-01 13:47', new \DateTimeZone('Europe/Paris')); $until = '2023-06-12'; - RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until); + RecurringMessage::every('first Monday of next month', new Message(), $from, $until); -If you don't pass a from parameter to your schedule, the first frequency period -is counted from the moment the scheduler is started. So if you start your -scheduler at 8:33 and the message is scheduled to perform every hour, it -will be executed at 9:33, 10:33, 11:33 and so on. +When starting the scheduler, the message isn't sent to the messenger immediately. +If you don't set a ``from`` parameter, the first frequency period starts from the +moment the scheduler runs. For example, if you start it at 8:33 and the message +is scheduled hourly, it will run at 9:33, 10:33, 11:33, etc. Custom Triggers ~~~~~~~~~~~~~~~ From 9c2d1d9198e70676f45a34119d7d563718840db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D1=80=D0=B8=D0=B3=D0=BE=D1=80=D0=B8=D0=B9?= Date: Sun, 25 Aug 2024 21:23:24 +1200 Subject: [PATCH 2425/2491] [Mailer] Update mailer.rst --- mailer.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mailer.rst b/mailer.rst index 53a6475a093..27a90c73191 100644 --- a/mailer.rst +++ b/mailer.rst @@ -834,6 +834,13 @@ The exceptions related to mailer transports (those which implement :class:`Symfony\\Component\\Mailer\\Exception\\TransportException`) also provide this debug information via the ``getDebug()`` method. +But you have to keep in mind that using :class:`Symfony\\Component\\Mailer\\Transport\\TransportInterface` +you can't rely on asynchronous sending emails. +It doesn't use a bus to dispatch :class:`Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage`. + +Use :class:`Symfony\\Component\\Mailer\\MailerInterface` if you want to have an opportunity +to send emails asynchronously. + .. _mailer-twig: Twig: HTML & CSS From eb5f908bc97bd2b40d9bbe644d8c61674d1a7714 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Fri, 4 Apr 2025 10:44:13 -0400 Subject: [PATCH 2426/2491] [RateLimiter] default `lock_factory` to `auto` --- rate_limiter.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 6c158ee52d0..1cef90828f5 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -461,9 +461,10 @@ simultaneous requests (e.g. three servers of a company hitting your API at the same time). Rate limiters use :doc:`locks ` to protect their operations against these race conditions. -By default, Symfony uses the global lock configured by ``framework.lock``, but -you can use a specific :ref:`named lock ` via the -``lock_factory`` option (or none at all): +By default, if the :doc:`lock ` component is installed, Symfony uses the +global lock configured by ``framework.lock``, but you can use a specific +:ref:`named lock ` via the ``lock_factory`` option (or none +at all): .. configuration-block:: From 74a146ee4f74fbc7dae98fa695040dd8da81dcc3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 4 Apr 2025 16:51:36 +0200 Subject: [PATCH 2427/2491] Reword --- mailer.rst | 65 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/mailer.rst b/mailer.rst index 27a90c73191..52c6ee7dded 100644 --- a/mailer.rst +++ b/mailer.rst @@ -807,40 +807,59 @@ Catch that exception to recover from the error or to display some message:: Debugging Emails ---------------- -The :class:`Symfony\\Component\\Mailer\\SentMessage` object returned by the -``send()`` method of the :class:`Symfony\\Component\\Mailer\\Transport\\TransportInterface` -provides access to the original message (``getOriginalMessage()``) and to some -debug information (``getDebug()``) such as the HTTP calls done by the HTTP -transports, which is useful to debug errors. +The ``send()`` method of the mailer service injected when using ``MailerInterface`` +doesn't return anything, so you can't access the sent email information. This is because +it sends email messages **asynchronously** when the :doc:`Messenger component ` +is used in the application. -You can also access :class:`Symfony\\Component\\Mailer\\SentMessage` by listening -to the :ref:`SentMessageEvent ` and retrieve ``getDebug()`` -by listening to the :ref:`FailedMessageEvent `. +To access information about the sent email, update your code to replace the +:class:`Symfony\\Component\\Mailer\\MailerInterface` with +:class:`Symfony\\Component\\Mailer\\Transport\\TransportInterface`: -.. note:: +.. code-block:: diff + + -use Symfony\Component\Mailer\MailerInterface; + +use Symfony\Component\Mailer\Transport\TransportInterface; + // ... + + class MailerController extends AbstractController + { + #[Route('/email')] + - public function sendEmail(MailerInterface $mailer): Response + + public function sendEmail(TransportInterface $mailer): Response + { + $email = (new Email()) + // ... + + $sentEmail = $mailer->send($email); - If your code used :class:`Symfony\\Component\\Mailer\\MailerInterface`, you - need to replace it by :class:`Symfony\\Component\\Mailer\\Transport\\TransportInterface` - to have the ``SentMessage`` object returned. + // ... + } + } + +The ``send()`` method of ``TransportInterface`` returns an object of type +:class:`Symfony\\Component\\Mailer\\SentMessage`. This is because it always sends +the emails **synchronously**, even if your application uses the Messenger component. + +The ``SentMessage`` object provides access to the original message +(``getOriginalMessage()``) and to some debug information (``getDebug()``) such +as the HTTP calls done by the HTTP transports, which is useful to debug errors. + +You can also access the :class:`Symfony\\Component\\Mailer\\SentMessage` object +by listening to the :ref:`SentMessageEvent `, and retrieve +``getDebug()`` by listening to the :ref:`FailedMessageEvent `. .. note:: Some mailer providers change the ``Message-Id`` when sending the email. The - ``getMessageId()`` method from ``SentMessage`` always returns the definitive - ID of the message (being the original random ID generated by Symfony or the - new ID generated by the mailer provider). + ``getMessageId()`` method from ``SentMessage`` always returns the final ID + of the message - whether it's the original random ID generated by Symfony or + a new one generated by the provider. -The exceptions related to mailer transports (those which implement +Exceptions related to mailer transports (those implementing :class:`Symfony\\Component\\Mailer\\Exception\\TransportException`) also provide this debug information via the ``getDebug()`` method. -But you have to keep in mind that using :class:`Symfony\\Component\\Mailer\\Transport\\TransportInterface` -you can't rely on asynchronous sending emails. -It doesn't use a bus to dispatch :class:`Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage`. - -Use :class:`Symfony\\Component\\Mailer\\MailerInterface` if you want to have an opportunity -to send emails asynchronously. - .. _mailer-twig: Twig: HTML & CSS From 8ed84b509d7a062e4991024d71770e0411f2f77c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 4 Apr 2025 16:53:55 +0200 Subject: [PATCH 2428/2491] Fix RST syntax issue --- scheduler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduler.rst b/scheduler.rst index 63ec32962cf..e7d855db249 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -296,7 +296,7 @@ You can also define ``from`` and ``until`` times for your schedule:: $from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris')); RecurringMessage::every('1 day', new Message(), $from); - // create a message every day until a specific date:: + // create a message every day until a specific date $until = '2023-06-12'; RecurringMessage::every('1 day', new Message(), null, $until); From 19b99dbe1b32290052fd6d211e75836efa00f20b Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 4 Apr 2025 17:04:03 +0200 Subject: [PATCH 2429/2491] [Config] Add `NodeDefinition::docUrl()` --- components/config/definition.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/config/definition.rst b/components/config/definition.rst index 44189d9dd6f..4848af33ffe 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -546,6 +546,30 @@ and in XML: +You can also provide a URL to a full documentation page:: + + $rootNode + ->docUrl('Full documentation is available at https://example.com/docs/{version:major}.{version:minor}/reference.html') + ->children() + ->integerNode('entries_per_page') + ->defaultValue(25) + ->end() + ->end() + ; + +A few placeholders are available to customize the URL: + +* ``{version:major}``: The major version of the package currently installed +* ``{version:minor}``: The minor version of the package currently installed +* ``{package}``: The name of the package + +The placeholders will be replaced when printing the configuration tree with the +``config:dump-reference`` command. + +.. versionadded:: 7.3 + + The ``docUrl()`` method was introduced in Symfony 7.3. + Optional Sections ----------------- From 50b6ffdac765fad51e6c087a00667711840aea10 Mon Sep 17 00:00:00 2001 From: RisingSunLight Date: Mon, 7 Apr 2025 00:49:36 +0200 Subject: [PATCH 2430/2491] fix command explanation --- templates.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates.rst b/templates.rst index 77e10bc5596..98742058988 100644 --- a/templates.rst +++ b/templates.rst @@ -849,7 +849,8 @@ errors. It's useful to run it before deploying your application to production $ php bin/console lint:twig templates/email/ $ php bin/console lint:twig templates/article/recent_list.html.twig - # you can also show the deprecated features used in your templates + # you can also show the first deprecated feature used in your templates + # as it shows only the first one found, you may need to run it until no more deprecations are found $ php bin/console lint:twig --show-deprecations templates/email/ When running the linter inside `GitHub Actions`_, the output is automatically From 20ce1892efe75de46c9447a7a40baab5f6a5a2a0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Apr 2025 08:09:16 +0200 Subject: [PATCH 2431/2491] Added a versionadded directive --- rate_limiter.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rate_limiter.rst b/rate_limiter.rst index 1cef90828f5..81bd7f5689e 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -535,6 +535,12 @@ at all): ; }; +.. versionadded:: 7.3 + + Before Symfony 7.3, configuring a rate limiter and using the default configured + lock factory (``lock.factory``) failed if the Symfony Lock component was not + installed in the application. + .. _`DoS attacks`: https://cheatsheetseries.owasp.org/cheatsheets/Denial_of_Service_Cheat_Sheet.html .. _`Apache mod_ratelimit`: https://httpd.apache.org/docs/current/mod/mod_ratelimit.html .. _`NGINX rate limiting`: https://www.nginx.com/blog/rate-limiting-nginx/ From 03321a8e0246365b1a17ac998f1de895f28b94ad Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Apr 2025 08:36:00 +0200 Subject: [PATCH 2432/2491] Minor reword --- templates.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates.rst b/templates.rst index 98742058988..5e34b930d0e 100644 --- a/templates.rst +++ b/templates.rst @@ -849,8 +849,8 @@ errors. It's useful to run it before deploying your application to production $ php bin/console lint:twig templates/email/ $ php bin/console lint:twig templates/article/recent_list.html.twig - # you can also show the first deprecated feature used in your templates - # as it shows only the first one found, you may need to run it until no more deprecations are found + # you can also show the deprecated features used in your templates + # (only the first deprecation is shown, so run multiple times to catch all) $ php bin/console lint:twig --show-deprecations templates/email/ When running the linter inside `GitHub Actions`_, the output is automatically From b5efbcd9a777ac3e913a93fdfb96e1c0ef934fc7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Apr 2025 08:41:41 +0200 Subject: [PATCH 2433/2491] [Templates] Add a versionadded diretive for a command change --- templates.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates.rst b/templates.rst index a93bbe742c6..c6312abb33c 100644 --- a/templates.rst +++ b/templates.rst @@ -870,7 +870,6 @@ errors. It's useful to run it before deploying your application to production $ php bin/console lint:twig templates/article/recent_list.html.twig # you can also show the deprecated features used in your templates - # (only the first deprecation is shown, so run multiple times to catch all) $ php bin/console lint:twig --show-deprecations templates/email/ # you can also excludes directories @@ -880,6 +879,11 @@ errors. It's useful to run it before deploying your application to production The option to exclude directories was introduced in Symfony 7.1. +.. versionadded:: 7.3 + + Before Symfony 7.3, the ``--show-deprecations`` option only displayed the + first deprecation found, so you had to run the command repeatedly. + When running the linter inside `GitHub Actions`_, the output is automatically adapted to the format required by GitHub, but you can force that format too: From 97de6eb32ef3f5d8d1b7d2c1fca5fffe04806c1f Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Mon, 7 Apr 2025 08:42:34 +0200 Subject: [PATCH 2434/2491] [Translator] document global variables feature configuration --- translation.rst | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/translation.rst b/translation.rst index c8996c08b48..7800161d77b 100644 --- a/translation.rst +++ b/translation.rst @@ -1160,6 +1160,67 @@ service argument with the :class:`Symfony\\Component\\Translation\\LocaleSwitche class to inject the locale switcher service. Otherwise, configure your services manually and inject the ``translation.locale_switcher`` service. +.. _translation-global-variables: + +Global Variables +~~~~~~~~~~~~~~~~ + +The translator allows you to automatically configure global variables that will be available +for the translation process. These global variables are defined in the ``translations.globals`` +option inside the main configuration file: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/translator.yaml + translator: + # ... + globals: + '%%app_name%%': 'My application' + '{app_version}': '1.2.3' + '{url}': { message: 'url', parameters: { scheme: 'https://' }, domain: 'global' } + + .. code-block:: xml + + + + + + + + + My application + + + https:// + + + + + + .. code-block:: php + + // config/packages/translator.php + use Symfony\Config\TwigConfig; + + return static function (TwigConfig $translator): void { + // ... + $translator->globals('%%app_name%%')->value('My application'); + $translator->globals('{app_version}')->value('1.2.3'); + $translator->globals('{url}')->value(['message' => 'url', 'parameters' => ['scheme' => 'https://']); + }; + +.. versionadded:: 7.3 + + The ``translator:globals`` option was introduced in Symfony 7.3. + .. _translation-debug: How to Find Missing or Unused Translation Messages From 97d301a5c1c4a69f3958777b95d9c8ffcd4b928b Mon Sep 17 00:00:00 2001 From: Pierre Ambroise Date: Wed, 2 Apr 2025 11:41:05 +0200 Subject: [PATCH 2435/2491] [Messenger] Document stamps in HandleTrait::handle --- messenger.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/messenger.rst b/messenger.rst index fc8f9491022..159dd567a34 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2512,6 +2512,20 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``:: } } +You also can also add stamps when handling a message. For example, you can +add an ``DoctrineFlushStamp`` to flush the entity manager after handling the message:: + + $this->handle(new SomeMessage($data), [new DoctrineFlushStamp()]); + +.. note:: + + If adding a stamp of the same type that already exists in the envelope, + both stamps will be kept (see `Envelopes & Stamps`_). + +.. versionadded:: 7.3 + + The ``$stamps`` parameter on the handle method was introduced in Symfony 7.3. + Customizing Handlers -------------------- From c2c14fd74b50128ffd986919aec8c1fc7cf49cca Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Apr 2025 09:40:08 +0200 Subject: [PATCH 2436/2491] Minor tweak --- messenger.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/messenger.rst b/messenger.rst index 47e0ad61906..b05056243c2 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2525,19 +2525,15 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``:: } } -You also can also add stamps when handling a message. For example, you can -add an ``DoctrineFlushStamp`` to flush the entity manager after handling the message:: +You can also add new stamps when handling a message; they will be appended +to the existing ones. For example, you can add a ``DoctrineFlushStamp`` to +flush the entity manager after handling the message:: $this->handle(new SomeMessage($data), [new DoctrineFlushStamp()]); -.. note:: - - If adding a stamp of the same type that already exists in the envelope, - both stamps will be kept (see `Envelopes & Stamps`_). - .. versionadded:: 7.3 - The ``$stamps`` parameter on the handle method was introduced in Symfony 7.3. + The ``$stamps`` parameter of the ``handle()`` method was introduced in Symfony 7.3. Customizing Handlers -------------------- From 7f9f20fcd83889b0725ec7d6e7192af8dc2391c8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Apr 2025 10:16:39 +0200 Subject: [PATCH 2437/2491] [Mesenger] Fix code example --- messenger.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/messenger.rst b/messenger.rst index b05056243c2..9078a500d11 100644 --- a/messenger.rst +++ b/messenger.rst @@ -2526,10 +2526,9 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``:: } You can also add new stamps when handling a message; they will be appended -to the existing ones. For example, you can add a ``DoctrineFlushStamp`` to -flush the entity manager after handling the message:: +to the existing ones:: - $this->handle(new SomeMessage($data), [new DoctrineFlushStamp()]); + $this->handle(new SomeMessage($data), [new SomeStamp(), new AnotherStamp()]); .. versionadded:: 7.3 From 11b256998374bdfbfa7a0155cf1274661a15811b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 8 Apr 2025 11:03:16 +0200 Subject: [PATCH 2438/2491] Tweaks and rewords --- translation.rst | 139 +++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 61 deletions(-) diff --git a/translation.rst b/translation.rst index 7800161d77b..35751d7db5f 100644 --- a/translation.rst +++ b/translation.rst @@ -416,6 +416,84 @@ You can also specify the message domain and pass some additional variables: major difference: automatic output escaping is **not** applied to translations using a tag. +Global Translation Parameters +----------------------------- + +.. versionadded:: 7.3 + + The global translation parameters feature was introduced in Symfony 7.3. + +If the content of a translation parameter is repeated across multiple +translation messages (e.g. a company name, or a version number), you can define +it as a global translation parameter. This helps you avoid repeating the same +values manually in each message. + +You can configure these global parameters in the ``translations.globals`` option +of your main configuration file using either ``%...%`` or ``{...}`` syntax: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/translator.yaml + translator: + # ... + globals: + # when using the '%' wrapping characters, you must escape them + '%%app_name%%': 'My application' + '{app_version}': '1.2.3' + '{url}': { message: 'url', parameters: { scheme: 'https://' }, domain: 'global' } + + .. code-block:: xml + + + + + + + + + + My application + + + https:// + + + + + + .. code-block:: php + + // config/packages/translator.php + use Symfony\Config\TwigConfig; + + return static function (TwigConfig $translator): void { + // ... + // when using the '%' wrapping characters, you must escape them + $translator->globals('%%app_name%%')->value('My application'); + $translator->globals('{app_version}')->value('1.2.3'); + $translator->globals('{url}')->value(['message' => 'url', 'parameters' => ['scheme' => 'https://']]); + }; + +Once defined, you can use these parameters in translation messages anywhere in +your application: + +.. code-block:: twig + + {{ 'Application version: {version}'|trans }} + {# output: "Application version: 1.2.3" #} + + {# parameters passed to the message override global parameters #} + {{ 'Package version: {version}'|trans({'{version}': '2.3.4'}) }} + # Displays "Package version: 2.3.4" + Forcing the Translator Locale ----------------------------- @@ -1160,67 +1238,6 @@ service argument with the :class:`Symfony\\Component\\Translation\\LocaleSwitche class to inject the locale switcher service. Otherwise, configure your services manually and inject the ``translation.locale_switcher`` service. -.. _translation-global-variables: - -Global Variables -~~~~~~~~~~~~~~~~ - -The translator allows you to automatically configure global variables that will be available -for the translation process. These global variables are defined in the ``translations.globals`` -option inside the main configuration file: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/translator.yaml - translator: - # ... - globals: - '%%app_name%%': 'My application' - '{app_version}': '1.2.3' - '{url}': { message: 'url', parameters: { scheme: 'https://' }, domain: 'global' } - - .. code-block:: xml - - - - - - - - - My application - - - https:// - - - - - - .. code-block:: php - - // config/packages/translator.php - use Symfony\Config\TwigConfig; - - return static function (TwigConfig $translator): void { - // ... - $translator->globals('%%app_name%%')->value('My application'); - $translator->globals('{app_version}')->value('1.2.3'); - $translator->globals('{url}')->value(['message' => 'url', 'parameters' => ['scheme' => 'https://']); - }; - -.. versionadded:: 7.3 - - The ``translator:globals`` option was introduced in Symfony 7.3. - .. _translation-debug: How to Find Missing or Unused Translation Messages From fff52938f54f32cb6b246f73423affbe1365660b Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 8 Apr 2025 07:23:44 -0400 Subject: [PATCH 2439/2491] [RateLimiter] deprecate injecting `RateLimiterFactory` --- rate_limiter.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 81bd7f5689e..1036e80e682 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -230,6 +230,12 @@ prevents that number from being higher than 5,000). Rate Limiting in Action ----------------------- +.. versionadded:: 7.3 + + :class:`Symfony\\Component\\RateLimiter\\RateLimiterFactoryInterface` was + added and should now be used for autowiring instead of + :class:`Symfony\\Component\\RateLimiter\\RateLimiterFactory`. + After having installed and configured the rate limiter, inject it in any service or controller and call the ``consume()`` method to try to consume a given number of tokens. For example, this controller uses the previous rate limiter to control @@ -242,13 +248,13 @@ the number of requests to the API:: use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; - use Symfony\Component\RateLimiter\RateLimiterFactory; + use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; class ApiController extends AbstractController { // if you're using service autowiring, the variable name must be: // "rate limiter name" (in camelCase) + "Limiter" suffix - public function index(Request $request, RateLimiterFactory $anonymousApiLimiter): Response + public function index(Request $request, RateLimiterFactoryInterface $anonymousApiLimiter): Response { // create a limiter based on a unique identifier of the client // (e.g. the client's IP address, a username/email, an API key, etc.) @@ -291,11 +297,11 @@ using the ``reserve()`` method:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\RateLimiter\RateLimiterFactory; + use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; class ApiController extends AbstractController { - public function registerUser(Request $request, RateLimiterFactory $authenticatedApiLimiter): Response + public function registerUser(Request $request, RateLimiterFactoryInterface $authenticatedApiLimiter): Response { $apiKey = $request->headers->get('apikey'); $limiter = $authenticatedApiLimiter->create($apiKey); @@ -350,11 +356,11 @@ the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\RateLimiter\RateLimiterFactory; + use Symfony\Component\RateLimiter\RateLimiterFactoryInterface; class ApiController extends AbstractController { - public function index(Request $request, RateLimiterFactory $anonymousApiLimiter): Response + public function index(Request $request, RateLimiterFactoryInterface $anonymousApiLimiter): Response { $limiter = $anonymousApiLimiter->create($request->getClientIp()); $limit = $limiter->consume(); From 35349c17b05de94e156ca0247b2f4d9f887aaa3a Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 8 Apr 2025 07:45:37 -0400 Subject: [PATCH 2440/2491] [RateLimiter] compound rate limiter --- rate_limiter.rst | 117 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/rate_limiter.rst b/rate_limiter.rst index 81bd7f5689e..906e787e7e1 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -541,6 +541,123 @@ at all): lock factory (``lock.factory``) failed if the Symfony Lock component was not installed in the application. +Compound Rate Limiter +--------------------- + +.. versionadded:: 7.3 + + Configuring compound rate limiters was added in 7.3. + +You can configure multiple rate limiters to work together: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/rate_limiter.yaml + framework: + rate_limiter: + two_per_minute: + policy: 'fixed_window' + limit: 2 + interval: '1 minute' + five_per_hour: + policy: 'fixed_window' + limit: 5 + interval: '1 hour' + contact_form: + policy: 'compound' + limiters: [two_per_minute, five_per_hour] + + .. code-block:: xml + + + + + + + + + + + + + two_per_minute + five_per_hour + + + + + + .. code-block:: php + + // config/packages/rate_limiter.php + use Symfony\Config\FrameworkConfig; + + return static function (FrameworkConfig $framework): void { + $framework->rateLimiter() + ->limiter('two_per_minute') + ->policy('fixed_window') + ->limit(2) + ->interval('1 minute') + ; + + $framework->rateLimiter() + ->limiter('two_per_minute') + ->policy('fixed_window') + ->limit(5) + ->interval('1 hour') + ; + + $framework->rateLimiter() + ->limiter('contact_form') + ->policy('compound') + ->limiters(['two_per_minute', 'five_per_hour']) + ; + }; + +Then, inject and use as normal:: + + // src/Controller/ContactController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\RateLimiter\RateLimiterFactory; + + class ContactController extends AbstractController + { + public function registerUser(Request $request, RateLimiterFactoryInterface $contactFormLimiter): Response + { + $limiter = $contactFormLimiter->create($request->getClientIp()); + + if (false === $limiter->consume(1)->isAccepted()) { + // either of the two limiters has been reached + } + + // ... + } + + // ... + } + .. _`DoS attacks`: https://cheatsheetseries.owasp.org/cheatsheets/Denial_of_Service_Cheat_Sheet.html .. _`Apache mod_ratelimit`: https://httpd.apache.org/docs/current/mod/mod_ratelimit.html .. _`NGINX rate limiting`: https://www.nginx.com/blog/rate-limiting-nginx/ From 70716ab76d3e4066668c81ad1be465e3dc1a772e Mon Sep 17 00:00:00 2001 From: Hubert Lenoir Date: Tue, 8 Apr 2025 17:57:53 +0200 Subject: [PATCH 2441/2491] Update service_container.rst to 7.3 --- service_container.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/service_container.rst b/service_container.rst index 30b69b8aa14..9a024e5e320 100644 --- a/service_container.rst +++ b/service_container.rst @@ -162,10 +162,6 @@ each time you ask for it. # this creates a service per class whose id is the fully-qualified class name App\: resource: '../src/' - exclude: - - '../src/DependencyInjection/' - - '../src/Entity/' - - '../src/Kernel.php' # order is important in this file because service definitions # always *replace* previous ones; add your own service configuration below @@ -187,7 +183,7 @@ each time you ask for it. - + @@ -212,8 +208,7 @@ each time you ask for it. // makes classes in src/ available to be used as services // this creates a service per class whose id is the fully-qualified class name - $services->load('App\\', '../src/') - ->exclude('../src/{DependencyInjection,Entity,Kernel.php}'); + $services->load('App\\', '../src/'); // order is important in this file because service definitions // always *replace* previous ones; add your own service configuration below @@ -221,9 +216,7 @@ each time you ask for it. .. tip:: - The value of the ``resource`` and ``exclude`` options can be any valid - `glob pattern`_. The value of the ``exclude`` option can also be an - array of glob patterns. + The value of the ``resource`` option can be any valid `glob pattern`_. Thanks to this configuration, you can automatically use any classes from the ``src/`` directory as a service, without needing to manually configure From c0f12c7408489bb8031b77d2caea5e3ce547781f Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Tue, 8 Apr 2025 20:36:41 +0200 Subject: [PATCH 2442/2491] [Translation] Fix Lint (DOCtor-RST) --- translation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translation.rst b/translation.rst index 35751d7db5f..86282090801 100644 --- a/translation.rst +++ b/translation.rst @@ -461,7 +461,7 @@ of your main configuration file using either ``%...%`` or ``{...}`` syntax: My application - + https:// From ac9e20cad5195c101d843bcb6cb391f0b9316011 Mon Sep 17 00:00:00 2001 From: Mokhtar Tlili Date: Tue, 8 Apr 2025 21:05:43 +0200 Subject: [PATCH 2443/2491] Add docs for bridge twig validator #20836 --- bridge/twig/validation.rst | 63 ++++++++++++++++++++++++++++++++++++++ index.rst | 1 + twig_bridge.rst | 9 ++++++ 3 files changed, 73 insertions(+) create mode 100644 bridge/twig/validation.rst create mode 100644 twig_bridge.rst diff --git a/bridge/twig/validation.rst b/bridge/twig/validation.rst new file mode 100644 index 00000000000..e7b887f5588 --- /dev/null +++ b/bridge/twig/validation.rst @@ -0,0 +1,63 @@ +Validating Twig Template Syntax +=============================== + +The Twig Bridge provides a custom `Twig` constraint that allows validating +whether a given string contains valid Twig syntax. + +This is particularly useful when template content is user-generated or +configurable, and you want to ensure it can be safely rendered by the Twig engine. + +Installation +------------ + +This constraint is part of the `symfony/twig-bridge` package. Make sure it's installed: + +.. code-block:: terminal + + $ composer require symfony/twig-bridge + +Usage +----- + +To use the `Twig` constraint, annotate the property that should contain a valid +Twig template:: + + use Symfony\Bridge\Twig\Validator\Constraints\Twig; + + class Template + { + #[Twig] + private string $templateCode; + } + +If the template contains a syntax error, a validation error will be thrown. + +Constraint Options +------------------ + +**message** +Customize the default error message when the template is invalid:: + + // ... + class Template + { + #[Twig(message: 'Your template contains a syntax error.')] + private string $templateCode; + } + +**skipDeprecations** +By default, this option is set to `true`, which means Twig deprecation warnings +are ignored during validation. + +If you want validation to fail when deprecated features are used in the template, +set this to `false`:: + + // ... + class Template + { + #[Twig(skipDeprecations: false)] + private string $templateCode; + } + +This can be helpful when enforcing stricter template rules or preparing for major +Twig version upgrades. diff --git a/index.rst b/index.rst index c566e5f8671..2bd09c8c0dc 100644 --- a/index.rst +++ b/index.rst @@ -60,6 +60,7 @@ Topics web_link webhook workflow + twig_bridge Components ---------- diff --git a/twig_bridge.rst b/twig_bridge.rst new file mode 100644 index 00000000000..bb7d84f7e9a --- /dev/null +++ b/twig_bridge.rst @@ -0,0 +1,9 @@ +Twig Bridge +=========== + +This bridge integrates Symfony with the Twig templating engine. + +.. toctree:: + :maxdepth: 1 + + bridge/twig/validation From a7a6c1d23db3430752cbdf59354aad47aaa4ef32 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 8 Apr 2025 07:13:46 -0400 Subject: [PATCH 2444/2491] [Scheduler][Webhook] add screencast links --- scheduler.rst | 6 ++++++ webhook.rst | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/scheduler.rst b/scheduler.rst index a09fabfc4ca..1630fd8dada 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -1,6 +1,11 @@ Scheduler ========= +.. admonition:: Screencast + :class: screencast + + Like video tutorials? Check out this `Scheduler quick-start screencast`_. + The scheduler component manages task scheduling within your PHP application, like running a task each night at 3 AM, every two weeks except for holidays or any other custom schedule you might need. @@ -1008,3 +1013,4 @@ helping you identify those messages when needed. .. _`cron command-line utility`: https://en.wikipedia.org/wiki/Cron .. _`crontab.guru website`: https://crontab.guru/ .. _`relative formats`: https://www.php.net/manual/en/datetime.formats.php#datetime.formats.relative +.. _`Scheduler quick-start screencast`: https://symfonycasts.com/screencast/mailtrap/bonus-symfony-scheduler diff --git a/webhook.rst b/webhook.rst index aba95cffb04..9d6b56c7ef0 100644 --- a/webhook.rst +++ b/webhook.rst @@ -15,6 +15,11 @@ Installation Usage in Combination with the Mailer Component ---------------------------------------------- +.. admonition:: Screencast + :class: screencast + + Like video tutorials? Check out the `Webhook Component for Email Events screencast`_. + When using a third-party mailer provider, you can use the Webhook component to receive webhook calls from this provider. @@ -207,3 +212,4 @@ Creating a Custom Webhook Webhook. .. _`MakerBundle`: https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html +.. _`Webhook Component for Email Events screencast`: https://symfonycasts.com/screencast/mailtrap/email-event-webhook From 59fd3a3f167c8c799fad3256ace24dc8a72501de Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 9 Apr 2025 12:31:13 +0200 Subject: [PATCH 2445/2491] Tweaks --- service_container.rst | 44 ++++++++++++++++++++++++++++++++++++ service_container/import.rst | 7 ++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/service_container.rst b/service_container.rst index 9a024e5e320..6ae601cf724 100644 --- a/service_container.rst +++ b/service_container.rst @@ -223,6 +223,50 @@ each time you ask for it. it. Later, you'll learn how to :ref:`import many services at once ` with resource. + If some files or directories in your project should not become services, you + can exclude them using the ``exclude`` option: + + .. configuration-block:: + + .. code-block:: yaml + + # config/services.yaml + services: + # ... + App\: + resource: '../src/' + exclude: + - '../src/SomeDirectory/' + - '../src/AnotherDirectory/' + - '../src/SomeFile.php' + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return function(ContainerConfigurator $container): void { + // ... + + $services->load('App\\', '../src/') + ->exclude('../src/{SomeDirectory,AnotherDirectory,Kernel.php}'); + }; + If you'd prefer to manually wire your service, you can :ref:`use explicit configuration `. diff --git a/service_container/import.rst b/service_container/import.rst index d5056032115..293cb5b97c2 100644 --- a/service_container/import.rst +++ b/service_container/import.rst @@ -82,7 +82,6 @@ a relative or absolute path to the imported file: App\: resource: '../src/*' - exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' # ... @@ -104,8 +103,7 @@ a relative or absolute path to the imported file: - + @@ -127,8 +125,7 @@ a relative or absolute path to the imported file: ->autoconfigure() ; - $services->load('App\\', '../src/*') - ->exclude('../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'); + $services->load('App\\', '../src/*'); }; When loading a configuration file, Symfony loads first the imported files and From 518fc3a24cfd03eff976cf296997edc8e2aea2f8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 9 Apr 2025 16:22:11 +0200 Subject: [PATCH 2446/2491] Minor tweak --- rate_limiter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 4bd213d2363..3a517c37bd4 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -552,7 +552,7 @@ Compound Rate Limiter .. versionadded:: 7.3 - Configuring compound rate limiters was added in 7.3. + Support for configuring compound rate limiters was introduced in Symfony 7.3. You can configure multiple rate limiters to work together: From fcfcacb6afdd7b6fcbdf5587f9c59140b9d5f887 Mon Sep 17 00:00:00 2001 From: Van Truong PHAN Date: Thu, 10 Apr 2025 04:44:59 +0200 Subject: [PATCH 2447/2491] Franken PHP can perform some action after the response has been streamed to the user Franken also implements fastcgi_finish_request PHP function. kernel.terminate event works well with franken. --- components/http_kernel.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 351a2123b90..cf16de9fe61 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -497,8 +497,8 @@ as possible to the client (e.g. sending emails). .. warning:: Internally, the HttpKernel makes use of the :phpfunction:`fastcgi_finish_request` - PHP function. This means that at the moment, only the `PHP FPM`_ server - API is able to send a response to the client while the server's PHP process + PHP function. This means that at the moment, only the `PHP FPM`_ and `FrankenPHP`_ servers + API are able to send a response to the client while the server's PHP process still performs some tasks. With all other server APIs, listeners to ``kernel.terminate`` are still executed, but the response is not sent to the client until they are all completed. @@ -770,3 +770,4 @@ Learn more .. _FOSRestBundle: https://github.com/friendsofsymfony/FOSRestBundle .. _`PHP FPM`: https://www.php.net/manual/en/install.fpm.php .. _variadic: https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list +.. _`FrankenPHP`: https://frankenphp.dev From ccd113706035d4d5c09342c2d8de207d138cf53c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 10 Apr 2025 08:03:25 +0200 Subject: [PATCH 2448/2491] Minor tweak --- components/http_kernel.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/http_kernel.rst b/components/http_kernel.rst index cf16de9fe61..91643086a18 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -497,8 +497,8 @@ as possible to the client (e.g. sending emails). .. warning:: Internally, the HttpKernel makes use of the :phpfunction:`fastcgi_finish_request` - PHP function. This means that at the moment, only the `PHP FPM`_ and `FrankenPHP`_ servers - API are able to send a response to the client while the server's PHP process + PHP function. This means that at the moment, only the `PHP FPM`_ API and the + `FrankenPHP`_ server are able to send a response to the client while the server's PHP process still performs some tasks. With all other server APIs, listeners to ``kernel.terminate`` are still executed, but the response is not sent to the client until they are all completed. From 344d8baac24247f9a0637bec61a2896e9404c43b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 10 Apr 2025 09:12:48 +0200 Subject: [PATCH 2449/2491] Reorganized the contents of the new constraint --- bridge/twig/validation.rst | 63 --------------- index.rst | 1 - reference/constraints/Twig.rst | 130 ++++++++++++++++++++++++++++++ reference/constraints/map.rst.inc | 1 + twig_bridge.rst | 9 --- 5 files changed, 131 insertions(+), 73 deletions(-) delete mode 100644 bridge/twig/validation.rst create mode 100644 reference/constraints/Twig.rst delete mode 100644 twig_bridge.rst diff --git a/bridge/twig/validation.rst b/bridge/twig/validation.rst deleted file mode 100644 index e7b887f5588..00000000000 --- a/bridge/twig/validation.rst +++ /dev/null @@ -1,63 +0,0 @@ -Validating Twig Template Syntax -=============================== - -The Twig Bridge provides a custom `Twig` constraint that allows validating -whether a given string contains valid Twig syntax. - -This is particularly useful when template content is user-generated or -configurable, and you want to ensure it can be safely rendered by the Twig engine. - -Installation ------------- - -This constraint is part of the `symfony/twig-bridge` package. Make sure it's installed: - -.. code-block:: terminal - - $ composer require symfony/twig-bridge - -Usage ------ - -To use the `Twig` constraint, annotate the property that should contain a valid -Twig template:: - - use Symfony\Bridge\Twig\Validator\Constraints\Twig; - - class Template - { - #[Twig] - private string $templateCode; - } - -If the template contains a syntax error, a validation error will be thrown. - -Constraint Options ------------------- - -**message** -Customize the default error message when the template is invalid:: - - // ... - class Template - { - #[Twig(message: 'Your template contains a syntax error.')] - private string $templateCode; - } - -**skipDeprecations** -By default, this option is set to `true`, which means Twig deprecation warnings -are ignored during validation. - -If you want validation to fail when deprecated features are used in the template, -set this to `false`:: - - // ... - class Template - { - #[Twig(skipDeprecations: false)] - private string $templateCode; - } - -This can be helpful when enforcing stricter template rules or preparing for major -Twig version upgrades. diff --git a/index.rst b/index.rst index 2bd09c8c0dc..c566e5f8671 100644 --- a/index.rst +++ b/index.rst @@ -60,7 +60,6 @@ Topics web_link webhook workflow - twig_bridge Components ---------- diff --git a/reference/constraints/Twig.rst b/reference/constraints/Twig.rst new file mode 100644 index 00000000000..8435c191855 --- /dev/null +++ b/reference/constraints/Twig.rst @@ -0,0 +1,130 @@ +Twig Constraint +=============== + +.. versionadded:: 7.3 + + The ``Twig`` constraint was introduced in Symfony 7.3. + +Validates that a given string contains valid :ref:`Twig syntax `. +This is particularly useful when template content is user-generated or +configurable, and you want to ensure it can be rendered by the Twig engine. + +.. note:: + + Using this constraint requires having the ``symfony/twig-bridge`` package + installed in your application (e.g. by running ``composer require symfony/twig-bridge``). + +========== =================================================================== +Applies to :ref:`property or method ` +Class :class:`Symfony\\Bridge\\Twig\\Validator\\Constraints\\Twig` +Validator :class:`Symfony\\Bridge\\Twig\\Validator\\Constraints\\TwigValidator` +========== =================================================================== + +Basic Usage +----------- + +Apply the ``Twig`` constraint to validate the contents of any property or the +returned value of any method: + + use Symfony\Bridge\Twig\Validator\Constraints\Twig; + + class Template + { + #[Twig] + private string $templateCode; + } + +.. configuration-block:: + + .. code-block:: php-attributes + + // src/Entity/Page.php + namespace App\Entity; + + use Symfony\Bridge\Twig\Validator\Constraints\Twig; + + class Page + { + #[Twig] + private string $templateCode; + } + + .. code-block:: yaml + + # config/validator/validation.yaml + App\Entity\Page: + properties: + templateCode: + - Symfony\Bridge\Twig\Validator\Constraints\Twig: ~ + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // src/Entity/Page.php + namespace App\Entity; + + use Symfony\Bridge\Twig\Validator\Constraints\Twig; + use Symfony\Component\Validator\Mapping\ClassMetadata; + + class Page + { + // ... + + public static function loadValidatorMetadata(ClassMetadata $metadata): void + { + $metadata->addPropertyConstraint('templateCode', new Twig()); + } + } + +Constraint Options +------------------ + +``message`` +~~~~~~~~~~~ + +**type**: ``message`` **default**: ``This value is not a valid Twig template.`` + +This is the message displayed when the given string does *not* contain valid Twig syntax:: + + // ... + + class Page + { + #[Twig(message: 'Check this Twig code; it contains errors.')] + private string $templateCode; + } + +This message has no parameters. + +``skipDeprecations`` +~~~~~~~~~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``true`` + +If ``true``, Twig deprecation warnings are ignored during validation. Set it to +``false`` to trigger validation errors when the given Twig code contains any deprecations:: + + // ... + + class Page + { + #[Twig(skipDeprecations: false)] + private string $templateCode; + } + +This can be helpful when enforcing stricter template rules or preparing for major +Twig version upgrades. diff --git a/reference/constraints/map.rst.inc b/reference/constraints/map.rst.inc index 58801a8c653..c2396ae3af7 100644 --- a/reference/constraints/map.rst.inc +++ b/reference/constraints/map.rst.inc @@ -34,6 +34,7 @@ String Constraints * :doc:`PasswordStrength ` * :doc:`Regex ` * :doc:`Slug ` +* :doc:`Twig ` * :doc:`Ulid ` * :doc:`Url ` * :doc:`UserPassword ` diff --git a/twig_bridge.rst b/twig_bridge.rst deleted file mode 100644 index bb7d84f7e9a..00000000000 --- a/twig_bridge.rst +++ /dev/null @@ -1,9 +0,0 @@ -Twig Bridge -=========== - -This bridge integrates Symfony with the Twig templating engine. - -.. toctree:: - :maxdepth: 1 - - bridge/twig/validation From b5f3bf13ed6858bb79901593bac9b3571ad53388 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Fri, 11 Apr 2025 14:43:37 +0200 Subject: [PATCH 2450/2491] Update end_to_end.rst --- testing/end_to_end.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/end_to_end.rst b/testing/end_to_end.rst index bb4a316f347..83d61b1e60f 100644 --- a/testing/end_to_end.rst +++ b/testing/end_to_end.rst @@ -26,7 +26,7 @@ to install the needed dependencies: .. code-block:: terminal - $ composer require symfony/panther + $ composer require --dev symfony/panther .. include:: /components/require_autoload.rst.inc From ce286296c47b9d53358a75df75f3f267b0286a75 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 10 Apr 2025 19:43:53 +0200 Subject: [PATCH 2451/2491] [Serializer] (re)document PRESERVE_EMPTY_OBJECTS --- serializer.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serializer.rst b/serializer.rst index 6e20a651341..b7deb6f5bff 100644 --- a/serializer.rst +++ b/serializer.rst @@ -1571,6 +1571,13 @@ to ``true``:: ]); // $jsonContent contains {"name":"Jane Doe"} +Preserving Empty Objetcs +~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, the Serializer will transform an empty array to `[]`. +You can change this behavior by setting the ``AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS`` context option +to ``true``, when the value is `\ArrayObject()` the serialization would be `{}`. + Handling Uninitialized Properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From e384239df47030f05c3547139678c37218400ab2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 14 Apr 2025 10:40:54 +0200 Subject: [PATCH 2452/2491] Tweaks --- serializer.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/serializer.rst b/serializer.rst index b7deb6f5bff..440494d0be1 100644 --- a/serializer.rst +++ b/serializer.rst @@ -1571,12 +1571,13 @@ to ``true``:: ]); // $jsonContent contains {"name":"Jane Doe"} -Preserving Empty Objetcs +Preserving Empty Objects ~~~~~~~~~~~~~~~~~~~~~~~~ -By default, the Serializer will transform an empty array to `[]`. -You can change this behavior by setting the ``AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS`` context option -to ``true``, when the value is `\ArrayObject()` the serialization would be `{}`. +By default, the Serializer transforms an empty array to ``[]``. You can change +this behavior by setting the ``AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS`` +context option to ``true``. When the value is an instance of ``\ArrayObject()``, +the serialized data will be ``{}``. Handling Uninitialized Properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 3a572358ae6cfafa90748178292a6e24c9ab9321 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 14 Apr 2025 10:59:37 +0200 Subject: [PATCH 2453/2491] Update the build script to mention that it does not support Windows --- _build/build.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_build/build.php b/_build/build.php index 454553d459e..b80d8e0e51e 100755 --- a/_build/build.php +++ b/_build/build.php @@ -15,6 +15,13 @@ ->addOption('generate-fjson-files', null, InputOption::VALUE_NONE, 'Use this option to generate docs both in HTML and JSON formats') ->addOption('disable-cache', null, InputOption::VALUE_NONE, 'Use this option to force a full regeneration of all doc contents') ->setCode(function(InputInterface $input, OutputInterface $output) { + // the doc building app doesn't work on Windows + if ('\\' === DIRECTORY_SEPARATOR) { + $output->writeln('ERROR: The application that builds Symfony Docs does not support Windows. You can try using a Linux distribution via WSL (Windows Subsystem for Linux).'); + + return 1; + } + $io = new SymfonyStyle($input, $output); $io->text('Building all Symfony Docs...'); From cb186580124e06ed65024404856642ffb29ab1f9 Mon Sep 17 00:00:00 2001 From: jdevinemt <65512359+jdevinemt@users.noreply.github.com> Date: Thu, 20 Mar 2025 17:07:39 -0600 Subject: [PATCH 2454/2491] [Deployment] - More accurate local .env file recommendation --- deployment.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deployment.rst b/deployment.rst index 864ebc7a963..87e88f10ff8 100644 --- a/deployment.rst +++ b/deployment.rst @@ -134,14 +134,13 @@ B) Configure your Environment Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Most Symfony applications read their configuration from environment variables. -While developing locally, you'll usually store these in ``.env`` and ``.env.local`` -(for local overrides). On production, you have two options: +While developing locally, you'll usually store these in :ref:`.env files `. On production, you have two options: 1. Create "real" environment variables. How you set environment variables, depends on your setup: they can be set at the command line, in your Nginx configuration, or via other methods provided by your hosting service; -2. Or, create a ``.env.local`` file like your local development. +2. Or, create a ``.env.prod.local`` file containing values specific to your production environment. There is no significant advantage to either of the two options: use whatever is most natural in your hosting environment. From 059ecfa24b88db20e962a8e6a4cee88244de65ec Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 14 Apr 2025 17:42:27 +0200 Subject: [PATCH 2455/2491] Minor tweaks --- deployment.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/deployment.rst b/deployment.rst index 87e88f10ff8..07187f53cba 100644 --- a/deployment.rst +++ b/deployment.rst @@ -134,16 +134,18 @@ B) Configure your Environment Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Most Symfony applications read their configuration from environment variables. -While developing locally, you'll usually store these in :ref:`.env files `. On production, you have two options: +While developing locally, you'll usually store these in :ref:`.env files `. +On production, you have two options: 1. Create "real" environment variables. How you set environment variables, depends on your setup: they can be set at the command line, in your Nginx configuration, or via other methods provided by your hosting service; -2. Or, create a ``.env.prod.local`` file containing values specific to your production environment. +2. Or, create a ``.env.prod.local`` file that contains values specific to your + production environment. -There is no significant advantage to either of the two options: use whatever is -most natural in your hosting environment. +There is no significant advantage to either option: use whichever is most natural +for your hosting environment. .. tip:: From 0ce5ffbbbd24e0230e7ec527b372958e0cb53e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 14 Apr 2025 17:23:22 +0200 Subject: [PATCH 2456/2491] [HttpFoundation] Add FrankenPHP docs for X-Sendfile --- components/http_foundation.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 9a4f0b61516..5a0c24ef618 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -854,7 +854,7 @@ Alternatively, if you are serving a static file, you can use a The ``BinaryFileResponse`` will automatically handle ``Range`` and ``If-Range`` headers from the request. It also supports ``X-Sendfile`` -(see for `nginx`_ and `Apache`_). To make use of it, you need to determine +(see for `FrankenPHP`_, `nginx`_ and `Apache`_). To make use of it, you need to determine whether or not the ``X-Sendfile-Type`` header should be trusted and call :method:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse::trustXSendfileTypeHeader` if it should:: @@ -1061,6 +1061,7 @@ Learn More /session /http_cache/* +.. _FrankenPHP: https://frankenphp.dev/docs/x-sendfile/ .. _nginx: https://mattbrictson.com/blog/accelerated-rails-downloads .. _Apache: https://tn123.org/mod_xsendfile/ .. _`JSON Hijacking`: https://haacked.com/archive/2009/06/25/json-hijacking.aspx/ From afc84e2242147e1c7137a4d380b9e0736d86626c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 14 Apr 2025 17:58:24 +0200 Subject: [PATCH 2457/2491] Update the links related to X-Sendfile and X-Accel-Redirect --- components/http_foundation.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 5a0c24ef618..14843bab346 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -854,9 +854,10 @@ Alternatively, if you are serving a static file, you can use a The ``BinaryFileResponse`` will automatically handle ``Range`` and ``If-Range`` headers from the request. It also supports ``X-Sendfile`` -(see for `FrankenPHP`_, `nginx`_ and `Apache`_). To make use of it, you need to determine -whether or not the ``X-Sendfile-Type`` header should be trusted and call -:method:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse::trustXSendfileTypeHeader` +(see `FrankenPHP X-Sendfile and X-Accel-Redirect headers`_, +`nginx X-Accel-Redirect header`_ and `Apache mod_xsendfile module`_). To make use +of it, you need to determine whether or not the ``X-Sendfile-Type`` header should +be trusted and call :method:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse::trustXSendfileTypeHeader` if it should:: BinaryFileResponse::trustXSendfileTypeHeader(); @@ -1061,9 +1062,9 @@ Learn More /session /http_cache/* -.. _FrankenPHP: https://frankenphp.dev/docs/x-sendfile/ -.. _nginx: https://mattbrictson.com/blog/accelerated-rails-downloads -.. _Apache: https://tn123.org/mod_xsendfile/ +.. _`FrankenPHP X-Sendfile and X-Accel-Redirect headers`: https://frankenphp.dev/docs/x-sendfile/ +.. _`nginx X-Accel-Redirect header`: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers +.. _`Apache mod_xsendfile module`: https://github.com/nmaier/mod_xsendfile .. _`JSON Hijacking`: https://haacked.com/archive/2009/06/25/json-hijacking.aspx/ .. _`valid JSON top-level value`: https://www.json.org/json-en.html .. _OWASP guidelines: https://cheatsheetseries.owasp.org/cheatsheets/AJAX_Security_Cheat_Sheet.html#always-return-json-with-an-object-on-the-outside From a8a4523bcdfd889b2f9afee9342a655a879e090c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 15 Apr 2025 17:18:46 +0200 Subject: [PATCH 2458/2491] Fix a syntax issue in Coding Standards --- contributing/code/standards.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 3a00343faf1..ebfde7dfab4 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -211,7 +211,7 @@ Naming Conventions * Use `camelCase`_ for PHP variables, function and method names, arguments (e.g. ``$acceptableContentTypes``, ``hasSession()``); -Use `snake_case`_ for configuration parameters, route names and Twig template +* Use `snake_case`_ for configuration parameters, route names and Twig template variables (e.g. ``framework.csrf_protection``, ``http_status_code``); * Use SCREAMING_SNAKE_CASE for constants (e.g. ``InputArgument::IS_ARRAY``); From 4f50290a46361fdf8907ecfa53beb8c6864330d8 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 15 Apr 2025 11:33:07 +0200 Subject: [PATCH 2459/2491] feat: swap from event constant to event class --- event_dispatcher.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 7372d58b8d0..b854488de52 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -246,14 +246,13 @@ methods could be called before or after the methods defined in other listeners and subscribers. To learn more about event subscribers, read :doc:`/components/event_dispatcher`. The following example shows an event subscriber that defines several methods which -listen to the same ``kernel.exception`` event:: +listen to the same ``kernel.exception`` event which has an ``ExceptionEvent``:: // src/EventSubscriber/ExceptionSubscriber.php namespace App\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\ExceptionEvent; - use Symfony\Component\HttpKernel\KernelEvents; class ExceptionSubscriber implements EventSubscriberInterface { @@ -261,7 +260,7 @@ listen to the same ``kernel.exception`` event:: { // return the subscribed events, their methods and priorities return [ - KernelEvents::EXCEPTION => [ + ExceptionEvent::class => [ ['processException', 10], ['logException', 0], ['notifyException', -10], From a6e0879c81c9009fcd376a144c0f97702b60213f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 15 Apr 2025 17:36:40 +0200 Subject: [PATCH 2460/2491] Minor tweak --- event_dispatcher.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index b854488de52..8e5c3d092e0 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -246,7 +246,8 @@ methods could be called before or after the methods defined in other listeners and subscribers. To learn more about event subscribers, read :doc:`/components/event_dispatcher`. The following example shows an event subscriber that defines several methods which -listen to the same ``kernel.exception`` event which has an ``ExceptionEvent``:: +listen to the same :ref:`kernel.exception event `_ +via its ``ExceptionEvent`` class:: // src/EventSubscriber/ExceptionSubscriber.php namespace App\EventSubscriber; From 90def249610950e1811cd70d5bc1a94caf09ad15 Mon Sep 17 00:00:00 2001 From: Ousmane NDIAYE Date: Tue, 15 Apr 2025 16:47:27 +0200 Subject: [PATCH 2461/2491] Update embedded.rst Comment added to specify the name of the fil to edit. (As previous examples) --- form/embedded.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/form/embedded.rst b/form/embedded.rst index dd163235f03..9e20164c3a4 100644 --- a/form/embedded.rst +++ b/form/embedded.rst @@ -87,6 +87,7 @@ inside the task form itself. To accomplish this, add a ``category`` field to the ``TaskType`` object whose type is an instance of the new ``CategoryType`` class:: + // src/Form/TaskType.php use App\Form\CategoryType; use Symfony\Component\Form\FormBuilderInterface; From 89ff8f3485003be9c8c2f774a7acb588f7d192aa Mon Sep 17 00:00:00 2001 From: Bastien Jaillot Date: Wed, 16 Apr 2025 12:20:24 +0200 Subject: [PATCH 2462/2491] Update routing.rst --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index 79a513ba8dd..f34205de98e 100644 --- a/routing.rst +++ b/routing.rst @@ -2715,7 +2715,7 @@ same URL, but with the HTTPS scheme. If you want to force a group of routes to use HTTPS, you can define the default scheme when importing them. The following example forces HTTPS on all routes -defined as annotations: +defined as attributes: .. configuration-block:: From 32aec360f5fce14a1f7b680b8e5695a36cbad263 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 16 Apr 2025 17:43:23 +0200 Subject: [PATCH 2463/2491] [EventDispatcher] Fix a minor syntax issue in a reference --- event_dispatcher.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 8e5c3d092e0..d9b913ed49f 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -246,7 +246,7 @@ methods could be called before or after the methods defined in other listeners and subscribers. To learn more about event subscribers, read :doc:`/components/event_dispatcher`. The following example shows an event subscriber that defines several methods which -listen to the same :ref:`kernel.exception event `_ +listen to the same :ref:`kernel.exception event ` via its ``ExceptionEvent`` class:: // src/EventSubscriber/ExceptionSubscriber.php From 7fc2bc7c4c2268e5f27acbc7954497a859c96a3a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 16 Apr 2025 16:22:47 +0200 Subject: [PATCH 2464/2491] [Console] Minor tweak in the article introduction --- console.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/console.rst b/console.rst index baab4aff4a7..82bafd4d640 100644 --- a/console.rst +++ b/console.rst @@ -18,14 +18,14 @@ the ``list`` command to view all available commands in the application: ... Available commands: - about Display information about the current project - completion Dump the shell completion script - help Display help for a command - list List commands + about Display information about the current project + completion Dump the shell completion script + help Display help for a command + list List commands assets - assets:install Install bundle's web assets under a public directory + assets:install Install bundle's web assets under a public directory cache - cache:clear Clear the cache + cache:clear Clear the cache ... .. note:: From c4cf202b2614a726be6694161b6eec7aba253588 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 17 Apr 2025 08:34:15 +0200 Subject: [PATCH 2465/2491] fix configuration block indentation --- service_container.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container.rst b/service_container.rst index 6ae601cf724..6086ae1d946 100644 --- a/service_container.rst +++ b/service_container.rst @@ -226,7 +226,7 @@ each time you ask for it. If some files or directories in your project should not become services, you can exclude them using the ``exclude`` option: - .. configuration-block:: + .. configuration-block:: .. code-block:: yaml From fa8f5b191bf11cd1c8e29f56fea743855d597e54 Mon Sep 17 00:00:00 2001 From: Alexander Hofbauer Date: Thu, 17 Apr 2025 09:15:22 +0200 Subject: [PATCH 2466/2491] [Mailer] Document email.image name parameter --- mailer.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mailer.rst b/mailer.rst index a6b5eb819d8..034f9bdfe97 100644 --- a/mailer.rst +++ b/mailer.rst @@ -1093,6 +1093,14 @@ the email contents:

Welcome {{ email.toName }}!

{# ... #} +By default this will create an attachment using the file path as filename: +``Content-Disposition: inline; name="cid..."; filename="@images/logo.png"``. +This behavior can be overridden by passing a name (the third argument): + +.. code-block:: html+twig + + My Logo + .. _mailer-inline-css: Inlining CSS Styles From 316c8ac333d822e1b5d68aa8bdbc25f8923c453c Mon Sep 17 00:00:00 2001 From: Pierre Ambroise Date: Thu, 17 Apr 2025 16:39:24 +0200 Subject: [PATCH 2467/2491] Add when argument to AsAlias --- service_container/alias_private.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst index f99f7cb5f3e..84632c1d89b 100644 --- a/service_container/alias_private.rst +++ b/service_container/alias_private.rst @@ -181,6 +181,27 @@ This means that when using the container directly, you can access the # ... app.mailer: '@App\Mail\PhpMailer' +The ``#[AsAlias]`` attribute also support per-environment configuration +via the ``when`` argument:: + + // src/Mail/PhpMailer.php + namespace App\Mail; + + // ... + use Symfony\Component\DependencyInjection\Attribute\AsAlias; + + #[AsAlias(id: 'app.mailer', when: 'dev')] + class PhpMailer + { + // ... + } + +You can pass either a string or an array of strings to the ``when`` argument. + +.. versionadded:: 7.3 + + The ``when`` argument on the ``#[AsAlias]`` attribute was introduced in Symfony 7.3. + .. tip:: When using ``#[AsAlias]`` attribute, you may omit passing ``id`` argument From 5482c8281ad9bf346362e06f7988e83dd4282c6a Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Thu, 17 Apr 2025 20:14:01 -0400 Subject: [PATCH 2468/2491] [Routing] add tip about using `symfony/clock` with `UriSigner` --- routing.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routing.rst b/routing.rst index a9ada1fc44b..0e1a46a505b 100644 --- a/routing.rst +++ b/routing.rst @@ -2815,6 +2815,16 @@ argument of :method:`Symfony\\Component\\HttpFoundation\\UriSigner::sign`:: Starting with Symfony 7.3, signed URI hashes no longer include the ``/`` or ``+`` characters, as these may cause issues with certain clients. +.. tip:: + + If ``symfony/clock`` is installed, it is used for creating and verifying the + expiration. This allows you to :ref:`mock the current time in your tests + `. + +.. versionadded:: 7.3 + + ``symfony/clock`` support was added to ``UriSigner`` in Symfony 7.3. + Troubleshooting --------------- From aa3b1674ea0202c0d3966ee82f04836fe33479ec Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Fri, 18 Apr 2025 19:34:27 -0400 Subject: [PATCH 2469/2491] [Routing] document `UriSigner::verify()` --- routing.rst | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/routing.rst b/routing.rst index a9ada1fc44b..19c2ae1a5a6 100644 --- a/routing.rst +++ b/routing.rst @@ -2810,10 +2810,30 @@ argument of :method:`Symfony\\Component\\HttpFoundation\\UriSigner::sign`:: The feature to add an expiration date for a signed URI was introduced in Symfony 7.1. +If you need to know the reason why a signed URI is invalid, you can use the +``verify()`` method which throws exceptions on failure:: + + use Symfony\Component\HttpFoundation\Exception\ExpiredSignedUriException; + use Symfony\Component\HttpFoundation\Exception\UnsignedUriException; + use Symfony\Component\HttpFoundation\Exception\UnverifiedSignedUriException; + + // ... + + try { + $uriSigner->verify($uri); // $uri can be a string or Request object + + // the URI is valid + } catch (UnsignedUriException) { + // the URI isn't signed + } catch (UnverifiedSignedUriException) { + // the URI is signed but the signature is invalid + } catch (ExpiredSignedUriException) { + // the URI is signed but expired + } + .. versionadded:: 7.3 - Starting with Symfony 7.3, signed URI hashes no longer include the ``/`` or - ``+`` characters, as these may cause issues with certain clients. + The ``verify()`` method was introduced in Symfony 7.3. Troubleshooting --------------- From e7613b0e2af243005b9fb66c9d696f74005a645a Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sat, 19 Apr 2025 19:03:15 +0200 Subject: [PATCH 2470/2491] [Validator] Add filenameCharset and filenameCountUnit options to File constraint --- reference/constraints/File.rst | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 495c19f9cbe..62efa6cc08e 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -274,6 +274,31 @@ You can find a list of existing mime types on the `IANA website`_. If set, the validator will check that the filename of the underlying file doesn't exceed a certain length. +``filenameCountUnit`` +~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``File::FILENAME_COUNT_BYTES`` + +The character count unit to use for the filename max length check. +By default :phpfunction:`strlen` is used, which counts the length of the string in bytes. + +Can be one of the following constants of the +:class:`Symfony\\Component\\Validator\\Constraints\\File` class: + +* ``FILENAME_COUNT_BYTES``: Uses :phpfunction:`strlen` counting the length of the + string in bytes. +* ``FILENAME_COUNT_CODEPOINTS``: Uses :phpfunction:`mb_strlen` counting the length + of the string in Unicode code points. Simple (multibyte) Unicode characters count + as 1 character, while for example ZWJ sequences of composed emojis count as + multiple characters. +* ``FILENAME_COUNT_GRAPHEMES``: Uses :phpfunction:`grapheme_strlen` counting the + length of the string in graphemes, i.e. even emojis and ZWJ sequences of composed + emojis count as 1 character. + +.. versionadded:: 7.3 + + The ``filenameCountUnit`` option was introduced in Symfony 7.3. + ``filenameTooLongMessage`` ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -290,6 +315,35 @@ Parameter Description ``{{ filename_max_length }}`` Maximum number of characters allowed ============================== ============================================================== +``filenameCharset`` +~~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``null`` + +The charset to be used when computing value's filename max length with the +:phpfunction:`mb_check_encoding` and :phpfunction:`mb_strlen` +PHP functions. + +``filenameCharsetMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``This filename does not match the expected charset.`` + +The message that will be shown if the value is not using the given `filenameCharsetMessage`_. + +You can use the following parameters in this message: + +================= ============================================================ +Parameter Description +================= ============================================================ +``{{ charset }}`` The expected charset +``{{ name }}`` The current (invalid) value +================= ============================================================ + +.. versionadded:: 7.3 + + The ``filenameCharset`` and ``filenameCharsetMessage`` options were introduced in Symfony 7.3. + ``extensionsMessage`` ~~~~~~~~~~~~~~~~~~~~~ From 76c4720d47de37c43d0a87cc1c61fe8d1216605c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Apr 2025 17:17:11 +0200 Subject: [PATCH 2471/2491] Minor tweaks --- service_container/alias_private.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst index 84632c1d89b..22bf649d861 100644 --- a/service_container/alias_private.rst +++ b/service_container/alias_private.rst @@ -181,8 +181,8 @@ This means that when using the container directly, you can access the # ... app.mailer: '@App\Mail\PhpMailer' -The ``#[AsAlias]`` attribute also support per-environment configuration -via the ``when`` argument:: +The ``#[AsAlias]`` attribute can also be limited to one or more specific +:ref:`config environments ` using the ``when`` argument:: // src/Mail/PhpMailer.php namespace App\Mail; @@ -196,11 +196,16 @@ via the ``when`` argument:: // ... } -You can pass either a string or an array of strings to the ``when`` argument. + // pass an array to apply it in multiple config environments + #[AsAlias(id: 'app.mailer', when: ['dev', 'test'])] + class PhpMailer + { + // ... + } .. versionadded:: 7.3 - The ``when`` argument on the ``#[AsAlias]`` attribute was introduced in Symfony 7.3. + The ``when`` argument of the ``#[AsAlias]`` attribute was introduced in Symfony 7.3. .. tip:: From 6350e2ea71430fa106bd7873a4c384153fab134e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Apr 2025 17:49:02 +0200 Subject: [PATCH 2472/2491] Minor tweaks --- routing.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/routing.rst b/routing.rst index 672f331291b..663e8518504 100644 --- a/routing.rst +++ b/routing.rst @@ -2837,13 +2837,14 @@ If you need to know the reason why a signed URI is invalid, you can use the .. tip:: - If ``symfony/clock`` is installed, it is used for creating and verifying the - expiration. This allows you to :ref:`mock the current time in your tests + If ``symfony/clock`` is installed, it will be used to create and verify + expirations. This allows you to :ref:`mock the current time in your tests `. .. versionadded:: 7.3 - ``symfony/clock`` support was added to ``UriSigner`` in Symfony 7.3. + Support for :doc:`Symfony Clock ` in ``UriSigner`` was + introduced in Symfony 7.3. Troubleshooting --------------- From a5308819ac679da412d48acbb3d45f245b23f1e3 Mon Sep 17 00:00:00 2001 From: aurac Date: Wed, 23 Apr 2025 19:38:45 +0200 Subject: [PATCH 2473/2491] fix(doctrine): default configuration --- reference/configuration/doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 8a1062a54ae..46877e9f84c 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -176,7 +176,7 @@ that the ORM resolves to: doctrine: orm: - auto_mapping: true + auto_mapping: false # the standard distribution overrides this to be true in debug, false otherwise auto_generate_proxy_classes: false proxy_namespace: Proxies From 3abba12e6fe84c031dcae54569f35e8225775b76 Mon Sep 17 00:00:00 2001 From: Hmache Abdellah <11814824+Hmache@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:31:32 +0200 Subject: [PATCH 2474/2491] [uid] Fix Uuid::v8() usage example to show it requires a UUID string This update corrects the usage example of Uuid::v8() to prevent misuse and confusion --- components/uid.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/uid.rst b/components/uid.rst index b286329151d..2fa04251f90 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -140,7 +140,7 @@ of the UUID value is specific to each implementation and no format should be ass use Symfony\Component\Uid\Uuid; // $uuid is an instance of Symfony\Component\Uid\UuidV8 - $uuid = Uuid::v8(); + $uuid = Uuid::v8('d9e7a184-5d5b-11ea-a62a-3499710062d0'); .. versionadded:: 6.2 From 4464d375341f6d333fff2dd91e2b48aeb3589591 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 24 Apr 2025 08:57:36 +0200 Subject: [PATCH 2475/2491] Tweaks --- components/uid.rst | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index 2fa04251f90..b031348f85a 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -32,13 +32,13 @@ to create each type of UUID: **UUID v1** (time-based) Generates the UUID using a timestamp and the MAC address of your device -(`read UUIDv1 spec `__). +(`read the UUIDv1 spec `__). Both are obtained automatically, so you don't have to pass any constructor argument:: use Symfony\Component\Uid\Uuid; - // $uuid is an instance of Symfony\Component\Uid\UuidV1 $uuid = Uuid::v1(); + // $uuid is an instance of Symfony\Component\Uid\UuidV1 .. tip:: @@ -48,7 +48,7 @@ Both are obtained automatically, so you don't have to pass any constructor argum **UUID v2** (DCE security) Similar to UUIDv1 but with a very high likelihood of ID collision -(`read UUIDv2 spec `__). +(`read the UUIDv2 spec `__). It's part of the authentication mechanism of DCE (Distributed Computing Environment) and the UUID includes the POSIX UIDs (user/group ID) of the user who generated it. This UUID variant is **not implemented** by the Uid component. @@ -56,7 +56,7 @@ This UUID variant is **not implemented** by the Uid component. **UUID v3** (name-based, MD5) Generates UUIDs from names that belong, and are unique within, some given namespace -(`read UUIDv3 spec `__). +(`read the UUIDv3 spec `__). This variant is useful to generate deterministic UUIDs from arbitrary strings. It works by populating the UUID contents with the``md5`` hash of concatenating the namespace and the name:: @@ -69,8 +69,8 @@ the namespace and the name:: // $namespace = Uuid::v4(); // $name can be any arbitrary string - // $uuid is an instance of Symfony\Component\Uid\UuidV3 $uuid = Uuid::v3($namespace, $name); + // $uuid is an instance of Symfony\Component\Uid\UuidV3 These are the default namespaces defined by the standard: @@ -81,20 +81,20 @@ These are the default namespaces defined by the standard: **UUID v4** (random) -Generates a random UUID (`read UUIDv4 spec `__). +Generates a random UUID (`read the UUIDv4 spec `__). Because of its randomness, it ensures uniqueness across distributed systems without the need for a central coordinating entity. It's privacy-friendly because it doesn't contain any information about where and when it was generated:: use Symfony\Component\Uid\Uuid; - // $uuid is an instance of Symfony\Component\Uid\UuidV4 $uuid = Uuid::v4(); + // $uuid is an instance of Symfony\Component\Uid\UuidV4 **UUID v5** (name-based, SHA-1) It's the same as UUIDv3 (explained above) but it uses ``sha1`` instead of -``md5`` to hash the given namespace and name (`read UUIDv5 spec `__). +``md5`` to hash the given namespace and name (`read the UUIDv5 spec `__). This makes it more secure and less prone to hash collisions. .. _uid-uuid-v6: @@ -103,12 +103,12 @@ This makes it more secure and less prone to hash collisions. It rearranges the time-based fields of the UUIDv1 to make it lexicographically sortable (like :ref:`ULIDs `). It's more efficient for database indexing -(`read UUIDv6 spec `__):: +(`read the UUIDv6 spec `__):: use Symfony\Component\Uid\Uuid; - // $uuid is an instance of Symfony\Component\Uid\UuidV6 $uuid = Uuid::v6(); + // $uuid is an instance of Symfony\Component\Uid\UuidV6 .. tip:: @@ -121,26 +121,28 @@ sortable (like :ref:`ULIDs `). It's more efficient for database indexing Generates time-ordered UUIDs based on a high-resolution Unix Epoch timestamp source (the number of milliseconds since midnight 1 Jan 1970 UTC, leap seconds excluded) -(`read UUIDv7 spec `__). +(`read the UUIDv7 spec `__). It's recommended to use this version over UUIDv1 and UUIDv6 because it provides better entropy (and a more strict chronological order of UUID generation):: use Symfony\Component\Uid\Uuid; - // $uuid is an instance of Symfony\Component\Uid\UuidV7 $uuid = Uuid::v7(); + // $uuid is an instance of Symfony\Component\Uid\UuidV7 **UUID v8** (custom) -Provides an RFC-compatible format for experimental or vendor-specific use cases -(`read UUIDv8 spec `__). -The only requirement is to set the variant and version bits of the UUID. The rest -of the UUID value is specific to each implementation and no format should be assumed:: +Provides an RFC-compatible format intended for experimental or vendor-specific use cases +(`read the UUIDv8 spec `__). +You must generate the UUID value yourself. The only requirement is to set the +variant and version bits of the UUID correctly. The rest of the UUID content is +implementation-specific, and no particular format should be assumed:: use Symfony\Component\Uid\Uuid; - // $uuid is an instance of Symfony\Component\Uid\UuidV8 + // pass your custom UUID value as the argument $uuid = Uuid::v8('d9e7a184-5d5b-11ea-a62a-3499710062d0'); + // $uuid is an instance of Symfony\Component\Uid\UuidV8 .. versionadded:: 6.2 From d8ac2923438cd19b28bc3a51577e5b505102eb64 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 24 Apr 2025 09:24:02 +0200 Subject: [PATCH 2476/2491] fix path to Panther web server router file The path is used as an argument for the `php` binary which treats it relative to the document root directory that is passed with the `-t` option (in a typical Symfony application the document root directory is `public` which is located in the same parent directory as the `tests` directory). --- testing/end_to_end.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/end_to_end.rst b/testing/end_to_end.rst index 83d61b1e60f..80e970bd2cd 100644 --- a/testing/end_to_end.rst +++ b/testing/end_to_end.rst @@ -878,7 +878,7 @@ Then declare it as a router for Panther server in ``phpunit.xml.dist`` using the - + From 9f7cc9d5d899a2afc46ca1be67f2242a21326168 Mon Sep 17 00:00:00 2001 From: Arnaud Thibaudet Date: Thu, 24 Apr 2025 10:17:29 +0200 Subject: [PATCH 2477/2491] Fix typo on parameter name Signed-off-by: Arnaud Thibaudet --- translation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translation.rst b/translation.rst index 86282090801..23949b7e67f 100644 --- a/translation.rst +++ b/translation.rst @@ -487,11 +487,11 @@ your application: .. code-block:: twig - {{ 'Application version: {version}'|trans }} + {{ 'Application version: {app_version}'|trans }} {# output: "Application version: 1.2.3" #} {# parameters passed to the message override global parameters #} - {{ 'Package version: {version}'|trans({'{version}': '2.3.4'}) }} + {{ 'Package version: {app_version}'|trans({'{app_version}': '2.3.4'}) }} # Displays "Package version: 2.3.4" Forcing the Translator Locale From ce4cd4db8dc7154a63c9951f5a276b11f93cc29e Mon Sep 17 00:00:00 2001 From: Jorick Pepin Date: Thu, 24 Apr 2025 17:11:47 +0200 Subject: [PATCH 2478/2491] [BrowserKit] Fix `submitForm` behaviour --- components/browser_kit.rst | 2 +- testing.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index c744837d7b1..21ceaf5a095 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -147,7 +147,7 @@ field values, etc.) before submitting it:: $crawler = $client->request('GET', 'https://github.com/login'); // find the form with the 'Log in' button and submit it - // 'Log in' can be the text content, id, value or name of a