diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index 4d70d45feb2..2d698b77c20 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -40,18 +40,18 @@ rules: extend_abstract_controller: ~ # no_app_bundle: ~ - # 4.x + # master versionadded_directive_major_version: - major_version: 4 + major_version: 5 versionadded_directive_min_version: - min_version: '4.0' + min_version: '5.0' deprecated_directive_major_version: - major_version: 4 + major_version: 5 deprecated_directive_min_version: - min_version: '4.0' + min_version: '5.0' # do not report as violation whitelist: @@ -78,7 +78,10 @@ whitelist: - '.. versionadded:: 1.6' # Flex in setup/upgrade_minor.rst - '0 => 123' # assertion for var_dumper - components/var_dumper.rst - '1 => "foo"' # assertion for var_dumper - components/var_dumper.rst + - '123,' # assertion for var_dumper - components/var_dumper.rst + - '"foo",' # assertion for var_dumper - components/var_dumper.rst - '$var .= "Because of this `\xE9` octet (\\xE9),\n";' - "`Deploying Symfony 4 Apps on Heroku`_." - ".. _`Deploying Symfony 4 Apps on Heroku`: https://devcenter.heroku.com/articles/deploying-symfony4" + - "// 224, 165, 141, 224, 164, 164, 224, 165, 135])" - '.. versionadded:: 0.2' # MercureBundle diff --git a/_build/redirection_map b/_build/redirection_map index 8114a00ebbf..5d44f67b39d 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -429,6 +429,7 @@ /profiler/storage /profiler /setup/composer /setup /security/security_checker /setup +/setup/built_in_web_server /setup/symfony_server /service_container/parameters /configuration /routing/generate_url_javascript /routing /routing/slash_in_parameter /routing diff --git a/_images/components/string/bytes-points-graphemes.png b/_images/components/string/bytes-points-graphemes.png new file mode 100644 index 00000000000..18d971cecf7 Binary files /dev/null and b/_images/components/string/bytes-points-graphemes.png differ diff --git a/bundles/configuration.rst b/bundles/configuration.rst index 3f573e5eab1..9da8c884370 100644 --- a/bundles/configuration.rst +++ b/bundles/configuration.rst @@ -199,10 +199,6 @@ The ``Configuration`` class to handle the sample configuration looks like:: } } -.. deprecated:: 4.2 - - Not passing the root node name to ``TreeBuilder`` was deprecated in Symfony 4.2. - .. seealso:: The ``Configuration`` class can be much more complicated than shown here, diff --git a/cache.rst b/cache.rst index 21bea9e120c..6301cffcd39 100644 --- a/cache.rst +++ b/cache.rst @@ -30,10 +30,6 @@ The following example shows a typical usage of the cache:: Symfony supports the Cache Contracts, PSR-6/16 and Doctrine Cache interfaces. You can read more about these at the :doc:`component documentation `. -.. versionadded:: 4.2 - - The cache contracts were introduced in Symfony 4.2. - .. _cache-configuration-with-frameworkbundle: Configuring Cache with FrameworkBundle @@ -390,10 +386,6 @@ If an error happens when storing an item in a pool, Symfony stores it in the other pools and no exception is thrown. Later, when the item is retrieved, Symfony stores the item automatically in all the missing pools. -.. versionadded:: 4.4 - - Support for configuring a chain using ``framework.cache.pools`` was introduced in Symfony 4.4. - .. configuration-block:: .. code-block:: yaml @@ -614,10 +606,6 @@ To see all available cache pools: $ php bin/console cache:pool:list -.. versionadded:: 4.3 - - The ``cache:pool:list`` command was introduced in Symfony 4.3. - Clear one pool: .. code-block:: terminal diff --git a/components/browser_kit.rst b/components/browser_kit.rst index 8108bf8f816..bfeab500f46 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -312,10 +312,6 @@ dedicated web crawler or scraper such as `Goutte`_:: '.table-list-header-toggle a:nth-child(1)' )->text()); -.. versionadded:: 4.3 - - The feature to make external HTTP requests was introduced in Symfony 4.3. - Learn more ---------- diff --git a/components/cache/adapters/memcached_adapter.rst b/components/cache/adapters/memcached_adapter.rst index 69d7afa48be..6ebbe93d36d 100644 --- a/components/cache/adapters/memcached_adapter.rst +++ b/components/cache/adapters/memcached_adapter.rst @@ -70,10 +70,6 @@ helper method allows creating and configuring a `Memcached`_ class instance usin 'memcached:?host[localhost]&host[localhost:12345]&host[/some/memcached.sock:]=3' ); -.. versionadded:: 4.2 - - The option to define multiple servers in a single DSN was introduced in Symfony 4.2. - The `Data Source Name (DSN)`_ for this adapter must use the following format: .. code-block:: text diff --git a/components/cache/adapters/redis_adapter.rst b/components/cache/adapters/redis_adapter.rst index 53b28c58466..1cbccc4d749 100644 --- a/components/cache/adapters/redis_adapter.rst +++ b/components/cache/adapters/redis_adapter.rst @@ -102,14 +102,6 @@ name of your service group:: 'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster' ); -.. versionadded:: 4.2 - - The option to define multiple servers in a single DSN was introduced in Symfony 4.2. - -.. versionadded:: 4.4 - - Redis Sentinel support was introduced in Symfony 4.4. - .. note:: See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options diff --git a/components/cache/psr6_psr16_adapters.rst b/components/cache/psr6_psr16_adapters.rst index 3c1e683b278..275de9f1a57 100644 --- a/components/cache/psr6_psr16_adapters.rst +++ b/components/cache/psr6_psr16_adapters.rst @@ -46,10 +46,6 @@ this use-case:: // now use this wherever you want $githubApiClient = new GitHubApiClient($psr6Cache); -.. versionadded:: 4.3 - - The ``Psr16Adapter`` class was introduced in Symfony 4.3. - Using a PSR-6 Cache Object as a PSR-16 Cache -------------------------------------------- @@ -87,8 +83,4 @@ this use-case:: // now use this wherever you want $githubApiClient = new GitHubApiClient($psr16Cache); -.. versionadded:: 4.3 - - The ``Psr16Cache`` class was introduced in Symfony 4.3. - .. _`PSR-16`: http://www.php-fig.org/psr/psr-16/ diff --git a/components/config/definition.rst b/components/config/definition.rst index 6cc72276e7c..ba668cd8613 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -68,10 +68,6 @@ implements the :class:`Symfony\\Component\\Config\\Definition\\ConfigurationInte } } -.. deprecated:: 4.2 - - Not passing the root node name to ``TreeBuilder`` was deprecated in Symfony 4.2. - Adding Node Definitions to the Tree ----------------------------------- diff --git a/components/console/helpers/progressbar.rst b/components/console/helpers/progressbar.rst index 27476fa0964..e592191f230 100644 --- a/components/console/helpers/progressbar.rst +++ b/components/console/helpers/progressbar.rst @@ -56,11 +56,6 @@ you can also set the current progress by calling the to redraw every N iterations. By default, redraw frequency is **100ms** or **10%** of your ``max``. - .. versionadded:: 4.4 - - The ``minSecondsBetweenRedraws()`` and ``maxSecondsBetweenRedraws()`` - methods were introduced in Symfony 4.4. - If you don't know the exact number of steps in advance, set it to a reasonable value and then call the ``setMaxSteps()`` method to update it as needed:: @@ -124,10 +119,6 @@ If ``$iterable = [1, 2]``, the previous code will output the following: 1/2 [==============>-------------] 50% 2/2 [============================] 100% -.. versionadded:: 4.3 - - The ``iterate()`` method was introduced in Symfony 4.3. - Customizing the Progress Bar ---------------------------- @@ -316,11 +307,6 @@ to display it can be customized:: $progressBar->advance(); } - .. versionadded:: 4.4 - - The ``minSecondsBetweenRedraws`` and ``maxSecondsBetweenRedraws()`` methods - were introduced in Symfony 4.4. - Custom Placeholders ~~~~~~~~~~~~~~~~~~~ diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 2869b82560b..73300db25c9 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -214,10 +214,6 @@ provide a callback function to dynamically generate suggestions:: $filePath = $helper->ask($input, $output, $question); } -.. versionadded:: 4.3 - - The ``setAutocompleterCallback()`` method was introduced in Symfony 4.3. - Do not Trim the Answer ~~~~~~~~~~~~~~~~~~~~~~ @@ -238,10 +234,6 @@ You can also specify if you want to not trim the answer by setting it directly w $name = $helper->ask($input, $output, $question); } -.. versionadded:: 4.4 - - The ``setTrimmable()`` method was introduced in Symfony 4.4. - Hiding the User's Response ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/console/single_command_tool.rst b/components/console/single_command_tool.rst index 457efb48dae..500d679d1e1 100644 --- a/components/console/single_command_tool.rst +++ b/components/console/single_command_tool.rst @@ -5,34 +5,36 @@ 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. Fortunately, -it is possible to remove this need by declaring a single command application:: +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:: #!/usr/bin/env php register('echo') - ->addArgument('foo', InputArgument::OPTIONAL, 'The directory') - ->addOption('bar', null, InputOption::VALUE_REQUIRED) - ->setCode(function(InputInterface $input, OutputInterface $output) { - // output arguments and options - }) - ->getApplication() - ->setDefaultCommand('echo', true) // Single command application + use Symfony\Component\Console\SingleCommandApplication; + + (new SingleCommandApplication()) + ->setName('My Super Command') // Optional + ->setVersion('1.0.0') // Optional + ->addArgument('foo', InputArgument::OPTIONAL, 'The directory') + ->addOption('bar', null, InputOption::VALUE_REQUIRED) + ->setCode(function (InputInterface $input, OutputInterface $output) { + // output arguments and options + }) ->run(); -The :method:`Symfony\\Component\\Console\\Application::setDefaultCommand` method -accepts a boolean as second parameter. If true, the command ``echo`` will then -always be used, without having to pass its name. - You can still register a command as usual:: #!/usr/bin/env php @@ -49,3 +51,7 @@ You can still register a command as usual:: $application->setDefaultCommand($command->getName(), true); $application->run(); + +The :method:`Symfony\\Component\\Console\\Application::setDefaultCommand` method +accepts a boolean as second parameter. If true, the command ``echo`` will then +always be used, without having to pass its name. diff --git a/components/css_selector.rst b/components/css_selector.rst index 8bed3daa4db..e4a792a807c 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -98,10 +98,6 @@ Pseudo-classes are partially supported: ``li:first-of-type``) but not with the ``*`` selector). * Supported: ``*:only-of-type``. -.. versionadded:: 4.4 - - The support for ``*:only-of-type`` was introduced in Symfony 4.4. - Learn more ---------- diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 0460197b4af..8bc6a093fc8 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -77,10 +77,6 @@ tree. The DomCrawler component will use it automatically when the content has an HTML5 doctype. - .. versionadded:: 4.3 - - The automatic support of the html5-php library was introduced in Symfony 4.3. - Node Filtering ~~~~~~~~~~~~~~ @@ -169,10 +165,6 @@ Verify if the current node matches a selector:: $crawler->matches('p.lorem'); -.. versionadded:: 4.4 - - The ``matches()`` method was introduced in Symfony 4.4. - Node Traversing ~~~~~~~~~~~~~~~ @@ -207,10 +199,6 @@ Get the first parent (heading toward the document root) of the element that matc $crawler->closest('p.lorem'); -.. versionadded:: 4.4 - - The ``closest()`` method was introduced in Symfony 4.4. - .. note:: All the traversal methods return a new :class:`Symfony\\Component\\DomCrawler\\Crawler` @@ -236,14 +224,6 @@ Access the value of the first node of the current selection:: // the internal ones (e.g. " foo\n bar baz \n " is returned as "foo bar baz") $crawler->filterXPath('//body/p')->text('Default text content', true); -.. versionadded:: 4.3 - - The default argument of ``text()`` was introduced in Symfony 4.3. - -.. versionadded:: 4.4 - - The option to trim white spaces in ``text()`` was introduced in Symfony 4.4. - Access the attribute value of the first node of the current selection:: $class = $crawler->filterXPath('//body/p')->attr('class'); @@ -260,10 +240,6 @@ Extract attribute and/or node values from the list of nodes:: Special attribute ``_text`` represents a node value, while ``_name`` represents the element name (the HTML tag name). - .. versionadded:: 4.3 - - The special attribute ``_name`` was introduced in Symfony 4.3. - Call an anonymous function on each node of the list:: use Symfony\Component\DomCrawler\Crawler; @@ -357,19 +333,11 @@ and :phpclass:`DOMNode` objects:: // avoid the exception passing an argument that html() returns when node does not exist $html = $crawler->html('Default HTML content'); - .. versionadded:: 4.3 - - The default argument of ``html()`` was introduced in Symfony 4.3. - Or you can get the outer HTML of the first node using :method:`Symfony\\Component\\DomCrawler\\Crawler::outerHtml`:: $html = $crawler->outerHtml(); - .. versionadded:: 4.4 - - The ``outerHtml()`` method was introduced in Symfony 4.4. - Expression Evaluation ~~~~~~~~~~~~~~~~~~~~~ @@ -521,10 +489,6 @@ useful methods for working with forms:: $method = $form->getMethod(); $name = $form->getName(); -.. versionadded:: 4.4 - - The ``getName()`` method was introduced in Symfony 4.4. - The :method:`Symfony\\Component\\DomCrawler\\Form::getUri` method does more than just return the ``action`` attribute of the form. If the form method is GET, then it mimics the browser's behavior and returns the ``action`` diff --git a/components/dotenv.rst b/components/dotenv.rst index 9d605764c25..882a44debb1 100644 --- a/components/dotenv.rst +++ b/components/dotenv.rst @@ -104,10 +104,6 @@ You can adjust the variable defining the environment, default environment and te environments by passing them as additional arguments to ``Dotenv::loadEnv()`` (see :method:`Symfony\\Component\\Dotenv\\Dotenv::loadEnv` for details). -.. versionadded:: 4.2 - - The ``Dotenv::loadEnv()`` method was introduced in Symfony 4.2. - You should never store a ``.env.local`` file in your code repository as it might contain sensitive information; create a ``.env`` file (or multiple environment-specific ones as shown above) with sensible defaults instead. @@ -156,10 +152,6 @@ Define a default value in case the environment variable is not set: DB_USER= DB_PASS=${DB_USER:-root}pass # results in DB_PASS=rootpass -.. versionadded:: 4.4 - - The support for default values has been introduced in Symfony 4.4. - Embed commands via ``$()`` (not supported on Windows): .. code-block:: terminal diff --git a/components/event_dispatcher/traceable_dispatcher.rst b/components/event_dispatcher/traceable_dispatcher.rst index 87d58023445..33a98a2336b 100644 --- a/components/event_dispatcher/traceable_dispatcher.rst +++ b/components/event_dispatcher/traceable_dispatcher.rst @@ -41,10 +41,10 @@ to register event listeners and dispatch events:: $traceableEventDispatcher->dispatch($event, 'event.the_name'); After your application has been processed, you can use the -:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcherInterface::getCalledListeners` +:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher::getCalledListeners` method to retrieve an array of event listeners that have been called in your application. Similarly, the -:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcherInterface::getNotCalledListeners` +:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher::getNotCalledListeners` method returns an array of event listeners that have not been called:: // ... diff --git a/components/expression_language/syntax.rst b/components/expression_language/syntax.rst index 5b7ee72ec7a..045451491f5 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -21,10 +21,6 @@ The component supports: * **null** - ``null`` * **exponential** - also known as scientific (e.g. ``1.99E+3`` or ``1e-2``) - .. versionadded:: 4.4 - - The ``exponential`` literal was introduced in Symfony 4.4. - .. caution:: A backslash (``\``) must be escaped by 4 backslashes (``\\\\``) in a string diff --git a/components/filesystem.rst b/components/filesystem.rst index 21881a307d3..62235ebdc6d 100644 --- a/components/filesystem.rst +++ b/components/filesystem.rst @@ -286,6 +286,12 @@ exception on failure:: // returns a path like : /tmp/prefix_wyjgtF $filesystem->tempnam('/tmp', 'prefix_'); + // returns a path like : /tmp/prefix_wyjgtF.png + $filesystem->tempnam('/tmp', 'prefix_', '.png'); + +.. versionadded:: 4.4 + + The option to set a suffix in ``tempnam()`` was introduced in Symfony 4.4. ``dumpFile`` ~~~~~~~~~~~~ diff --git a/components/finder.rst b/components/finder.rst index 1bcf51b02d0..bb4559ee749 100644 --- a/components/finder.rst +++ b/components/finder.rst @@ -148,10 +148,6 @@ rules to exclude files and directories from the results with the // excludes files/directories matching the .gitignore patterns $finder->ignoreVCSIgnored(true); -.. versionadded:: 4.3 - - The ``ignoreVCSIgnored()`` method was introduced in Symfony 4.3. - File Name ~~~~~~~~~ @@ -248,11 +244,6 @@ Multiple paths can be excluded by chaining calls or passing an array:: // same as above $finder->notPath(['first/dir', 'other/dir']); -.. versionadded:: 4.2 - - Support for passing arrays to ``notPath()`` was introduced in Symfony - 4.2 - File Size ~~~~~~~~~ diff --git a/components/http_client.rst b/components/http_client.rst index 1217c6f8606..e0bf92b934c 100644 --- a/components/http_client.rst +++ b/components/http_client.rst @@ -9,10 +9,6 @@ The HttpClient Component PHP stream wrappers and cURL. It provides utilities to consume APIs and supports synchronous and asynchronous operations. -.. versionadded:: 4.3 - - The HttpClient component was introduced in Symfony 4.3. - Installation ------------ @@ -157,10 +153,6 @@ each request (which overrides any global authentication):: By using ``HttpClient::createForBaseUri()``, we ensure that the auth credentials won't be sent to any other hosts than https://example.com/. -.. versionadded:: 4.4 - - The ``auth_ntlm`` option and the ``HttpClient::createForBaseUri()`` method were introduced in Symfony 4.4. - Query String Parameters ~~~~~~~~~~~~~~~~~~~~~~~ @@ -361,10 +353,6 @@ following methods:: // returns detailed logs about the requests and responses of the HTTP transaction $httpLogs = $response->getInfo('debug'); -.. versionadded:: 4.4 - - The ``toStream()`` method was introduced in Symfony 4.4. - .. note:: ``$response->getInfo()`` is non-blocking: it returns *live* information @@ -427,10 +415,6 @@ and will abort the request. In case the response was canceled using ``$response->cancel()``, ``$response->getInfo('canceled')`` will return ``true``. -.. versionadded:: 4.4 - - The possibility to get information about canceled or not was introduced in Symfony 4.4. - Handling Exceptions ~~~~~~~~~~~~~~~~~~~ @@ -751,17 +735,9 @@ Now you can make HTTP requests with the PSR-18 client as follows:: $content = json_decode($response->getBody()->getContents(), true); -.. versionadded:: 4.4 - - The PSR-17 factory methods of ``Psr18Client`` were introduced in Symfony 4.4. - HTTPlug ~~~~~~~ -.. versionadded:: 4.4 - - Support for HTTPlug was introduced in Symfony 4.4. - 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 @@ -850,10 +826,6 @@ Then you're ready to go:: Native PHP Streams ~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - Support for native PHP streams was introduced in Symfony 4.4. - Responses implementing :class:`Symfony\\Contracts\\HttpClient\\ResponseInterface` can be cast to native PHP streams with :method:`Symfony\\Component\\HttpClient\\Response\\StreamWrapper::createResource``. diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 204e6d452f8..0d63d643e08 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -319,10 +319,6 @@ are also supported:: Anonymizing IP Addresses ~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - The ``anonymize()`` method was introduced in Symfony 4.4. - An increasingly common need for applications to comply with user protection regulations is to anonymize IP addresses before logging and storing them for analysis purposes. Use the ``anonymize()`` method from the diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 8aab0d03f0c..7066cc0c641 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -530,18 +530,6 @@ object, which you can use to access the original exception via the method. A typical listener on this event will check for a certain type of exception and create an appropriate error ``Response``. -.. versionadded:: 4.4 - - The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable` and - :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setThrowable` methods - were introduced in Symfony 4.4. - -.. deprecated:: 4.4 - - The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException` and - :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setException` methods - are deprecated since Symfony 4.4. - For example, to generate a 404 page, you might throw a special type of exception and then add a listener on this event that looks for this exception and creates and returns a 404 ``Response``. In fact, the HttpKernel component @@ -627,19 +615,6 @@ kernel.terminate ``KernelEvents::TERMINATE`` :class:`Sym kernel.exception ``KernelEvents::EXCEPTION`` :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent` =========================== ====================================== ======================================================================== -.. deprecated:: 4.3 - - Since Symfony 4.3, most of the event classes were renamed. - The following old classes were deprecated: - - * `GetResponseEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent` - * `FilterControllerEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerEvent` - * `FilterControllerArgumentsEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerArgumentsEvent` - * `GetResponseForControllerResultEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ViewEvent` - * `FilterResponseEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ResponseEvent` - * `PostResponseEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\TerminateEvent` - * `GetResponseForExceptionEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent` - .. _http-kernel-working-example: A full Working Example diff --git a/components/intl.rst b/components/intl.rst index 04a1752fa49..81c72bfee08 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -118,14 +118,6 @@ You may convert codes between two-letter alpha2 and three-letter alpha3 codes:: $alpha2Code = Languages::getAlpha2Code($alpha3Code); -.. versionadded:: 4.3 - - The ``Languages`` class was introduced in Symfony 4.3. - -.. versionadded:: 4.4 - - The full support for alpha3 codes was introduced in Symfony 4.4. - The ``Scripts`` class provides access to the optional four-letter script code that can follow the language code according to the `Unicode ISO 15924 Registry`_ (e.g. ``HANS`` in ``zh_HANS`` for simplified Chinese and ``HANT`` in ``zh_HANT`` @@ -157,10 +149,6 @@ to catching the exception, you can also check if a given script code is valid:: $isValidScript = Scripts::exists($scriptCode); -.. versionadded:: 4.3 - - The ``Scripts`` class was introduced in Symfony 4.3. - Country Names ~~~~~~~~~~~~~ @@ -217,14 +205,6 @@ You may convert codes between two-letter alpha2 and three-letter alpha3 codes:: $alpha2Code = Countries::getAlpha2Code($alpha3Code); -.. versionadded:: 4.3 - - The ``Countries`` class was introduced in Symfony 4.3. - -.. versionadded:: 4.4 - - The support for alpha3 codes was introduced in Symfony 4.4. - Locales ~~~~~~~ @@ -259,10 +239,6 @@ to catching the exception, you can also check if a given locale code is valid:: $isValidLocale = Locales::exists($localeCode); -.. versionadded:: 4.3 - - The ``Locales`` class was introduced in Symfony 4.3. - Currencies ~~~~~~~~~~ @@ -305,10 +281,6 @@ to catching the exception, you can also check if a given currency code is valid: $isValidCurrency = Currencies::exists($currencyCode); -.. versionadded:: 4.3 - - The ``Currencies`` class was introduced in Symfony 4.3. - .. _component-intl-timezones: Timezones @@ -387,10 +359,6 @@ to catching the exception, you can also check if a given timezone ID is valid:: $isValidTimezone = Timezones::exists($timezoneId); -.. versionadded:: 4.3 - - The ``Timezones`` class was introduced in Symfony 4.3. - Learn more ---------- diff --git a/components/lock.rst b/components/lock.rst index 7869c2e019d..a9309baa0ca 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -33,11 +33,6 @@ which in turn requires another class to manage the storage of locks:: $store = new SemaphoreStore(); $factory = new LockFactory($store); -.. versionadded:: 4.4 - - The ``Symfony\Component\Lock\LockFactory`` class was introduced in Symfony - 4.4. In previous versions it was called ``Symfony\Component\Lock\Factory``. - The lock is created by calling the :method:`Symfony\\Component\\Lock\\LockFactory::createLock` method. Its first argument is an arbitrary string that represents the locked resource. Then, a call to the :method:`Symfony\\Component\\Lock\\LockInterface::acquire` @@ -231,12 +226,6 @@ Store Scope Blocking Expiring :ref:`ZookeeperStore ` remote no no ============================================ ====== ======== ======== -.. versionadded:: 4.4 - - The ``PersistingStoreInterface`` and ``BlockingStoreInterface`` interfaces were - introduced in Symfony 4.4. In previous versions there was only one interface - called ``Symfony\Component\Lock\StoreInterface``. - .. _lock-store-flock: FlockStore diff --git a/components/mailer.rst b/components/mailer.rst index f4290bed825..de99cf09639 100644 --- a/components/mailer.rst +++ b/components/mailer.rst @@ -10,10 +10,6 @@ The Mailer Component If you're using the Symfony Framework, read the :doc:`Symfony Framework Mailer documentation `. -.. versionadded:: 4.3 - - The Mailer component was introduced in Symfony 4.3. - Installation ------------ @@ -146,6 +142,20 @@ The mailer will start using the first transport and if it fails, it will retry the same delivery with the next transports until one of them succeeds (or until all of them fail). +TLS Peer Verification +--------------------- + +By default, SMTP transports perform TLS peer verification. This behavior is +configurable with the ``verify_peer`` option. Although it's not recommended to +disable this verification for security reasons, it can be useful while developing +the application or when using a self-signed certificate:: + + $dsn = 'smtp://user:pass@smtp.example.com?verify_peer=false' + +.. versionadded:: 5.1 + + The ``verify_peer`` option was introduced in Symfony 5.1. + Sending emails asynchronously ----------------------------- diff --git a/components/messenger.rst b/components/messenger.rst index fa4b4a7d81b..8d79561401f 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -77,15 +77,9 @@ middleware stack. The component comes with a set of middleware that you can use. When using the message bus with Symfony's FrameworkBundle, the following middleware are configured for you: -#. :class:`Symfony\\Component\\Messenger\\Middleware\\LoggingMiddleware` (logs the processing of your messages) -#. :class:`Symfony\\Component\\Messenger\\Middleware\\SendMessageMiddleware` (enables asynchronous processing) +#. :class:`Symfony\\Component\\Messenger\\Middleware\\SendMessageMiddleware` (enables asynchronous processing, logs the processing of your messages if you pass a logger) #. :class:`Symfony\\Component\\Messenger\\Middleware\\HandleMessageMiddleware` (calls the registered handler(s)) -.. deprecated:: 4.3 - - The ``LoggingMiddleware`` is deprecated since Symfony 4.3 and will be - removed in 5.0. Pass a logger to ``SendMessageMiddleware`` instead. - Example:: use App\Message\MyMessage; @@ -322,12 +316,6 @@ do is to write your own CSV receiver:: } } -.. versionadded:: 4.3 - - In Symfony 4.3, the ``ReceiverInterface`` has changed its methods as shown - in the example above. You may need to update your code if you used this - interface in previous Symfony versions. - Receiver and Sender on the same Bus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/mime.rst b/components/mime.rst index dc02abd8d6e..e2dd3b05056 100644 --- a/components/mime.rst +++ b/components/mime.rst @@ -9,10 +9,6 @@ The Mime Component The Mime component allows manipulating the MIME messages used to send emails and provides utilities related to MIME types. -.. versionadded:: 4.3 - - The Mime component was introduced in Symfony 4.3. - Installation ------------ diff --git a/components/notifier.rst b/components/notifier.rst new file mode 100644 index 00000000000..9e7be5c4197 --- /dev/null +++ b/components/notifier.rst @@ -0,0 +1,28 @@ +.. index:: + single: Notifier + single: Notifications + single: Components; Notifier + +The Notifier Component +====================== + + The Notifier component sends notifications via one or more channels + (email, SMS, Slack, ...). + +Installation +------------ + +.. code-block:: terminal + + $ composer require symfony/notifier + +.. include:: /components/require_autoload.rst.inc + + +Usage +----- + +.. caution:: + + We're still working on the docs of this component. Check this page again + in a few days. diff --git a/components/options_resolver.rst b/components/options_resolver.rst index a88c9f95d31..c790d1ed561 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -440,10 +440,6 @@ This way, the ``$value`` argument will receive the previously normalized value, otherwise you can prepend the new normalizer by passing ``true`` as third argument. -.. versionadded:: 4.3 - - The ``addNormalizer()`` method was introduced in Symfony 4.3. - Default Values that Depend on another Option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 04380cfa076..df039b826c8 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -330,10 +330,6 @@ notices at class autoloading time. This can be disabled with the -.. versionadded:: 4.2 - - The ``DebugClassLoader`` integration was introduced in Symfony 4.2. - Write Assertions about Deprecations ----------------------------------- @@ -392,10 +388,6 @@ the test suite cannot use the latest versions of PHPUnit because: Polyfills for the Unavailable Methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - This feature was introduced in Symfony 4.4. - When using the ``simple-phpunit`` script, PHPUnit Bridge injects polyfills for most methods of the ``TestCase`` and ``Assert`` classes (e.g. ``expectException()``, ``expectExceptionMessage()``, ``assertContainsEquals()``, etc.). This allows writing @@ -405,10 +397,6 @@ older PHPUnit versions. Removing the Void Return Type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - This feature was introduced in Symfony 4.4. - When running the ``simple-phpunit`` script with the ``SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT`` environment variable set to ``1``, the PHPUnit bridge will alter the code of PHPUnit to remove the return type (introduced in PHPUnit 8) from ``setUp()``, @@ -444,10 +432,6 @@ call to the ``doSetUp()``, ``doTearDown()``, ``doSetUpBeforeClass()`` and Using Namespaced PHPUnit Classes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - This feature was introduced in Symfony 4.4. - The PHPUnit bridge adds namespaced class aliases for most of the PHPUnit classes declared without namespaces (e.g. ``PHPUnit_Framework_Assert``), allowing you to always use the namespaced class declaration even when the test is executed with @@ -617,20 +601,19 @@ functions: Use Case ~~~~~~~~ -Consider the following example that uses the ``checkMX`` option of the ``Email`` -constraint to test the validity of the email domain:: +Consider the following example that tests a custom class called ``DomainValidator`` +which defines a ``checkDnsRecord`` option to also validate that a domain is +associated to a valid host:: + use App\Validator\DomainValidator; use PHPUnit\Framework\TestCase; - use Symfony\Component\Validator\Constraints\Email; class MyTest extends TestCase { public function testEmail() { - $validator = ... - $constraint = new Email(['checkMX' => true]); - - $result = $validator->validate('foo@example.com', $constraint); + $validator = new DomainValidator(['checkDnsRecord' => true]); + $isValid = $validator->validate('example.com'); // ... } @@ -640,22 +623,23 @@ In order to avoid making a real network connection, add the ``@dns-sensitive`` annotation to the class and use the ``DnsMock::withMockedHosts()`` to configure the data you expect to get for the given hosts:: + use App\Validator\DomainValidator; use PHPUnit\Framework\TestCase; - use Symfony\Component\Validator\Constraints\Email; + use Symfony\Bridge\PhpUnit\DnsMock; /** * @group dns-sensitive */ - class MyTest extends TestCase + class DomainValidatorTest extends TestCase { public function testEmails() { - DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]); - - $validator = ... - $constraint = new Email(['checkMX' => true]); + DnsMock::withMockedHosts([ + 'example.com' => [['type' => 'A', 'ip' => '1.2.3.4']], + ]); - $result = $validator->validate('foo@example.com', $constraint); + $validator = new DomainValidator(['checkDnsRecord' => true]); + $isValid = $validator->validate('example.com'); // ... } diff --git a/components/process.rst b/components/process.rst index 7136dcc1048..baaff0f920b 100644 --- a/components/process.rst +++ b/components/process.rst @@ -102,11 +102,6 @@ with a non-zero code):: :method:`Symfony\\Component\\Process\\Process::getLastOutputTime` method. This method returns ``null`` if the process wasn't started! - .. versionadded:: 4.4 - - The :method:`Symfony\\Component\\Process\\Process::getLastOutputTime` - method was introduced in Symfony 4.4. - Using Features From the OS Shell -------------------------------- @@ -150,10 +145,6 @@ enclosing a variable name into ``"${:`` and ``}"`` exactly, the process object will replace it with its escaped value, or will fail if the variable is not found in the list of environment variables attached to the command. -.. versionadded:: 4.4 - - Portable command lines were introduced in Symfony 4.4. - Setting Environment Variables for Processes ------------------------------------------- @@ -383,6 +374,23 @@ instead:: ); $process->run(); +Using a Prepared Command Line +----------------------------- + +You can run the process by using a a prepared command line using the +double bracket notation. You can use a placeholder in order to have a +process that can only be changed with the values and without changing +the PHP code:: + + use Symfony\Component\Process\Process; + + $process = Process::fromShellCommandline('echo "$name"'); + $process->run(null, ['name' => 'Elsa']); + +.. caution:: + + A prepared command line will not be escaped automatically! + Process Timeout --------------- diff --git a/components/property_access.rst b/components/property_access.rst index 1ff482f5216..df0f3d99b51 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -169,11 +169,6 @@ This will produce: ``This person is an author`` Accessing a non Existing Property Path ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The ``disableExceptionOnInvalidPropertyPath()`` method was introduced in - Symfony 4.3. - By default a :class:`Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException` is thrown if the property path passed to :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue` does not exist. You can change this behavior using the diff --git a/components/property_info.rst b/components/property_info.rst index dce587e629e..ffce72e40bb 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -322,10 +322,6 @@ this returns ``true`` if: ``@var SomeClass``, ``@var SomeClass``, ``@var Doctrine\Common\Collections\Collection``, etc.) -.. versionadded:: 4.2 - - The support of phpDocumentor collection types was introduced in Symfony 4.2. - ``Type::getCollectionKeyType()`` & ``Type::getCollectionValueType()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -379,11 +375,6 @@ return and scalar types for PHP 7:: // Initializable information $reflectionExtractor->isInitializable($class, $property); -.. versionadded:: 4.1 - - The feature to extract the property types from constructor arguments was - introduced in Symfony 4.1. - .. note:: When using the Symfony framework, this service is automatically registered diff --git a/components/security.rst b/components/security.rst index ee6c1580472..9985b611c63 100644 --- a/components/security.rst +++ b/components/security.rst @@ -14,12 +14,6 @@ The Security Component Installation ------------ -.. code-block:: terminal - - $ composer require symfony/security - -.. include:: /components/require_autoload.rst.inc - The Security component is divided into several smaller sub-components which can be used separately: @@ -38,6 +32,17 @@ be used separately: It brings many layers of authentication together, allowing the creation of complex authentication systems. +You can install each of them separately in your project: + +.. code-block:: terminal + + $ composer require symfony/security-core + $ composer require symfony/security-http + $ composer require symfony/security-csrf + $ composer require symfony/security-guard + +.. include:: /components/require_autoload.rst.inc + .. seealso:: This article explains how to use the Security features as an independent diff --git a/components/security/authentication.rst b/components/security/authentication.rst index 47c4c42cede..7aa1da73f5d 100644 --- a/components/security/authentication.rst +++ b/components/security/authentication.rst @@ -319,10 +319,6 @@ the ``switch_user`` firewall listener. The ``Symfony\Component\Security\Http\Event\DeauthenticatedEvent`` event is triggered when a token has been deauthenticated because of a user change, it can help you doing some clean-up task when a logout has been triggered. -.. versionadded:: 4.3 - - The ``Symfony\Component\Security\Http\Event\DeauthenticatedEvent`` event was introduced in Symfony 4.3. - .. seealso:: For more information on switching users, see diff --git a/components/serializer.rst b/components/serializer.rst index b3d6b863c96..bad4af9572c 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -225,11 +225,6 @@ normalized data, instead of the denormalizer re-creating them. Note that arrays of objects. Those will still be replaced when present in the normalized data. -.. versionadded:: 4.3 - - The ``AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE`` option was - introduced in Symfony 4.3. - .. _component-serializer-attributes-groups: Attributes Groups @@ -436,12 +431,6 @@ key in the ``context`` parameter of the desired serializer method:: $serializer = new Serializer([$normalizer], [$encoder]); $serializer->serialize($person, 'json', [AbstractNormalizer::IGNORED_ATTRIBUTES => ['age']]); // Output: {"name":"foo"} -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setIgnoredAttributes` - method that was used as an alternative to the ``AbstractNormalizer::IGNORED_ATTRIBUTES`` option - was deprecated in Symfony 4.2. - .. _component-serializer-converting-property-names-when-serializing-and-deserializing: Converting Property Names when Serializing and Deserializing @@ -641,12 +630,6 @@ and ``remove``. Using Callbacks to Serialize Properties with Object Instances ------------------------------------------------------------- -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCallbacks` - method is deprecated since Symfony 4.2. Use the ``callbacks`` - key of the context instead. - When serializing, you can set a callback to format a specific object property:: use App\Model\Person; @@ -679,11 +662,6 @@ When serializing, you can set a callback to format a specific object property:: $serializer->serialize($person, 'json'); // Output: {"name":"cordoval", "age": 34, "createdAt": "2014-03-22T09:43:12-0500"} -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCallbacks` is deprecated since - Symfony 4.2, use the "callbacks" key of the context instead. - .. _component-serializer-normalizers: Normalizers @@ -743,10 +721,6 @@ There are several types of normalizers available: This normalizer converts :phpclass:`DateTimeZone` objects into strings that represent the name of the timezone according to the `list of PHP timezones`_. - .. versionadded:: 4.3 - - The ``DateTimeZoneNormalizer`` was introduced in Symfony 4.3. - :class:`Symfony\\Component\\Serializer\\Normalizer\\DataUriNormalizer` This normalizer converts :phpclass:`SplFileInfo` objects into a data URI string (``data:...``) such that files can be embedded into serialized data. @@ -812,13 +786,6 @@ The ``CsvEncoder`` The ``CsvEncoder`` encodes to and decodes from CSV. -You can pass the context key ``as_collection`` in order to have the results -always as a collection. - -.. deprecated:: 4.2 - - Relying on the default value ``false`` is deprecated since Symfony 4.2. - The ``XmlEncoder`` ~~~~~~~~~~~~~~~~~~ @@ -982,12 +949,6 @@ having unique identifiers:: var_dump($serializer->serialize($org, 'json')); // {"name":"Les-Tilleuls.coop","members":[{"name":"K\u00e9vin", organization: "Les-Tilleuls.coop"}]} -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCircularReferenceHandler` - method is deprecated since Symfony 4.2. Use the ``AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER`` - key of the context instead. - Handling Serialization Depth ---------------------------- @@ -1140,12 +1101,6 @@ having unique identifiers:: ]; */ -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setMaxDepthHandler` - method is deprecated since Symfony 4.2. Use the ``max_depth_handler`` - key of the context instead. - Handling Arrays --------------- diff --git a/components/string.rst b/components/string.rst new file mode 100644 index 00000000000..b3ca048b75e --- /dev/null +++ b/components/string.rst @@ -0,0 +1,472 @@ +.. index:: + single: String + single: Components; String + +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 as an + :doc:`experimental feature `. + +Installation +------------ + +.. code-block:: terminal + + $ composer require symfony/string + +.. include:: /components/require_autoload.rst.inc + +What is a String? +----------------- + +You can skip this section if you already know what a *"code point"* or a +*"grapheme cluster"* are in the context of handling strings. Otherwise, read +this section to learn about the terminology used by this component. + +Languages like English require a very limited set of characters and symbols to +display any content. Each string is a series of characters (letters or symbols) +and they can be encoded even with the most limited standards (e.g. `ASCII`_). + +However, other languages require thousands of symbols to display their contents. +They need complex encoding standards such as `Unicode`_ and concepts like +"character" no longer make sense. Instead, you have to deal with these terms: + +* `Code points`_: they are the atomic unit of information. A string is a series + of code points. Each code point is a number whose meaning is given by the + `Unicode`_ standard. For example, the English letter ``A`` is the ``U+0041`` + code point and the Japanese *kana* ``の`` is the ``U+306E`` code point. +* `Grapheme clusters`_: they are a sequence of one or more code points which are + displayed as a single graphical unit. For example, the Spanish letter ``ñ`` is + a grapheme cluster that contains two code points: ``U+006E`` = ``n`` (*"latin + small letter N"*) + ``U+0303`` = ``◌̃`` (*"combining tilde"*). +* Bytes: they are the actual information stored for the string contents. Each + code point can require one or more bytes of storage depending on the standard + being used (UTF-8, UTF-16, etc.). + +The following image displays the bytes, code points and grapheme clusters for +the same word written in English (``hello``) and Hindi (``नमस्ते``): + +.. image:: /_images/components/string/bytes-points-graphemes.png + :align: center + +Usage +----- + +Create a new object of type :class:`Symfony\\Component\\String\\ByteString`, +:class:`Symfony\\Component\\String\\CodePointString` or +:class:`Symfony\\Component\\String\\UnicodeString`, pass the string contents as +their arguments and then use the object-oriented API to work with those strings:: + + use Symfony\Component\String\UnicodeString; + + $text = (new UnicodeString('This is a déjà-vu situation.')) + ->trimEnd('.') + ->replace('déjà-vu', 'jamais-vu') + ->append('!'); + // $text = 'This is a jamais-vu situation!' + + $content = new UnicodeString('नमस्ते दुनिया'); + if ($content->ignoreCase()->startsWith('नमस्ते')) { + // ... + } + +Method Reference +---------------- + +Methods to Create String Objects +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +First, you can create objects prepared to store strings as bytes, code points +and grapheme clusters with the following classes:: + + use Symfony\Component\String\ByteString; + use Symfony\Component\String\CodePointString; + use Symfony\Component\String\UnicodeString; + + $foo = new ByteString('hello'); + $bar = new CodePointString('hello'); + // UnicodeString is the most commonly used class + $baz = new UnicodeString('hello'); + +Use the ``wrap()`` static method to instantiate more than one string object:: + + $contents = ByteString::wrap(['hello', 'world']); // $contents = ByteString[] + $contents = UnicodeString::wrap(['I', '❤️', 'Symfony']); // $contents = UnicodeString[] + + // use the unwrap method to make the inverse conversion + $contents = UnicodeString::unwrap([ + new UnicodeString('hello'), new UnicodeString('world'), + ]); // $contents = ['hello', 'world'] + +There are two shortcut functions called ``b()`` and ``u()`` to create +``ByteString`` and ``UnicodeString`` objects:: + + // ... + use function Symfony\Component\String\b; + use function Symfony\Component\String\u; + + // both are equivalent + $foo = new ByteString('hello'); + $foo = b('hello'); + + // both are equivalent + $baz = new UnicodeString('hello'); + $baz = u('hello'); + +There are also some specialized constructors:: + + // ByteString can create a random string of the given length + $foo = ByteString::fromRandom(12); + + // CodePointString and UnicodeString can create a string from code points + $foo = UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947); + // equivalent to: $foo = new UnicodeString('नमस्ते'); + +Methods to Transform String Objects +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each string object can be transformed into the other two types of objects:: + + $foo = ByteString::fromRandom(12)->toCodePointString(); + $foo = (new CodePointString('hello'))->toUnicodeString(); + $foo = UnicodeString::fromCodePoints(0x68, 0x65, 0x6C, 0x6C, 0x6F)->toByteString(); + + // the optional $toEncoding argument defines the encoding of the target string + $foo = (new CodePointString('hello'))->toByteString('Windows-1252'); + // the optional $fromEncoding argument defines the encoding of the original string + $foo = (new ByteString('さよなら'))->toCodePointString('ISO-2022-JP'); + +If the conversion is not possible for any reason, you'll get an +:class:`Symfony\\Component\\String\\Exception\\InvalidArgumentException`. + +Methods Related to Length and White Spaces +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + // returns the number of graphemes, code points or bytes of the given string + $word = 'नमस्ते'; + (new ByteString($word))->length(); // 18 (bytes) + (new CodePointString($word))->length(); // 6 (code points) + (new UnicodeString($word))->length(); // 4 (graphemes) + + // some symbols require double the width of others to represent them when using + // a monospaced font (e.g. in a console). This method returns the total width + // needed to represent the entire word + $word = 'नमस्ते'; + (new ByteString($word))->width(); // 18 + (new CodePointString($word))->width(); // 4 + (new UnicodeString($word))->width(); // 4 + // if the text contains multiple lines, it returns the max width of all lines + $text = "<<width(); // 14 + + // only returns TRUE if the string is exactly an empty string (not even white spaces) + u('hello world')->isEmpty(); // false + u(' ')->isEmpty(); // false + u('')->isEmpty(); // true + + // removes all white spaces from the start and end of the string and replaces two + // or more consecutive white spaces inside contents by a single white space + u(" \n\n hello world \n \n")->collapseWhitespace(); // 'hello world' + +Methods to Change Case +~~~~~~~~~~~~~~~~~~~~~~ + +:: + + // changes all graphemes/code points to lower case + u('FOO Bar')->lower(); // 'foo bar' + + // when dealing with different languages, uppercase/lowercase is not enough + // there are three cases (lower, upper, title), some characters have no case, + // case is context-sensitive and locale-sensitive, etc. + // this method returns a string that you can use in case-insensitive comparisons + u('FOO Bar')->folded(); // 'foo bar' + u('Die O\'Brian Straße')->folded(); // "die o'brian strasse" + + // changes all graphemes/code points to upper case + u('foo BAR')->upper(); // 'FOO BAR' + + // changes all graphemes/code points to "title case" + u('foo bar')->title(); // 'Foo bar' + u('foo bar')->title(true); // 'Foo Bar' + + // changes all graphemes/code points to camelCase + u('Foo: Bar-baz.')->camel(); // 'fooBarBaz' + // changes all graphemes/code points to snake_case + u('Foo: Bar-baz.')->snake(); // 'foo_bar_baz' + // other cases can be achieved by chaining methods. E.g. PascalCase: + u('Foo: Bar-baz.')->camel()->title(); // 'FooBarBaz' + +The methods of all string classes are case-sensitive by default. You can perform +case-insensitive operations with the ``ignoreCase()`` method:: + + u('abc')->indexOf('B'); // null + u('abc')->ignoreCase()->indexOf('B'); // 1 + +Methods to Append and Prepend +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + // adds the given content (one or more strings) at the beginning/end of the string + u('world')->prepend('hello'); // 'helloworld' + u('world')->prepend('hello', ' '); // 'hello world' + + u('hello')->append('world'); // 'helloworld' + u('hello')->append(' ', 'world'); // 'hello world' + + // adds the given content at the beginning of the string (or removes it) to + // make sure that the content starts exactly with that content + u('Name')->ensureStart('get'); // 'getName' + u('getName')->ensureStart('get'); // 'getName' + u('getgetName')->ensureStart('get'); // 'getName' + // this method is similar, but works on the end of the content instead of on the beginning + u('User')->ensureEnd('Controller'); // 'UserController' + u('UserController')->ensureEnd('Controller'); // 'UserController' + u('UserControllerController')->ensureEnd('Controller'); // 'UserController' + + // returns the contents found before/after the first occurrence of the given string + u('hello world')->before('world'); // 'hello ' + u('hello world')->before('o'); // 'hell' + u('hello world')->before('o', true); // 'hello' + + u('hello world')->after('hello'); // ' world' + u('hello world')->after('o'); // ' world' + u('hello world')->after('o', true); // 'o world' + + // returns the contents found before/after the last occurrence of the given string + u('hello world')->beforeLast('o'); // 'hello w' + u('hello world')->beforeLast('o', true); // 'hello wo' + + u('hello world')->afterLast('o'); // 'rld' + u('hello world')->afterLast('o', true); // 'orld' + +Methods to Pad and Trim +~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + // makes a string as long as the first argument by adding the given + // string at the beginning, end or both sides of the string + u(' Lorem Ipsum ')->padBoth(20, '-'); // '--- Lorem Ipsum ----' + u(' Lorem Ipsum')->padStart(20, '-'); // '-------- Lorem Ipsum' + u('Lorem Ipsum ')->padEnd(20, '-'); // 'Lorem Ipsum --------' + + // repeats the given string the number of times passed as argument + u('_.')->repeat(10); // '_._._._._._._._._._.' + + // removes the given characters (by default, white spaces) from the string + u(' Lorem Ipsum ')->trim(); // 'Lorem Ipsum' + u('Lorem Ipsum ')->trim('m'); // 'Lorem Ipsum ' + u('Lorem Ipsum')->trim('m'); // 'Lorem Ipsu' + + u(' Lorem Ipsum ')->trimStart(); // 'Lorem Ipsum ' + u(' Lorem Ipsum ')->trimEnd(); // ' Lorem Ipsum' + +Methods to Search and Replace +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + // checks if the string starts/ends with the given string + u('https://symfony.com')->startsWith('https'); // true + u('report-1234.pdf')->endsWith('.pdf'); // true + + // checks if the string contents are exactly the same as the given contents + u('foo')->equalsTo('foo'); // true + + // checks if the string content match the given regular expression + u('avatar-73647.png')->match('/avatar-(\d+)\.png/'); + // result = ['avatar-73647.png', '73647'] + + // finds the position of the first occurrence of the given string + // (the second argument is the position where the search starts and negative + // values have the same meaning as in PHP functions) + u('abcdeabcde')->indexOf('c'); // 2 + u('abcdeabcde')->indexOf('c', 2); // 2 + u('abcdeabcde')->indexOf('c', -4); // 7 + u('abcdeabcde')->indexOf('eab'); // 4 + u('abcdeabcde')->indexOf('k'); // null + + // finds the position of the last occurrence of the given string + // (the second argument is the position where the search starts and negative + // values have the same meaning as in PHP functions) + u('abcdeabcde')->indexOfLast('c'); // 7 + u('abcdeabcde')->indexOfLast('c', 2); // 7 + u('abcdeabcde')->indexOfLast('c', -4); // 2 + u('abcdeabcde')->indexOfLast('eab'); // 4 + u('abcdeabcde')->indexOfLast('k'); // null + + // replaces all occurrences of the given string + u('http://symfony.com')->replace('http://', 'https://'); // 'https://symfony.com' + // replaces all occurrences of the given regular expression + u('(+1) 206-555-0100')->replaceMatches('/[^A-Za-z0-9]++/', ''); // '12065550100' + // you can pass a callable as the second argument to perform advanced replacements + u('123')->replaceMatches('/\d/', function ($match) { + return '['.$match[0].']'; + }); // result = '[1][2][3]' + +Methods to Join, Split, Truncate and Reverse +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + // uses the string as the "glue" to merge all the given strings + u(', ')->join(['foo', 'bar']); // 'foo, bar' + + // breaks the string into pieces using the given delimiter + u('template_name.html.twig')->split('.'); // ['template_name', 'html', 'twig'] + // you can set the maximum number of pieces as the second argument + u('template_name.html.twig')->split('.', 2); // ['template_name', 'html.twig'] + + // returns a substring which starts at the first argument and has the length of the + // second optional argument (negative values have the same meaning as in PHP functions) + u('Symfony is great')->slice(0, 7); // 'Symfony' + u('Symfony is great')->slice(0, -6); // 'Symfony is' + u('Symfony is great')->slice(11); // 'great' + u('Symfony is great')->slice(-5); // 'great' + + // reduces the string to the length given as argument (if it's longer) + u('Lorem Ipsum')->truncate(80); // 'Lorem Ipsum' + u('Lorem Ipsum')->truncate(3); // 'Lor' + u('Lorem Ipsum')->truncate(8, '…'); // 'Lorem I…' + + // breaks the string into lines of the given length + u('Lorem Ipsum')->wordwrap(4); // 'Lorem\nIpsum' + // by default it breaks by white space; pass TRUE to break unconditionally + u('Lorem Ipsum')->wordwrap(4, "\n", true); // 'Lore\nm\nIpsu\nm' + + // replaces a portion of the string with the given contents: + // the second argument is the position where the replacement starts; + // the third argument is the number of graphemes/code points removed from the string + u('0123456789')->splice('xxx'); // 'xxx' + u('0123456789')->splice('xxx', 0, 2); // 'xxx23456789' + u('0123456789')->splice('xxx', 0, 6); // 'xxx6789' + u('0123456789')->splice('xxx', 6); // '012345xxx' + + // breaks the string into pieces of the length given as argument + u('0123456789')->chunk(3); // ['012', '345', '678', '9'] + + // reverses the order of the string contents + u('foo bar')->reverse(); // 'rab oof' + u('さよなら')->reverse(); // 'らなよさ' + +.. versionadded:: 5.1 + + The ``reverse()`` method was introduced in Symfony 5.1. + +Methods Added by ByteString +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These methods are only available for ``ByteString`` objects:: + + // returns TRUE if the string contents are valid UTF-8 contents + b('Lorem Ipsum')->isUtf8(); // true + b("\xc3\x28")->isUtf8(); // false + + // returns the value of the byte stored at the given position + // ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184, + // 224, 165, 141, 224, 164, 164, 224, 165, 135]) + b('नमस्ते')->byteCode(0); // 224 + b('नमस्ते')->byteCode(17); // 135 + +Methods Added by CodePointString and UnicodeString +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These methods are only available for ``CodePointString`` and ``UnicodeString`` +objects:: + + // transliterates any string into the latin alphabet defined by the ASCII encoding + // (don't use this method to build a slugger because this component already provides + // a slugger, as explained later in this article) + u('नमस्ते')->ascii(); // 'namaste' + u('さよなら')->ascii(); // 'sayonara' + u('спасибо')->ascii(); // 'spasibo' + + // returns an array with the code point or points stored at the given position + // (code points of 'नमस्ते' graphemes = [2344, 2350, 2360, 2340] + u('नमस्ते')->codePointsAt(0); // [2344] + u('नमस्ते')->codePointsAt(2); // [2360] + +`Unicode equivalence`_ is the specification by the Unicode standard that +different sequences of code points represent the same character. For example, +the Swedish letter ``å`` can be a single code point (``U+00E5`` = *"latin small +letter A with ring above"*) or a sequence of two code points (``U+0061`` = +*"latin small letter A"* + ``U+030A`` = *"combining ring above"*). The +``normalize()`` method allows to pick the normalization mode:: + + // these encode the letter as a single code point: U+00E5 + u('å')->normalize(UnicodeString::NFC); + u('å')->normalize(UnicodeString::NFKC); + // these encode the letter as two code points: U+0061 + U+030A + u('å')->normalize(UnicodeString::NFD); + u('å')->normalize(UnicodeString::NFKD); + +Slugger +------- + +In some contexts, such as URLs and file/directory names, it's not safe to use +any Unicode character. A *slugger* transforms a given string into another string +that only includes safe ASCII characters:: + + use Symfony\Component\String\Slugger\AsciiSlugger; + + $slugger = new AsciiSlugger(); + $slug = $slugger->slug('Wôrķšƥáçè ~~sèťtïñğš~~'); + // $slug = 'Workspace-settings' + +The separator between words is a dash (``-``) by default, but you can define +another separator as the second argument:: + + $slug = $slugger->slug('Wôrķšƥáçè ~~sèťtïñğš~~', '/'); + // $slug = 'Workspace/settings' + +The slugger transliterates the original string into the Latin script before +applying the other transformations. The locale of the original string is +detected automatically, but you can define it explicitly:: + + // this tells the slugger to transliterate from Korean language + $slugger = new AsciiSlugger('ko'); + + // you can override the locale as the third optional parameter of slug() + $slug = $slugger->slug('...', '-', 'fa'); + +In a Symfony application, you don't need to create the slugger yourself. Thanks +to :doc:`service autowiring `, you can inject a +slugger by type-hinting a service constructor argument with the +:class:`Symfony\\Component\\String\\Slugger\\SluggerInterface`. The locale of +the injected slugger is the same as the request locale:: + + use Symfony\Component\String\Slugger\SluggerInterface; + + class MyService + { + private $slugger; + + public function __construct(SluggerInterface $slugger) + { + $this->slugger = $slugger; + } + + public function someMethod() + { + $slug = $this->slugger->slug('...'); + } + } + +.. _`ASCII`: https://en.wikipedia.org/wiki/ASCII +.. _`Unicode`: https://en.wikipedia.org/wiki/Unicode +.. _`Code points`: https://en.wikipedia.org/wiki/Code_point +.. _`Grapheme clusters`: https://en.wikipedia.org/wiki/Grapheme +.. _`Unicode equivalence`: https://en.wikipedia.org/wiki/Unicode_equivalence diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 1455c2518bc..7f9b02fb544 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -158,10 +158,6 @@ implement the PSR-6 interface :class:`Psr\\Cache\\CacheItemPoolInterface`):: ->setMappingCache(new SomePsr6Cache()); ->getValidator(); -.. versionadded:: 4.4 - - Support for PSR-6 compatible mapping caches was introduced in Symfony 4.4. - .. note:: The loaders already use a singleton load mechanism. That means that the diff --git a/components/var_dumper.rst b/components/var_dumper.rst index a607ddeb59b..e89c822c21f 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -227,10 +227,6 @@ option. Read more about this and other options in If you want to use your browser search input, press ``Ctrl. + F`` or ``Cmd. + F`` again while having focus on VarDumper's search input. - .. versionadded:: 4.4 - - The feature to use the browser search input was introduced in Symfony 4.4. - Using the VarDumper Component in your PHPUnit Test Suite -------------------------------------------------------- @@ -258,11 +254,6 @@ The ``VarDumperTestTrait`` also includes these other methods: is called automatically after each case to reset the custom configuration made in ``setUpVarDumper()``. -.. versionadded:: 4.4 - - The ``setUpVarDumper()`` and ``tearDownVarDumper()`` methods were introduced - in Symfony 4.4. - Example:: use PHPUnit\Framework\TestCase; diff --git a/components/yaml.rst b/components/yaml.rst index 572c2286ced..5206f81b805 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -390,10 +390,6 @@ you can dump them as ``~`` with the ``DUMP_NULL_AS_TILDE`` flag:: $dumped = Yaml::dump(['foo' => null], 2, 4, Yaml::DUMP_NULL_AS_TILDE); // foo: ~ -.. versionadded:: 4.4 - - The flag to dump ``null`` as ``~`` was introduced in Symfony 4.4. - Syntax Validation ~~~~~~~~~~~~~~~~~ diff --git a/configuration.rst b/configuration.rst index caa2a25cb61..781683ad577 100644 --- a/configuration.rst +++ b/configuration.rst @@ -644,10 +644,6 @@ their values by running: # run this command to show all the details for a specific env var: $ php bin/console debug:container --env-var=FOO -.. versionadded:: 4.3 - - The option to debug environment variables was introduced in Symfony 4.3. - .. _configuration-accessing-parameters: Accessing Configuration Parameters diff --git a/configuration/env_var_processors.rst b/configuration/env_var_processors.rst index 67d9bca422e..83eafef37aa 100644 --- a/configuration/env_var_processors.rst +++ b/configuration/env_var_processors.rst @@ -366,10 +366,6 @@ Symfony provides the following env var processors: 'auth' => '%env(require:AUTH_FILE)%', ]); - .. versionadded:: 4.3 - - The ``require`` processor was introduced in Symfony 4.3. - ``env(trim:FOO)`` Trims the content of ``FOO`` env var, removing whitespaces from the beginning and end of the string. This is especially useful in combination with the @@ -412,10 +408,6 @@ Symfony provides the following env var processors: 'auth' => '%env(trim:file:AUTH_FILE)%', ]); - .. versionadded:: 4.3 - - The ``trim`` processor was introduced in Symfony 4.3. - ``env(key:FOO:BAR)`` Retrieves the value associated with the key ``FOO`` from the array whose contents are stored in the ``BAR`` env var: @@ -497,10 +489,6 @@ Symfony provides the following env var processors: When the fallback parameter is omitted (e.g. ``env(default::API_KEY)``), the value returned is ``null``. - .. versionadded:: 4.3 - - The ``default`` processor was introduced in Symfony 4.3. - ``env(url:FOO)`` Parses an absolute URL and returns its components as an associative array. @@ -570,10 +558,6 @@ Symfony provides the following env var processors: In order to ease extraction of the resource from the URL, the leading ``/`` is trimmed from the ``path`` component. - .. versionadded:: 4.3 - - The ``url`` processor was introduced in Symfony 4.3. - ``env(query_string:FOO)`` Parses the query string part of the given URL and returns its components as an associative array. @@ -620,10 +604,6 @@ Symfony provides the following env var processors: ], ]); - .. versionadded:: 4.3 - - The ``query_string`` processor was introduced in Symfony 4.3. - It is also possible to combine any number of processors: .. code-block:: yaml diff --git a/configuration/secrets.rst b/configuration/secrets.rst index f1294143732..86329773b90 100644 --- a/configuration/secrets.rst +++ b/configuration/secrets.rst @@ -4,10 +4,6 @@ How to Keep Sensitive Information Secret ======================================== -.. versionadded:: 4.4 - - The Secrets management was introduced in Symfony 4.4. - :ref:`Environment variables ` are the best way to store configuration that depends on where the application is run - for example, some API key that might be set to one value while developing locally and another value on production. diff --git a/console.rst b/console.rst index 250451d985f..8b7b38b0d46 100644 --- a/console.rst +++ b/console.rst @@ -317,14 +317,9 @@ command: :method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)* This method is executed after ``interact()`` and ``initialize()``. - It contains the logic you want the command to execute and it should + It contains the logic you want the command to execute and it must return an integer which will be used as the command `exit status`_. - .. deprecated:: 4.4 - - Not returning an integer with the exit status as the result of - ``execute()`` is deprecated since Symfony 4.4. - .. _console-testing-commands: Testing Commands diff --git a/console/coloring.rst b/console/coloring.rst index 774a2ab96fa..3684d71709d 100644 --- a/console/coloring.rst +++ b/console/coloring.rst @@ -77,10 +77,6 @@ You can also set these colors and options directly inside the tag name:: Displaying Clickable Links ~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The feature to display clickable links was introduced in Symfony 4.3. - Commands can use the special ```` tag to display links similar to the ```` elements of web pages:: diff --git a/console/commands_as_services.rst b/console/commands_as_services.rst index 000dffeca48..4e0c4e38b62 100644 --- a/console/commands_as_services.rst +++ b/console/commands_as_services.rst @@ -60,13 +60,6 @@ works! You can call the ``app:sunshine`` command and start logging. work (e.g. making database queries), as that code will be run, even if you're using the console to execute a different command. -.. note:: - - In previous Symfony versions, you could make the command class extend from - :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand` to - get services via ``$this->getContainer()->get('SERVICE_ID')``. This is - deprecated in Symfony 4.2 and it won't work in future Symfony versions. - .. _console-command-service-lazy-loading: Lazy Loading diff --git a/console/style.rst b/console/style.rst index dd981436e50..c800e56f976 100644 --- a/console/style.rst +++ b/console/style.rst @@ -152,10 +152,6 @@ Content Methods ] ); - .. versionadded:: 4.4 - - The ``horizontalTable()`` method was introduced in Symfony 4.4. - :method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::definitionList` It displays the given ``key => value`` pairs as a compact list of elements:: @@ -169,10 +165,6 @@ Content Methods ['foo4' => 'bar4'] ); - .. versionadded:: 4.4 - - The ``definitionList()`` method was introduced in Symfony 4.4. - :method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::newLine` It displays a blank line in the command output. Although it may seem useful, most of the times you won't need it at all. The reason is that every helper diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index af09e4939e3..275db5125eb 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -173,39 +173,39 @@ 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:: 4.x`` +For a new feature or a behavior change use the ``.. versionadded:: 5.x`` directive: .. code-block:: rst - .. versionadded:: 4.2 + .. versionadded:: 5.2 - Named autowiring aliases have been introduced in Symfony 4.2. + ... ... ... was introduced in Symfony 5.2. If you are documenting a behavior change, it may be helpful to *briefly* describe how the behavior has changed: .. code-block:: rst - .. versionadded:: 4.2 + .. versionadded:: 5.2 - Support for ICU MessageFormat was introduced in Symfony 4.2. Prior to this, - pluralization was managed by the ``transChoice`` method. + ... ... ... was introduced in Symfony 5.2. Prior to this, + ... ... ... ... ... ... ... ... . -For a deprecation use the ``.. deprecated:: 4.x`` directive: +For a deprecation use the ``.. deprecated:: 5.x`` directive: .. code-block:: rst - .. deprecated:: 4.2 + .. deprecated:: 5.2 - Not passing the root node name to ``TreeBuilder`` was deprecated in Symfony 4.2. + ... ... ... was deprecated in Symfony 5.2. -Whenever a new major version of Symfony is released (e.g. 5.0, 6.0, etc), +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. At this point, all the ``versionadded`` and ``deprecated`` tags for Symfony versions that have a lower major version will be removed. For example, if -Symfony 5.0 were released today, 4.0 to 4.4 ``versionadded`` and ``deprecated`` -tags would be removed from the new ``5.0`` branch. +Symfony 6.0 were released today, 5.0 to 5.4 ``versionadded`` and ``deprecated`` +tags would be removed from the new ``6.0`` branch. .. _reStructuredText: http://docutils.sourceforge.net/rst.html .. _Sphinx: https://www.sphinx-doc.org/ diff --git a/controller/argument_value_resolver.rst b/controller/argument_value_resolver.rst index a32166778ee..e9f1def5906 100644 --- a/controller/argument_value_resolver.rst +++ b/controller/argument_value_resolver.rst @@ -53,17 +53,6 @@ In addition, some components and official bundles provide other value resolvers: the controller can be accessed by anonymous users. It requires installing the :doc:`Security component `. -:class:`Symfony\\Bundle\\SecurityBundle\\SecurityUserValueResolver` - Injects the object that represents the current logged in user if type-hinted - with ``UserInterface``. Default value can be set to ``null`` in case - the controller can be accessed by anonymous users. It requires installing - the `SecurityBundle`_. - -.. deprecated:: 4.1 - - The ``SecurityUserValueResolver`` was deprecated in Symfony 4.1 in favor of - :class:`Symfony\\Component\\Security\\Http\\Controller\\UserValueResolver`. - ``Psr7ServerRequestResolver`` Injects a `PSR-7`_ compliant version of the current request if type-hinted with ``RequestInterface``, ``MessageInterface`` or ``ServerRequestInterface``. @@ -260,6 +249,5 @@ sub-requests. .. _`@ParamConverter`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html .. _`yield`: http://php.net/manual/en/language.generators.syntax.php -.. _`SecurityBundle`: https://github.com/symfony/security-bundle .. _`PSR-7`: https://www.php-fig.org/psr/psr-7/ .. _`SensioFrameworkExtraBundle`: https://github.com/sensiolabs/SensioFrameworkExtraBundle diff --git a/controller/service.rst b/controller/service.rst index 18ee56ee707..77020bab590 100644 --- a/controller/service.rst +++ b/controller/service.rst @@ -178,12 +178,12 @@ Base Controller Methods and Their Service Replacements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The best way to see how to replace base ``Controller`` convenience methods is to -look at the `ControllerTrait`_ that holds its logic. +look at the `AbstractController`_ class that holds its logic. If you want to know what type-hints to use for each service, see the ``getSubscribedServices()`` method in `AbstractController`_. -.. _`Controller class source code`: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php -.. _`ControllerTrait`: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +.. _`Controller class source code`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php +.. _`AbstractController`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php .. _`AbstractController`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php .. _`ADR pattern`: https://en.wikipedia.org/wiki/Action%E2%80%93domain%E2%80%93responder diff --git a/controller/upload_file.rst b/controller/upload_file.rst index c98897ecf9c..e01558c3ca8 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -199,19 +199,13 @@ There are some important things to consider in the code of the above controller: users. This also applies to the files uploaded by your visitors. The ``UploadedFile`` class provides methods to get the original file extension (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getExtension`), - the original file size (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientSize`) + the original file size (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getSize`) and the original file name (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientOriginalName`). However, they are considered *not safe* because a malicious user could tamper that information. That's why it's always better to generate a unique name and use the :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::guessExtension` method to let Symfony guess the right extension according to the file MIME type; -.. deprecated:: 4.1 - - The :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientSize` - method was deprecated in Symfony 4.1 and will be removed in Symfony 5.0. - Use ``getSize()`` instead. - You can use the following code to link to the PDF brochure of a product: .. code-block:: html+twig diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 3b0d6a0338c..bb980079809 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -73,10 +73,6 @@ In this case, you'll need to - *very carefully* - trust *all* proxies. Request::HEADER_X_FORWARDED_AWS_ELB ); -.. versionadded:: 4.4 - - The support for the ``REMOTE_ADDR`` option was introduced in Symfony 4.4. - That's it! It's critical that you prevent traffic from all non-trusted sources. If you allow outside traffic, they could "spoof" their true IP address and other information. diff --git a/doctrine.rst b/doctrine.rst index 1e903b91427..696a6411c6d 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -488,10 +488,6 @@ doesn't replace the validation configuration entirely. You still need to add some :doc:`validation constraints ` to ensure that data provided by the user is correct. -.. versionadded:: 4.3 - - The automatic validation has been added in Symfony 4.3. - Fetching Objects from the Database ---------------------------------- diff --git a/doctrine/events.rst b/doctrine/events.rst index 6d376d027d6..7ecde04900e 100644 --- a/doctrine/events.rst +++ b/doctrine/events.rst @@ -330,10 +330,6 @@ with the ``doctrine.orm.entity_listener`` tag: ]) ; -.. versionadded:: 4.4 - - Support for invokable listeners (using the ``__invoke()`` method) was introduced in Symfony 4.4. - Doctrine Lifecycle Subscribers ------------------------------ diff --git a/event_dispatcher.rst b/event_dispatcher.rst index b7ff514d85f..5a20bb05dea 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -67,12 +67,6 @@ The most common way to listen to an event is to register an **event listener**:: Check out the :doc:`Symfony events reference ` to see what type of object each event provides. -.. versionadded:: 4.3 - - The :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent` class was - introduced in Symfony 4.3. In previous versions it was called - ``Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent``. - Now that the class is created, you need to register it as a service and notify Symfony that it is a "listener" on the ``kernel.exception`` event by using a special "tag": diff --git a/form/bootstrap4.rst b/form/bootstrap4.rst index 7c3a58bd8e6..71dbff9d0d6 100644 --- a/form/bootstrap4.rst +++ b/form/bootstrap4.rst @@ -91,10 +91,6 @@ for **all** users. Custom Forms ------------ -.. versionadded:: 4.4 - - Support for the ``switch-custom`` class was introduced in Symfony 4.4. - Bootstrap 4 has a feature called "`custom forms`_". You can enable that on your Symfony Form ``RadioType`` and ``CheckboxType`` by adding some classes to the label: diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index cc9ffe65df1..2d93199db15 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -415,12 +415,6 @@ libraries are used in your application: {% endfor %} {% endblock %} -.. note:: - - Symfony 4.2 deprecated calling ``FormRenderer::searchAndRenderBlock`` for - fields that have already been rendered. That's why the previous example - includes the ``... if not child.rendered`` statement. - The first part of the Twig block name (e.g. ``postal_address``) comes from the class name (``PostalAddressType`` -> ``postal_address``). This can be controlled by overriding the ``getBlockPrefix()`` method in ``PostalAddressType``. The diff --git a/form/data_transformers.rst b/form/data_transformers.rst index 589fedc053d..5aa92ec6210 100644 --- a/form/data_transformers.rst +++ b/form/data_transformers.rst @@ -326,10 +326,6 @@ end-user error message in the data transformer using the } } -.. versionadded:: 4.3 - - The ``setInvalidMessage()`` method was introduced in Symfony 4.3. - That's it! If you're using the :ref:`default services.yaml configuration `, Symfony will automatically know to pass your ``TaskType`` an instance of the diff --git a/form/form_customization.rst b/form/form_customization.rst index 3094eb08f40..ef5733b3146 100644 --- a/form/form_customization.rst +++ b/form/form_customization.rst @@ -315,10 +315,6 @@ spot (since it'll render the field for you). form_parent(form_view) ...................... -.. versionadded:: 4.3 - - The ``form_parent()`` function was introduced in Symfony 4.3. - Returns the parent form view or ``null`` if the form view already is the root form. Using this function should be preferred over accessing the parent form using ``form.parent``. The latter way will produce different results diff --git a/form/form_themes.rst b/form/form_themes.rst index 433154c48ca..70c357c47c9 100644 --- a/form/form_themes.rst +++ b/form/form_themes.rst @@ -297,10 +297,6 @@ field without having to :doc:`create a custom form type add('task', null, ['attr' => ['maxlength' => 4]]) -.. versionadded:: 4.3 +.. seealso:: - Starting from Symfony 4.3, :doc:`Doctrine ` metadata is introspected - to add :ref:`automatic validation constraints `. + Besides guessing the form type, Symfony also guesses :ref:`validation constraints ` + if you're using a Doctrine entity. Read :ref:`automatic_object_validation` + guide for more information. Unmapped Fields ~~~~~~~~~~~~~~~ diff --git a/http_cache.rst b/http_cache.rst index 18f4462e539..7a48728d2cd 100644 --- a/http_cache.rst +++ b/http_cache.rst @@ -167,11 +167,6 @@ cache efficiency of your routes. You can change the name of the header used for the trace information using the ``trace_header`` config option. -.. versionadded:: 4.3 - - The ``trace_level`` and ``trace_header`` configuration options - were introduced in Symfony 4.3. - .. _http-cache-symfony-versus-varnish: .. sidebar:: Changing from one Reverse Proxy to another diff --git a/logging.rst b/logging.rst index 633cd90ad8d..61471ec6bcb 100644 --- a/logging.rst +++ b/logging.rst @@ -343,11 +343,6 @@ any service whose class implements ``Psr\Log\LoggerAwareInterface`` will receive a call to its method ``setLogger()`` with the default logger service passed as a service. -.. versionadded:: 4.2 - - The automatic call to ``setLogger()`` when implementing ``LoggerAwareInterface`` - was introduced in Symfony 4.2. - If you want to use in your own services a pre-configured logger which uses a specific channel (``app`` by default), you can either :ref:`autowire monolog channels ` or use the ``monolog.logger`` tag with the ``channel`` property as explained in the diff --git a/logging/handlers.rst b/logging/handlers.rst index 1682040e504..9f5b903cfa9 100644 --- a/logging/handlers.rst +++ b/logging/handlers.rst @@ -4,10 +4,6 @@ Handlers ElasticsearchLogstashHandler ---------------------------- -.. versionadded:: 4.4 - - The ``ElasticsearchLogstashHandler`` was introduced in Symfony 4.4. - This handler deals directly with the HTTP interface of Elasticsearch. This means it will slow down your application if Elasticsearch takes times to answer. Even if all HTTP calls are done asynchronously. diff --git a/logging/processors.rst b/logging/processors.rst index f2b889461ec..bf0aeb854fe 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -180,11 +180,6 @@ Symfony's MonologBridge provides processors that can be registered inside your a :class:`Symfony\\Bridge\\Monolog\\Processor\\ConsoleCommandProcessor` Adds information about current console command. -.. versionadded:: 4.3 - - The ``RouteProcessor`` and the ``ConsoleCommandProcessor`` were introduced - in Symfony 4.3. - .. seealso:: Check out the `built-in Monolog processors`_ to learn more about how to diff --git a/mailer.rst b/mailer.rst index 59d5354ec36..d407a0568c6 100644 --- a/mailer.rst +++ b/mailer.rst @@ -1,11 +1,6 @@ Sending Emails with Mailer ========================== -.. versionadded:: 4.3 - - The Mailer component was introduced in Symfony 4.3. The previous solution, - called Swift Mailer, is still valid: :doc:`Swift Mailer`. - Installation ------------ @@ -281,18 +276,10 @@ transports, which is useful to debug errors. ID of the message (being the original random ID generated by Symfony or the new ID generated by the mailer provider). - .. versionadded:: 4.4 - - The ``getMessageId()`` method was introduced in Symfony 4.4. - The exceptions related to mailer transports (those which implement :class:`Symfony\\Component\\Mailer\\Exception\\TransportException`) also provide this debug information via the ``getDebug()`` method. -.. versionadded:: 4.4 - - The ``getDebug()`` methods were introduced in Symfony 4.4. - .. _mailer-twig: Twig: HTML & CSS @@ -565,10 +552,6 @@ directly from GitHub and save it in ``assets/css``. Signing and Encrypting Messages ------------------------------- -.. versionadded:: 4.4 - - The option to sign and/or encrypt messages was introduced in Symfony 4.4. - It's possible to sign and/or encrypt email messages applying the `S/MIME`_ standard to increase their integrity/security. Both options can be combined to encrypt a signed message and/or to sign an encrypted message. @@ -724,10 +707,6 @@ the transport to be handled later (see :ref:`messenger-worker`). Multiple Email Transports ------------------------- -.. versionadded:: 4.4 - - The option to define multiple email transports was introduced in Symfony 4.4. - You may want to use more than one mailer transport for delivery of your messages. This can be configured by replacing the ``dsn`` configuration entry with a ``transports`` entry, like: diff --git a/messenger.rst b/messenger.rst index 8afce615c1a..7287dff3ac7 100644 --- a/messenger.rst +++ b/messenger.rst @@ -450,11 +450,6 @@ You can do this with the ``messenger:consume`` command: # use -vv to see details about what's happening $ php bin/console messenger:consume async -vv -.. versionadded:: 4.3 - - The ``messenger:consume`` command was renamed in Symfony 4.3 (previously it - was called ``messenger:consume-messages``). - The first argument is the receiver's name (or service id if you routed to a custom service). By default, the command will run forever: looking for new messages on your transport and handling them. This command is called your "worker". @@ -782,10 +777,6 @@ your Envelope:: Doctrine Transport ~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The Doctrine transport was introduced in Symfony 4.3. - The Doctrine transport can be used to store messages in a database table. .. code-block:: bash @@ -888,10 +879,6 @@ auto_setup Whether the table should be created Redis Transport ~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The Redis transport was introduced in Symfony 4.3. - The Redis transport uses `streams`_ to queue messages. .. code-block:: bash @@ -900,10 +887,12 @@ The Redis transport uses `streams`_ to queue messages. MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages # Full DSN Example MESSENGER_TRANSPORT_DSN=redis://password@localhost:6379/messages/symfony/consumer?auto_setup=true&serializer=1&stream_max_entries=0&dbindex=0 + # Unix Socket Example + MESSENGER_TRANSPORT_DSN=redis:///var/run/redis.sock -.. versionadded:: 4.4 +.. versionadded:: 5.1 - The ``dbindex`` query parameter in Redis DSN was introduced in Symfony 4.4. + The Unix socket DSN was introduced in Symfony 5.1. To use the Redis transport, you will need the Redis PHP extension (>=4.3) and a running Redis server (^5.0). @@ -926,20 +915,13 @@ stream_max_entries The maximum number of entries which ``0`` (which means "n the stream will be trimmed to. Set it to a large enough number to avoid losing pending messages +tls Enable TLS support for the connection false ================== ===================================== ========================= -.. versionadded:: 4.4 - - The ``stream_max_entries`` option was introduced in Symfony 4.4. - In Memory Transport ~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The ``in-memory`` transport was introduced in Symfony 4.3. - -The ``in-memory`` transport does not actually deliver messages. Instead, it +The ``in-memory`` transport does not actually delivery messages. Instead, it holds them in memory during the request, which can be useful for testing. For example, if you have an ``async_priority_normal`` transport, you could override it in the ``test`` environment to use this transport: @@ -987,13 +969,6 @@ during a request:: Serializing Messages ~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The default serializer changed in 4.3 from the Symfony serializer to the - native PHP serializer. Existing applications should configure their transports - to use the Symfony serializer to avoid losing already-queued messages after - upgrading. - When messages are sent to (and received from) a transport, they're serialized using PHP's native ``serialize()`` & ``unserialize()`` functions. You can change this globally (or for each transport) to a service that implements @@ -1090,10 +1065,6 @@ Possible options to configure with tags are: * ``method`` * ``priority`` -.. versionadded:: 4.4 - - The ability to specify ``from_transport`` on the tag, was added in Symfony 4.4. - Handler Subscriber & Options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/performance.rst b/performance.rst index d5614320545..51d2d83f230 100644 --- a/performance.rst +++ b/performance.rst @@ -39,11 +39,6 @@ features, such as the APCu Cache adapter. Dump the Service Container into a Single File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - The ``container.dumper.inline_factories`` parameter was introduced in - Symfony 4.4. - Symfony compiles the :doc:`service container ` into multiple small files by default. Set this parameter to ``true`` to compile the entire container into a single file, which could improve performance when using @@ -94,10 +89,6 @@ used byte code cache is `APC`_. Use the OPcache class preloading ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - The feature that generates the preloading file was introduced in Symfony 4.4. - Starting from PHP 7.4, OPcache can compile and load classes at start-up and make them available to all requests until the server is restarted, improving performance significantly. diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index b412f8ebb4f..11672d517d6 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -221,16 +221,6 @@ Configuration * `storage_id`_ * `use_cookies`_ -* `templating`_ - - * :ref:`cache ` - * `engines`_ - * :ref:`form ` - - * :ref:`resources ` - - * `loaders`_ - * `test`_ * `translator`_ @@ -260,7 +250,6 @@ Configuration * `endpoint`_ * `static_method`_ - * `strict_email`_ * `translation_domain`_ * `workflows`_ @@ -464,10 +453,6 @@ disallow_search_engine_index **type**: ``boolean`` **default**: ``true`` when the debug mode is enabled, ``false`` otherwise. -.. versionadded:: 4.3 - - The ``disallow_search_engine_index`` option was introduced in Symfony 4.3. - If ``true``, Symfony adds a ``X-Robots-Tag: noindex`` HTTP tag to all responses (unless your own app adds that header, in which case it's not modified). This `X-Robots-Tag HTTP header`_ tells search engines to not index your web site. @@ -604,10 +589,6 @@ error_controller **type**: ``string`` **default**: ``error_controller`` -.. versionadded:: 4.4 - - The ``error_controller`` option was introduced in Symfony 4.4. - This is the controller that is called when an exception is thrown anywhere in your application. The default controller (:class:`Symfony\\Component\\HttpKernel\\Controller\\ErrorController`) @@ -689,12 +670,6 @@ hinclude_default_template **type**: ``string`` **default**: ``null`` -.. versionadded:: 4.3 - - The ``framework.fragments.hinclude_default_template`` option was introduced - in Symfony 4.3. In previous Symfony versions it was defined under - ``framework.templating.hinclude_default_template``. - Sets the content shown during the loading of the fragment or when JavaScript is disabled. This can be either a template name or the content itself. @@ -786,10 +761,6 @@ auth_ntlm **type**: ``string`` -.. versionadded:: 4.4 - - The ``auth_ntlm`` option was introduced in Symfony 4.4. - The username and password used to create the ``Authorization`` HTTP header used in the `Microsoft NTLM authentication protocol`_. The value of this option must follow the format ``username:password``. This authentication mechanism requires @@ -840,10 +811,6 @@ If this option is a boolean value, the response is buffered when the value is returned value is ``true`` (the closure receives as argument an array with the response headers). -.. versionadded:: 4.4 - - The support of ``Closure`` in the ``buffer`` option was introduced in Symfony 4.4. - cafile ...... @@ -1004,10 +971,6 @@ max_duration The maximum execution time, in seconds, that the request and the response are allowed to take. A value lower than or equal to 0 means it is unlimited. -.. versionadded:: 4.4 - - The ``max_duration`` option was introduced in Symfony 4.4. - verify_host ........... @@ -1209,6 +1172,11 @@ utf8 **type**: ``boolean`` **default**: ``false`` +.. deprecated:: 5.1 + + Not setting this option is deprecated since Symfony 5.1. Moreover, the + default value of this option will change to ``true`` in Symfony 6.0. + When this option is set to ``true``, the regular expressions used in the :ref:`requirements of route parameters ` will be run using the `utf-8 modifier`_. This will for example match any UTF-8 character @@ -1331,7 +1299,7 @@ to the cookie specification. cookie_samesite ............... -**type**: ``string`` or ``null`` **default**: ``null`` +**type**: ``string`` or ``null`` **default**: ``'lax'`` It controls the way cookies are sent when the HTTP request was not originated from the same domain the cookies are associated to. Setting this option is @@ -1362,10 +1330,10 @@ The possible values for this option are: cookie_secure ............. -**type**: ``boolean`` or ``string`` **default**: ``false`` +**type**: ``boolean`` or ``null`` **default**: ``null`` This determines whether cookies should only be sent over secure connections. In -addition to ``true`` and ``false``, there's a special ``'auto'`` value that +addition to ``true`` and ``false``, there's a special ``null`` value that means ``true`` for HTTPS requests and ``false`` for HTTP requests. cookie_httponly @@ -2001,127 +1969,6 @@ package: If you request an asset that is *not found* in the ``manifest.json`` file, the original - *unmodified* - asset path will be returned. -templating -~~~~~~~~~~ - -.. deprecated:: 4.3 - - The integration of the Templating component in FrameworkBundle has been - deprecated since version 4.3 and will be removed in 5.0. That's why all the - configuration options defined under ``framework.templating`` are deprecated too. - -.. _reference-templating-form: - -form -.... - -.. _reference-templating-form-resources: - -resources -""""""""" - -**type**: ``string[]`` **default**: ``['FrameworkBundle:Form']`` - -.. deprecated:: 4.3 - - The integration of the Templating component in FrameworkBundle has been - deprecated since version 4.3 and will be removed in 5.0. Form theming with - PHP templates will no longer be supported and you'll need to use Twig instead. - -A list of all resources for form theming in PHP. This setting is not required -if you're :ref:`using the Twig format for your themes `. - -Assume you have custom global form themes in ``templates/form_themes/``, you can -configure this like: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - templating: - form: - resources: - - 'form_themes' - - .. code-block:: xml - - - - - - - - - form_themes - - - - - - .. code-block:: php - - // config/packages/framework.php - $container->loadFromExtension('framework', [ - 'templating' => [ - 'form' => [ - 'resources' => [ - 'form_themes', - ], - ], - ], - ]); - -.. note:: - - The default form templates from ``FrameworkBundle:Form`` will always - be included in the form resources. - -.. seealso:: - - See :ref:`forms-theming-global` for more information. - -.. _reference-templating-cache: - -cache -..... - -**type**: ``string`` - -The path to the cache directory for templates. When this is not set, caching -is disabled. - -.. note:: - - When using Twig templating, the caching is already handled by the - TwigBundle and doesn't need to be enabled for the FrameworkBundle. - -engines -....... - -**type**: ``string[]`` / ``string`` **required** - -The Templating Engine to use. This can either be a string (when only one -engine is configured) or an array of engines. - -At least one engine is required. - -loaders -....... - -**type**: ``string[]`` - -An array (or a string when configuring just one loader) of service ids for -templating loaders. Templating loaders are used to find and load templates -from a resource (e.g. a filesystem or database). Templating loaders must -implement :class:`Symfony\\Component\\Templating\\Loader\\LoaderInterface`. - translator ~~~~~~~~~~ @@ -2130,10 +1977,6 @@ cache_dir **type**: ``string`` | ``null`` **default**: ``%kernel.cache_dir%/translations/`` -.. versionadded:: 4.4 - - The ``cache_dir`` option was introduced in Symfony 4.4. - Defines the directory where the translation cache is stored. Use ``null`` to disable this cache. @@ -2151,7 +1994,7 @@ Whether or not to enable the ``translator`` service in the service container. fallbacks ......... -**type**: ``string|array`` **default**: ``['en']`` +**type**: ``string|array`` **default**: value of `default_locale`_ This option is used when the translation key for the current locale wasn't found. @@ -2227,10 +2070,6 @@ throw_exception_on_invalid_property_path **type**: ``boolean`` **default**: ``true`` -.. versionadded:: 4.3 - - The ``throw_exception_on_invalid_property_path`` option was introduced in Symfony 4.3. - When enabled, the ``property_accessor`` service throws an exception when you try to access an invalid property path of an object. @@ -2305,10 +2144,6 @@ enabled **type**: ``boolean`` **default**: ``true`` -.. versionadded:: 4.3 - - The ``enabled`` option was introduced in Symfony 4.3. - If you set this option to ``false``, no HTTP requests will be made and the given password will be considered valid. This is useful when you don't want or can't make HTTP requests, such as in ``dev`` and ``test`` environments or in @@ -2319,10 +2154,6 @@ endpoint **type**: ``string`` **default**: ``null`` -.. versionadded:: 4.3 - - The ``endpoint`` option was introduced in Symfony 4.3. - By default, the :doc:`NotCompromisedPassword ` constraint uses the public API provided by `haveibeenpwned.com`_. This option allows to define a different, but compatible, API endpoint to make the password @@ -2339,20 +2170,6 @@ metadata of the class. You can define an array of strings with the names of several methods. In that case, all of them will be called in that order to load the metadata. -strict_email -............ - -**type**: ``Boolean`` **default**: ``false`` - -.. deprecated:: 4.1 - - The ``strict_email`` option was deprecated in Symfony 4.1. Use the new - ``email_validation_mode`` option instead. - -If this option is enabled, the `egulias/email-validator`_ library will be -used by the :doc:`/reference/constraints/Email` constraint validator. Otherwise, -the validator uses a simple regular expression to validate email addresses. - email_validation_mode ..................... @@ -2911,10 +2728,6 @@ A list of lock stores to be created by the framework extension. ], ]); -.. versionadded:: 4.2 - - The ``flock://`` store was introduced in Symfony 4.2. - .. _reference-lock-resources-name: name diff --git a/reference/configuration/kernel.rst b/reference/configuration/kernel.rst index 5852927e7ad..5f52cd155e7 100644 --- a/reference/configuration/kernel.rst +++ b/reference/configuration/kernel.rst @@ -12,12 +12,17 @@ Configuration ------------- * `Charset`_ -* `Kernel Name`_ * `Project Directory`_ * `Cache Directory`_ * `Log Directory`_ * `Container Build Time`_ +In previous Symfony versions there was another configuration option to define +the "kernel name", which is only important when +:doc:`using applications with multiple kernels `. +If you need a unique ID for your kernels use the ``kernel.container_class`` +parameter or the ``Kernel::getContainerClass()`` method. + .. _configuration-kernel-charset: Charset @@ -44,29 +49,6 @@ charset:: } } -Kernel Name -~~~~~~~~~~~ - -**type**: ``string`` **default**: ``src`` (i.e. the directory name holding -the kernel class) - -.. deprecated:: 4.2 - - The ``kernel.name`` parameter and the ``Kernel::getName()`` method were - deprecated in Symfony 4.2. If you need a unique ID for your kernels use the - ``kernel.container_class`` parameter or the ``Kernel::getContainerClass()`` method. - -The name of the kernel isn't usually directly important - it's used in the -generation of cache files - and you probably will only change it when -:doc:`using applications with multiple kernels `. - -This value is exposed via the ``kernel.name`` configuration parameter and the -:method:`Symfony\\Component\\HttpKernel\\Kernel::getName` method. - -To change this setting, override the ``getName()`` method. Alternatively, move -your kernel into a different directory. For example, if you moved the kernel -into a ``foo/`` directory (instead of ``src/``), the kernel name will be ``foo``. - .. _configuration-kernel-project-directory: Project Directory @@ -121,11 +103,6 @@ Log Directory **type**: ``string`` **default**: ``$this->getProjectDir()/var/log`` -.. deprecated:: 4.2 - - The ``kernel.log_dir`` parameter was deprecated in Symfony 4.2, - use ``kernel.logs_dir`` instead. - This returns the absolute path of the log directory of your Symfony project. It's calculated automatically based on the current :ref:`environment `. diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index 5fbadd50a0c..de881abfc3a 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -145,7 +145,6 @@ encoding algorithm. Also, each algorithm defines different config options: algorithm: 'sodium' memory_cost: 16384 # Amount in KiB. (16384 = 16 MiB) time_cost: 2 # Number of iterations - threads: 4 # Number of parallel threads # MessageDigestPasswordEncoder encoder using SHA512 hashing with default options AppBundle\Entity\User: 'sha512' @@ -183,14 +182,12 @@ encoding algorithm. Also, each algorithm defines different config options: + time_cost: number of iterations --> @@ -230,7 +227,6 @@ encoding algorithm. Also, each algorithm defines different config options: 'algorithm' => 'sodium', 'memory_cost' => 16384, // Amount in KiB. (16384 = 16 MiB) 'time_cost' => 2, // Number of iterations - 'threads' => 4, // Number of parallel threads ], // MessageDigestPasswordEncoder encoder using SHA512 hashing with default options @@ -240,17 +236,6 @@ encoding algorithm. Also, each algorithm defines different config options: ], ]); -.. deprecated:: 4.3 - - The ``threads`` configuration option was deprecated in Symfony 4.3. No - alternative is provided because starting from Symfony 5.0 this value will be - hardcoded to ``1`` (one thread). - -.. versionadded:: 4.3 - - The ``sodium`` algorithm was introduced in Symfony 4.3. In previous Symfony - versions it was called ``argon2i``. - .. tip:: You can also create your own password encoders as services and you can even @@ -263,11 +248,6 @@ encoding algorithm. Also, each algorithm defines different config options: Using the Sodium Password Encoder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The ``SodiumPasswordEncoder`` was introduced in Symfony 4.3. In previous - Symfony versions it was called ``Argon2iPasswordEncoder``. - It uses the `Argon2 key derivation function`_ and it's the encoder 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. @@ -544,25 +524,6 @@ The ``invalidate_session`` option allows to redefine this behavior. Set this option to ``false`` in every firewall and the user will only be logged out from the current firewall and not the other ones. -logout_on_user_change -~~~~~~~~~~~~~~~~~~~~~ - -**type**: ``boolean`` **default**: ``true`` - -.. deprecated:: 4.1 - - The ``logout_on_user_change`` option was deprecated in Symfony 4.1. - -If ``false`` this option makes Symfony to not trigger a logout when the user has -changed. Doing that is deprecated, so this option should set to ``true`` or -unset to avoid getting deprecation messages. - -The user is considered to have changed when the user class implements -:class:`Symfony\\Component\\Security\\Core\\User\\EquatableInterface` and the -``isEqualTo()`` method returns ``false``. Also, when any of the properties -required by the :class:`Symfony\\Component\\Security\\Core\\User\\UserInterface` -(like the username, password or salt) changes. - success_handler ~~~~~~~~~~~~~~~ diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 7c6add6ca60..7f83f0929a8 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -42,7 +42,6 @@ Configuration * `debug`_ * `default_path`_ -* `exception_controller`_ * `form_themes`_ * `globals`_ * `number_format`_ @@ -196,29 +195,6 @@ The path to the directory where Symfony will look for the application Twig templates by default. If you store the templates in more than one directory, use the :ref:`paths ` option too. -.. _config-twig-exception-controller: - -exception_controller -~~~~~~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``twig.controller.exception:showAction`` - -.. deprecated:: 4.4 - - The ``exception_controller`` configuration option was deprecated in Symfony 4.4. - Set it to ``null`` and use the new ``error_controller`` option under ``framework`` - configuration instead. - -This is the controller that is activated after an exception is thrown anywhere -in your application. The default controller -(:class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`) -is what's responsible for rendering specific templates under different error -conditions (see :doc:`/controller/error_pages`). Modifying this -option is advanced. If you need to customize an error page you should use -the previous link. If you need to perform some behavior on an exception, -you should add an :doc:`event listener ` to the -:ref:`kernel.exception event `. - .. _config-twig-form-themes: form_themes diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst index e12aacbaf63..c65d3223110 100644 --- a/reference/constraints/Bic.rst +++ b/reference/constraints/Bic.rst @@ -92,10 +92,6 @@ iban **type**: ``string`` **default**: ``null`` -.. versionadded:: 4.3 - - The ``iban`` option was introduced in Symfony 4.3. - An IBAN value to validate that the BIC is associated with it. ibanMessage @@ -103,10 +99,6 @@ ibanMessage **type**: ``string`` **default**: ``This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.`` -.. versionadded:: 4.3 - - The ``ibanMessage`` option was introduced in Symfony 4.3. - The default message supplied when the value does not pass the combined BIC/IBAN check. ibanPropertyPath @@ -114,10 +106,6 @@ ibanPropertyPath **type**: ``string`` **default**: ``null`` -.. versionadded:: 4.3 - - The ``ibanPropertyPath`` option was introduced in Symfony 4.3. - It defines the object property whose value stores the IBAN used to check the BIC with. For example, if you want to compare the ``$bic`` property of some object diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 6362d9932ee..6adfe62d893 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -138,10 +138,6 @@ Valid values are: * ``UATP`` * ``VISA`` -.. versionadded:: 4.3 - - The ``UATP`` and ``MIR`` number schemes were introduced in Symfony 4.3. - For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_. diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 7cc8ae3ac1f..25feac3506e 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -322,10 +322,6 @@ Parameter Description ``{{ value }}`` The current (invalid) value ================= ============================================================ -.. versionadded:: 4.3 - - The ``{{ choices }}`` parameter was introduced in Symfony 4.3. - message ~~~~~~~ @@ -370,10 +366,6 @@ Parameter Description ``{{ value }}`` The current (invalid) value ================= ============================================================ -.. versionadded:: 4.3 - - The ``{{ choices }}`` parameter was introduced in Symfony 4.3. - multiple ~~~~~~~~ diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 8b68f59bea2..7621a379f72 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -6,9 +6,7 @@ cast to a string before being validated. ========== =================================================================== Applies to :ref:`property or method ` -Options - `checkHost`_ - - `checkMX`_ - - `groups`_ +Options - `groups`_ - `message`_ - `mode`_ - `normalizer`_ @@ -33,8 +31,7 @@ Basic Usage { /** * @Assert\Email( - * message = "The email '{{ value }}' is not a valid email.", - * checkMX = true + * message = "The email '{{ value }}' is not a valid email." * ) */ protected $email; @@ -48,7 +45,6 @@ Basic Usage email: - Email: message: The email "{{ value }}" is not a valid email. - checkMX: true .. code-block:: xml @@ -62,7 +58,6 @@ Basic Usage - @@ -82,7 +77,6 @@ Basic Usage { $metadata->addPropertyConstraint('email', new Assert\Email([ 'message' => 'The email "{{ value }}" is not a valid email.', - 'checkMX' => true, ])); } } @@ -92,36 +86,6 @@ Basic Usage Options ------- -checkHost -~~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.2 - - This option was deprecated in Symfony 4.2. - -If true, then the :phpfunction:`checkdnsrr` PHP function will be used to -check the validity of the MX *or* the A *or* the AAAA record of the host -of the given email. - -checkMX -~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.2 - - This option was deprecated in Symfony 4.2. - -If true, then the :phpfunction:`checkdnsrr` PHP function will be used to -check the validity of the MX record of the host of the given email. - -.. caution:: - - This option is not reliable because it depends on the network conditions - and some valid servers refuse to respond to those requests. - .. include:: /reference/constraints/_groups-option.rst.inc message diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index f1171a5c82d..3fffe9f13a5 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -252,10 +252,6 @@ You can find a list of existing mime types on the `IANA website`_. (i.e. the form type is not defined explicitly in the ``->add()`` method of the form builder) and when the field doesn't define its own ``accept`` value. - .. versionadded:: 4.4 - - This feature was introduced in Symfony 4.4. - mimeTypesMessage ~~~~~~~~~~~~~~~~ diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index b27f43ffbf1..4b6e5915967 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -113,16 +113,11 @@ Options allowEmptyString ~~~~~~~~~~~~~~~~ -**type**: ``boolean`` **default**: ``true`` +**type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.4 - - The ``allowEmptyString`` option was introduced in Symfony 4.4. - -When using the ``min`` option, it's mandatory to also define this option. If -set to ``true``, empty strings are considered valid (which is the same behavior -as previous Symfony versions). Set it to ``false`` to consider empty strings not -valid. +If set to ``true``, empty strings are considered valid (which is the same +behavior as previous Symfony versions). The default ``false`` value considers +empty strings not valid. charset ~~~~~~~ diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index d7f16293b3a..dbdf0905df5 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -8,10 +8,13 @@ the two letter `ISO 639-1`_ *language* code (e.g. ``fr``), or the language code followed by an underscore (``_``) and the `ISO 3166-1 alpha-2`_ *country* code (e.g. ``fr_FR`` for French/France). +The given locale values are *canonicalized* before validating them to avoid +issues with wrong uppercase/lowercase values and to remove unneeded elements +(e.g. ``FR-fr.utf8`` will be validated as ``fr_FR``). + ========== =================================================================== Applies to :ref:`property or method ` -Options - `canonicalize`_ - - `groups`_ +Options - `groups`_ - `message`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Locale` @@ -89,19 +92,6 @@ Basic Usage Options ------- -canonicalize -~~~~~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.1 - - Using this option with value ``false`` was deprecated in Symfony 4.1 and it - will throw an exception in Symfony 5.0. Use ``true`` instead. - -If ``true``, the :phpmethod:`Locale::canonicalize` method will be applied before checking -the validity of the given locale (e.g. ``FR-fr.utf8`` is transformed into ``fr_FR``). - .. include:: /reference/constraints/_groups-option.rst.inc ``message`` diff --git a/reference/constraints/Negative.rst b/reference/constraints/Negative.rst index 4e3edee87f2..7468b4bfc4a 100644 --- a/reference/constraints/Negative.rst +++ b/reference/constraints/Negative.rst @@ -1,10 +1,6 @@ Negative ======== -.. versionadded:: 4.3 - - The ``Negative`` constraint was introduced in Symfony 4.3. - Validates that a value is a negative number. Zero is neither positive nor negative, so you must use :doc:`/reference/constraints/NegativeOrZero` if you want to allow zero as value. diff --git a/reference/constraints/NegativeOrZero.rst b/reference/constraints/NegativeOrZero.rst index 5a77a36ab67..f010acda0b1 100644 --- a/reference/constraints/NegativeOrZero.rst +++ b/reference/constraints/NegativeOrZero.rst @@ -1,10 +1,6 @@ NegativeOrZero ============== -.. versionadded:: 4.3 - - The ``NegativeOrZero`` constraint was introduced in Symfony 4.3. - Validates that a value is a negative number or equal to zero. If you don't want to allow zero as value, use :doc:`/reference/constraints/Negative` instead. diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 19ac9542ec9..c3c16f21eae 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -90,10 +90,6 @@ allowNull If set to ``true``, ``null`` values are considered valid and won't trigger a constraint violation. -.. versionadded:: 4.3 - - The ``allowNull`` option was introduced in Symfony 4.3. - .. include:: /reference/constraints/_groups-option.rst.inc ``message`` diff --git a/reference/constraints/NotCompromisedPassword.rst b/reference/constraints/NotCompromisedPassword.rst index ffa9fe99d8d..6d2cb52f1aa 100644 --- a/reference/constraints/NotCompromisedPassword.rst +++ b/reference/constraints/NotCompromisedPassword.rst @@ -1,10 +1,6 @@ NotCompromisedPassword ====================== -.. versionadded:: 4.3 - - The ``NotCompromisedPassword`` constraint was introduced in Symfony 4.3. - Validates that the given password has not been compromised by checking that it is not included in any of the public data breaches tracked by `haveibeenpwned.com`_. diff --git a/reference/constraints/Positive.rst b/reference/constraints/Positive.rst index bfed77a763c..af76f205e53 100644 --- a/reference/constraints/Positive.rst +++ b/reference/constraints/Positive.rst @@ -1,10 +1,6 @@ Positive ======== -.. versionadded:: 4.3 - - The ``Positive`` constraint was introduced in Symfony 4.3. - Validates that a value is a positive number. Zero is neither positive nor negative, so you must use :doc:`/reference/constraints/PositiveOrZero` if you want to allow zero as value. diff --git a/reference/constraints/PositiveOrZero.rst b/reference/constraints/PositiveOrZero.rst index cc592f824c6..ea762e78f90 100644 --- a/reference/constraints/PositiveOrZero.rst +++ b/reference/constraints/PositiveOrZero.rst @@ -1,10 +1,6 @@ PositiveOrZero ============== -.. versionadded:: 4.3 - - The ``PositiveOrZero`` constraint was introduced in Symfony 4.3. - Validates that a value is a positive number or equal to zero. If you don't want to allow zero as value, use :doc:`/reference/constraints/Positive` instead. diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 1d2ee4d077f..0b05ebaaa0f 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -366,11 +366,7 @@ maxPropertyPath **type**: ``string`` -.. versionadded:: 4.4 - - The ``maxPropertyPath`` option was introduced in Symfony 4.4. - -It defines the object property whose value is used as `max`_ option. +It defines the object property whose value is used as ``max`` option. For example, if you want to compare the ``$submittedDate`` property of some object with regard to the ``$deadline`` property of the same object, use @@ -413,11 +409,7 @@ minPropertyPath **type**: ``string`` -.. versionadded:: 4.4 - - The ``minPropertyPath`` option was introduced in Symfony 4.4. - -It defines the object property whose value is used as `min`_ option. +It defines the object property whose value is used as ``min`` option. For example, if you want to compare the ``$endDate`` property of some object with regard to the ``$startDate`` property of the same object, use @@ -435,10 +427,6 @@ notInRangeMessage **type**: ``string`` **default**: ``This value should be between {{ min }} and {{ max }}.`` -.. versionadded:: 4.4 - - The ``notInRangeMessage`` option was introduced in Symfony 4.4. - The message that will be shown if the underlying value is less than the `min`_ option or greater than the `max`_ option. diff --git a/reference/constraints/Timezone.rst b/reference/constraints/Timezone.rst index c5f27e1cbfb..045c258bda4 100644 --- a/reference/constraints/Timezone.rst +++ b/reference/constraints/Timezone.rst @@ -1,10 +1,6 @@ Timezone ======== -.. versionadded:: 4.3 - - The ``Timezone`` constraint was introduced in Symfony 4.3. - Validates that a value is a valid timezone identifier (e.g. ``Europe/Paris``). ========== ====================================================================== diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index dfe96f8655e..31cd0075b13 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -143,11 +143,6 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``, } } -.. versionadded:: 4.4 - - The feature to define multiple types in the ``type`` option was introduced - in Symfony 4.4. - Options ------- @@ -178,11 +173,6 @@ type **type**: ``string`` or ``array`` [:ref:`default option `] -.. versionadded:: 4.4 - - The feature to define multiple types in the ``type`` option was introduced - in Symfony 4.4. - This required option defines the type or collection of types allowed for the given value. Each type is either the FQCN (fully qualified class name) of some PHP class/interface or a valid PHP datatype (checked by PHP's ``is_()`` functions): diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 4c9885d0147..fdc58880797 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -5,9 +5,7 @@ Validates that a value is a valid URL string. ========== =================================================================== Applies to :ref:`property or method ` -Options - `checkDNS`_ - - `dnsMessage`_ - - `groups`_ +Options - `groups`_ - `message`_ - `normalizer`_ - `payload`_ @@ -76,170 +74,15 @@ Basic Usage } } +This constraint doesn't check that the host of the given URL really exists, +because the information of the DNS records is not reliable. Use the +:phpfunction:`checkdnsrr` PHP function if you still want to check that. + .. include:: /reference/constraints/_empty-values-are-valid.rst.inc Options ------- -checkDNS -~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.1 - - This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, - because checking the DNS records is not reliable enough to validate the - existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you - still want to use this kind of validation. - -By default, this constraint just validates the syntax of the given URL. If you -also need to check whether the associated host exists, set the ``checkDNS`` -option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the -:class:`Symfony\\Component\\Validator\\Constraints\\Url` class: - -.. configuration-block:: - - .. code-block:: php-annotations - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - - class Author - { - /** - * @Assert\Url( - * checkDNS = "ANY" - * ) - */ - protected $bioUrl; - } - - .. code-block:: yaml - - # config/validator/validation.yaml - App\Entity\Author: - properties: - bioUrl: - - Url: { checkDNS: 'ANY' } - - .. code-block:: xml - - - - - - - - - - - - - - - .. code-block:: php - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - use Symfony\Component\Validator\Mapping\ClassMetadata; - - class Author - { - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'checkDNS' => Assert\Url::CHECK_DNS_TYPE_ANY, - ])); - } - } - -This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity -of the DNS record corresponding to the host associated with the given URL. - -dnsMessage -~~~~~~~~~~ - -**type**: ``string`` **default**: ``The host could not be resolved.`` - -.. deprecated:: 4.1 - - This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, - because checking the DNS records is not reliable enough to validate the - existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you - still want to use this kind of validation. - -This message is shown when the ``checkDNS`` option is set to ``true`` and the -DNS check failed. - -.. configuration-block:: - - .. code-block:: php-annotations - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - - class Author - { - /** - * @Assert\Url( - * dnsMessage = "The host '{{ value }}' could not be resolved." - * ) - */ - protected $bioUrl; - } - - .. code-block:: yaml - - # config/validator/validation.yaml - App\Entity\Author: - properties: - bioUrl: - - Url: { dnsMessage: 'The host "{{ value }}" could not be resolved.' } - - .. code-block:: xml - - - - - - - - - - - - - - - .. code-block:: php - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - use Symfony\Component\Validator\Mapping\ClassMetadata; - - class Author - { - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'dnsMessage' => 'The host "{{ value }}" could not be resolved.', - ])); - } - } - .. include:: /reference/constraints/_groups-option.rst.inc message diff --git a/reference/constraints/_comparison-propertypath-option.rst.inc b/reference/constraints/_comparison-propertypath-option.rst.inc index 0491d7dea1f..35f0da4d189 100644 --- a/reference/constraints/_comparison-propertypath-option.rst.inc +++ b/reference/constraints/_comparison-propertypath-option.rst.inc @@ -15,7 +15,3 @@ with regard to the ``$startDate`` property of the same object, use ``{{ compared_value_path }}`` placeholder. Although it's not intended to include it in the error messages displayed to end users, it's useful when using APIs for doing any mapping logic on client-side. - - .. versionadded:: 4.4 - - The ``{{ compared_value_path }}`` placeholder was introduced in Symfony 4.4. diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 7e1f2748fe2..e9bbdce76bc 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -38,7 +38,6 @@ Tag Name Usage `serializer.encoder`_ Register a new encoder in the ``serializer`` service `serializer.normalizer`_ Register a new normalizer in the ``serializer`` service `swiftmailer.default.plugin`_ Register a custom SwiftMailer Plugin -`templating.helper`_ Make your service available in PHP templates `translation.loader`_ Register a custom service that loads translations `translation.extractor`_ Register a custom service that extracts translation messages from a file `translation.dumper`_ Register a custom service that dumps translation messages @@ -496,10 +495,6 @@ This tag is used to register your own :ref:`MIME type guessers ` don't fit your needs. -.. versionadded:: 4.3 - - The ``mime.mime_type_guesser`` tag was introduced in Symfony 4.3. - .. _dic_tags-monolog: monolog.logger @@ -822,53 +817,6 @@ For more information on plugins, see `SwiftMailer's Plugin Documentation`_. Several SwiftMailer plugins are core to Symfony and can be activated via different configuration. For details, see :doc:`/reference/configuration/swiftmailer`. -templating.helper ------------------ - -**Purpose**: Make your service available in PHP templates - -.. deprecated:: 4.3 - - The ``templating.helper`` tag is deprecated since version 4.3 and will be - removed in 5.0; use Twig instead. - -To enable a custom template helper, add it as a regular service in one -of your configuration, tag it with ``templating.helper`` and define an -``alias`` attribute (the helper will be accessible via this alias in the -templates): - -.. configuration-block:: - - .. code-block:: yaml - - services: - App\Templating\AppHelper: - tags: - - { name: templating.helper, alias: alias_name } - - .. code-block:: xml - - - - - - - - - - - - .. code-block:: php - - use App\Templating\AppHelper; - - $container->register(AppHelper::class) - ->addTag('templating.helper', ['alias' => 'alias_name']) - ; - .. _dic-tags-translation-loader: translation.loader diff --git a/reference/forms/types/button.rst b/reference/forms/types/button.rst index 20ae46ca6d4..b7d81868089 100644 --- a/reference/forms/types/button.rst +++ b/reference/forms/types/button.rst @@ -60,10 +60,6 @@ label_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``label_translation_parameters`` option was introduced in Symfony 4.3. - The content of the `label`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This option defines the values used to replace those placeholders. diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index dee6827a0ca..bbda2b3ec46 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -68,10 +68,6 @@ alpha3 **type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.4 - - The ``alpha3`` option was introduced in Symfony 4.4. - If this option is ``true``, the choice values use the `ISO 3166-1 alpha-3`_ three-letter codes (e.g. New Zealand = ``NZL``) instead of the default `ISO 3166-1 alpha-2`_ two-letter codes (e.g. New Zealand = ``NZ``). diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index b2ff999fd28..c6df697f7aa 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -173,11 +173,6 @@ values for the year, month and day fields:: .. include:: /reference/forms/types/options/date_format.rst.inc -.. deprecated:: 4.3 - - Using the ``format`` option when the ``html5`` option is enabled is deprecated - since Symfony 4.3. - .. include:: /reference/forms/types/options/html5.rst.inc .. _form-reference-date-input: diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index 6adc3e733eb..72af8847075 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -76,11 +76,6 @@ Defines the ``format`` option that will be passed down to the date field. See the :ref:`DateType's format option ` for more details. -.. deprecated:: 4.3 - - Using the ``date_format`` option when the form is rendered as an HTML 5 - datetime input is deprecated since Symfony 4.3. - date_label ~~~~~~~~~~ @@ -100,11 +95,6 @@ date_widget .. include:: /reference/forms/types/options/date_widget_description.rst.inc -.. deprecated:: 4.3 - - Using the ``date_widget`` option when the ``widget`` option is set to - ``single_text`` is deprecated since Symfony 4.3. - .. include:: /reference/forms/types/options/days.rst.inc placeholder @@ -146,11 +136,6 @@ used by the HTML5 ``datetime-local`` field. Keeping the default value will cause the field to be rendered as an ``input`` field with ``type="datetime-local"``. For more information on valid formats, see `Date/Time Format Syntax`_. -.. deprecated:: 4.3 - - Using the ``format`` option when the ``html5`` option is enabled is deprecated - since Symfony 4.3. - .. include:: /reference/forms/types/options/hours.rst.inc .. include:: /reference/forms/types/options/html5.rst.inc @@ -210,11 +195,6 @@ time_widget Defines the ``widget`` option for the :doc:`TimeType `. -.. deprecated:: 4.3 - - Using the ``time_widget`` option when the ``widget`` option is set to - ``single_text`` is deprecated since Symfony 4.3. - .. include:: /reference/forms/types/options/view_timezone.rst.inc widget diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index d228f4f8145..fa5660158bc 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -20,7 +20,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down | | - `rounding_mode`_ | +-------------+-----------------------------------------------------------------------+ | Overridden | - `compound`_ | -| options | - `scale`_ | +| options | | +-------------+-----------------------------------------------------------------------+ | Inherited | - `attr`_ | | options | - `data`_ | @@ -86,21 +86,6 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc -``scale`` -~~~~~~~~~ - -**type**: ``integer`` **default**: ``0`` - -.. deprecated:: 4.2 - - The ``scale`` option is deprecated since Symfony 4.2 and will be removed - in 5.0. - -This specifies how many decimals will be allowed until the field rounds the -submitted value (via ``rounding_mode``). This option inherits from -:doc:`number ` type and is overridden to ``0`` for -``IntegerType``. - Inherited Options ----------------- diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index bba93983ca4..e521ac21b60 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -24,6 +24,7 @@ manually, but then you should just use the ``ChoiceType`` directly. | Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | +-------------+------------------------------------------------------------------------+ | Options | - `alpha3`_ | +| | - `choice_self_translation`_ | | | - `choice_translation_locale`_ | +-------------+------------------------------------------------------------------------+ | Overridden | - `choices`_ | @@ -70,14 +71,27 @@ alpha3 **type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.4 - - The ``alpha3`` option was introduced in Symfony 4.4. - If this option is ``true``, the choice values use the `ISO 639-2 alpha-3`_ three-letter codes (e.g. French = ``fra``) instead of the default `ISO 639-1 alpha-2`_ two-letter codes (e.g. French = ``fr``). +choice_self_translation +~~~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +.. versionadded:: 5.1 + + The ``choice_self_translation`` option was introduced in Symfony 5.1. + +By default, the choice values are translated into the locale of the application. +For example, when using ``en`` as the locale, you'll get an array like +``[..., 'cs' => 'Czech', ..., 'es' => 'Spanish', ..., 'zh' => 'Chinese']``. + +If this option is ``true``, each choice value is translated into its own +language. The resulting array is the same regardless of the application locale: +``[..., 'cs' => 'čeština', ..., 'es' => 'español', ..., 'zh' => '中文']``. + .. include:: /reference/forms/types/options/choice_translation_locale.rst.inc Overridden Options diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 6e9215c276a..599d0efa4cd 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -55,10 +55,6 @@ html5 **type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.3 - - The ``html5`` option was introduced in Symfony 4.3. - If set to ``true``, the HTML input will be rendered as a native HTML5 ``type="number"`` form. @@ -67,10 +63,6 @@ input **type**: ``string`` **default**: ``number`` -.. versionadded:: 4.3 - - The ``input`` option was introduced in Symfony 4.3. - The format of the input data - i.e. the format that the number is stored on your underlying object. Valid values are ``number`` and ``string``. Setting this option to ``string`` can be useful if the underlying data is a string diff --git a/reference/forms/types/options/attr_translation_parameters.rst.inc b/reference/forms/types/options/attr_translation_parameters.rst.inc index 98326ba4abe..71187cd75c5 100644 --- a/reference/forms/types/options/attr_translation_parameters.rst.inc +++ b/reference/forms/types/options/attr_translation_parameters.rst.inc @@ -3,10 +3,6 @@ attr_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``attr_translation_parameters`` option was introduced in Symfony 4.3. - The content of the ``title`` and ``placeholder`` values defined in the `attr`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This diff --git a/reference/forms/types/options/block_prefix.rst.inc b/reference/forms/types/options/block_prefix.rst.inc index f02feb0ce70..db012bc3c42 100644 --- a/reference/forms/types/options/block_prefix.rst.inc +++ b/reference/forms/types/options/block_prefix.rst.inc @@ -4,10 +4,6 @@ block_prefix **type**: ``string`` or ``null`` **default**: ``null`` (see :ref:`Knowing which block to customize `) -.. versionadded:: 4.3 - - The ``block_prefix`` option was introduced in Symfony 4.3. - Allows you to add a custom block prefix and override the block name used to render the form type. Useful for example if you have multiple instances of the same form and you need to personalize the rendering diff --git a/reference/forms/types/options/date_input_format_description.rst.inc b/reference/forms/types/options/date_input_format_description.rst.inc index 4cd9b353e31..e411cd12d70 100644 --- a/reference/forms/types/options/date_input_format_description.rst.inc +++ b/reference/forms/types/options/date_input_format_description.rst.inc @@ -1,7 +1,3 @@ -.. versionadded:: 4.3 - - The ``input_format`` option was introduced in Symfony 4.3. - If the ``input`` option is set to ``string``, this option specifies the format of the date. This must be a valid `PHP date format`_. diff --git a/reference/forms/types/options/help_translation_parameters.rst.inc b/reference/forms/types/options/help_translation_parameters.rst.inc index 4294fb2b185..2b69e237941 100644 --- a/reference/forms/types/options/help_translation_parameters.rst.inc +++ b/reference/forms/types/options/help_translation_parameters.rst.inc @@ -3,10 +3,6 @@ help_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``help_translation_parameters`` option was introduced in Symfony 4.3. - The content of the `help`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This option defines the values used to replace those placeholders. diff --git a/reference/forms/types/options/label_translation_parameters.rst.inc b/reference/forms/types/options/label_translation_parameters.rst.inc index 443c6706f14..815b780553e 100644 --- a/reference/forms/types/options/label_translation_parameters.rst.inc +++ b/reference/forms/types/options/label_translation_parameters.rst.inc @@ -3,10 +3,6 @@ label_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``label_translation_parameters`` option was introduced in Symfony 4.3. - The content of the `label`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This option defines the values used to replace those placeholders. diff --git a/reference/forms/types/options/preferred_choices.rst.inc b/reference/forms/types/options/preferred_choices.rst.inc index 6ed20b5c6b6..e41dd4d654d 100644 --- a/reference/forms/types/options/preferred_choices.rst.inc +++ b/reference/forms/types/options/preferred_choices.rst.inc @@ -20,12 +20,6 @@ form of languages, you can list the most popular on top, like Bork Bork and Pira 'preferred_choices' => ['muppets', 'arr'], ]); -.. versionadded:: 4.4 - - Starting from Symfony 4.4, the preferred choices are displayed both at the - top of the list and at their original locations on the list. In prior - Symfony versions, they were only displayed at the top of the list. - This options can also be a callback function to give you more flexibility. This might be especially useful if your values are objects:: diff --git a/reference/forms/types/options/row_attr.rst.inc b/reference/forms/types/options/row_attr.rst.inc index 4cb9775b5e5..e8cbaa6b564 100644 --- a/reference/forms/types/options/row_attr.rst.inc +++ b/reference/forms/types/options/row_attr.rst.inc @@ -14,7 +14,3 @@ to render the :ref:`form type row `:: Use the ``attr`` option if you want to add these attributes to the the :ref:`form type widget ` element. - -.. versionadded:: 4.3 - - The ``row_attr`` option was introduced in Symfony 4.3. diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index b6a516fffc0..0455b5e8a5b 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -63,10 +63,6 @@ symbol **type**: ``boolean`` or ``string`` **default**: ``%`` -.. versionadded:: 4.3 - - The ``symbol`` option was introduced in Symfony 4.3. - By default, fields are rendered with a percentage sign ``%`` after the input. Setting the value to ``false`` will not display the percentage sign. Setting the value to a ``string`` (e.g. ``‱``), will show that string instead of the default diff --git a/reference/forms/types/submit.rst b/reference/forms/types/submit.rst index 7c6c5d69b1c..8976dc30a02 100644 --- a/reference/forms/types/submit.rst +++ b/reference/forms/types/submit.rst @@ -45,10 +45,6 @@ validate **type**: ``boolean`` **default**: ``true`` -.. versionadded:: 4.4 - - The ``validate`` option was introduced in Symfony 4.4. - Set this option to ``false`` to disable the client-side validation of the form performed by the browser. diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index 09d368e4ee3..2d4ef56d085 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -139,10 +139,6 @@ input_format **type**: ``string`` **default**: ``H:i:s`` -.. versionadded:: 4.3 - - The ``input_format`` option was introduced in Symfony 4.3. - If the ``input`` option is set to ``string``, this option specifies the format of the time. This must be a valid `PHP time format`_. diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index fb2efb4ce21..a493f406378 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -19,7 +19,6 @@ manually, but then you should just use the ``ChoiceType`` directly. +-------------+------------------------------------------------------------------------+ | Options | - `input`_ | | | - `intl`_ | -| | - `regions`_ | +-------------+------------------------------------------------------------------------+ | Overridden | - `choices`_ | | options | | @@ -73,19 +72,11 @@ on your underlying object. Valid values are: * ``intltimezone`` (an ``\IntlTimeZone`` object) * ``string`` (e.g. ``America/New_York``) -.. versionadded:: 4.3 - - The ``intltimezone`` input type was introduced in Symfony 4.3. - intl ~~~~ **type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.3 - - This option was introduced in Symfony 4.3. - If this option is set to ``true``, the timezone selector will display the timezones from the `ICU Project`_ via the :doc:`Intl component ` instead of the regular PHP timezones. @@ -99,17 +90,6 @@ with the ``choice_translation_locale`` option. The :doc:`Timezone constraint ` can validate both timezone sets and adapts to the selected set automatically. -``regions`` -~~~~~~~~~~~ - -**type**: ``int`` **default**: ``\DateTimeZone::ALL`` - -.. deprecated:: 4.2 - - This option was deprecated in Symfony 4.2. - -The available regions in the timezone choice list. For example: ``DateTimeZone::AMERICA | DateTimeZone::EUROPE`` - Overridden Options ------------------ diff --git a/reference/forms/types/week.rst b/reference/forms/types/week.rst index 754139c9cd6..6967df09bb7 100644 --- a/reference/forms/types/week.rst +++ b/reference/forms/types/week.rst @@ -4,10 +4,6 @@ WeekType Field ============== -.. versionadded:: 4.4 - - The ``WeekType`` type was introduced in Symfony 4.4. - This field type allows the user to modify data that represents a specific `ISO 8601`_ week number (e.g. ``1984-W05``). diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 70c2d286a66..ddb2a7ff0ac 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -325,33 +325,6 @@ trans Translates the text into the current language. More information in :ref:`Translation Filters `. -transchoice -~~~~~~~~~~~ - -.. deprecated:: 4.2 - - The ``transchoice`` filter is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` filter instead. - -.. code-block:: twig - - {{ message|transchoice(count, arguments = [], domain = null, locale = null) }} - -``message`` - **type**: ``string`` -``count`` - **type**: ``integer`` -``arguments`` *(optional)* - **type**: ``array`` **default**: ``[]`` -``domain`` *(optional)* - **type**: ``string`` **default**: ``null`` -``locale`` *(optional)* - **type**: ``string`` **default**: ``null`` - -Translates the text with pluralization support. More information in -:ref:`Translation Filters `. - yaml_encode ~~~~~~~~~~~ @@ -560,31 +533,6 @@ trans Renders the translation of the content. More information in :ref:`translation-tags`. -transchoice -~~~~~~~~~~~ - -.. deprecated:: 4.2 - - The ``transchoice`` tag is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` tag instead. - -.. code-block:: twig - - {% transchoice count with vars from domain into locale %}{% endtranschoice %} - -``count`` - **type**: ``integer`` -``vars`` *(optional)* - **type**: ``array`` **default**: ``[]`` -``domain`` *(optional)* - **type**: ``string`` **default**: ``null`` -``locale`` *(optional)* - **type**: ``string`` **default**: ``null`` - -Renders the translation of the content with pluralization support, more -information in :ref:`translation-tags`. - trans_default_domain ~~~~~~~~~~~~~~~~~~~~ diff --git a/routing.rst b/routing.rst index d178db369a2..31ca2baffca 100644 --- a/routing.rst +++ b/routing.rst @@ -729,11 +729,6 @@ If you want to always include some default value in the generated URL (for example to force the generation of ``/blog/1`` instead of ``/blog`` in the previous example) add the ``!`` character before the parameter name: ``/blog/{!page}`` -.. versionadded:: 4.3 - - The feature to force the inclusion of default values in generated URLs was - introduced in Symfony 4.3. - As it happens with requirements, default values can also be inlined in each parameter using the syntax ``{parameter_name?default_value}``. This feature is compatible with inlined requirements, so you can inline both in a single @@ -955,10 +950,6 @@ and in route imports. Symfony defines some special attributes with the same name ; }; -.. versionadded:: 4.3 - - The special attributes were introduced in Symfony 4.3. - Extra Parameters ~~~~~~~~~~~~~~~~ @@ -1230,11 +1221,6 @@ the common configuration using options when importing the routes. ; }; -.. versionadded:: 4.4 - - The option to exclude some files or subdirectories when loading annotations - was introduced in Symfony 4.4. - In this example, the route of the ``index()`` action will be called ``blog_index`` and its URL will be ``/blog/``. The route of the ``show()`` action will be called ``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes @@ -1414,13 +1400,6 @@ Use the ``RedirectController`` to redirect to other routes and URLs: Symfony also provides some utilities to :ref:`redirect inside controllers ` -.. versionadded:: 4.4 - - In Symfony versions prior to 4.4, you needed to define the specific - ``RedirectController`` method to use (either ``redirectAction`` or - ``urlRedirectAction``). Starting from Symfony 4.4 this is no longer needed - because Symfony detects if the redirection is to a route or an URL. - .. _routing-trailing-slash-redirection: Redirecting URLs with Trailing Slashes diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index 12541ce8ac1..8a66b15e38f 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -216,10 +216,6 @@ implement the :class:`Symfony\\Bundle\\FrameworkBundle\\Routing\\RouteLoaderInte interface to be tagged automatically. If you're **not using autoconfigure**, tag it manually with ``routing.loader``. -.. deprecated:: 4.4 - - Not tagging or implementing your route loader was deprecated in Symfony 4.4. - .. note:: The routes defined using service route loaders will be automatically @@ -230,11 +226,6 @@ tag it manually with ``routing.loader``. If your service is invokable, you don't need to precise the method to use. -.. versionadded:: 4.3 - - The support of the ``__invoke()`` method to create invokable service route - loaders was introduced in Symfony 4.3. - Creating a custom Loader ------------------------ @@ -262,7 +253,7 @@ you do. The resource name itself is not actually used in the example:: { private $isLoaded = false; - public function load($resource, $type = null) + public function load($resource, string $type = null) { if (true === $this->isLoaded) { throw new \RuntimeException('Do not add the "extra" loader twice'); @@ -289,7 +280,7 @@ you do. The resource name itself is not actually used in the example:: return $routes; } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return 'extra' === $type; } @@ -428,7 +419,7 @@ configuration file - you can call the class AdvancedLoader extends Loader { - public function load($resource, $type = null) + public function load($resource, string $type = null) { $routes = new RouteCollection(); @@ -442,7 +433,7 @@ configuration file - you can call the return $routes; } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return 'advanced_extra' === $type; } diff --git a/security/access_control.rst b/security/access_control.rst index d423db47be6..6fe3c1299cd 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -44,8 +44,6 @@ Take the following ``access_control`` entries as an example: - { path: '^/admin', roles: ROLE_USER_PORT, ip: 127.0.0.1, port: 8080 } - { path: '^/admin', roles: ROLE_USER_HOST, host: symfony\.com$ } - { path: '^/admin', roles: ROLE_USER_METHOD, methods: [POST, PUT] } - # when defining multiple roles, users must have at least one of them (it's like an OR condition) - - { path: '^/admin', roles: [ROLE_MANAGER, ROLE_ADMIN] } .. code-block:: xml @@ -63,8 +61,6 @@ Take the following ``access_control`` entries as an example: - - @@ -94,12 +90,7 @@ Take the following ``access_control`` entries as an example: 'path' => '^/admin', 'roles' => 'ROLE_USER_METHOD', 'methods' => 'POST, PUT', - ], - [ - 'path' => '^/admin', - // when defining multiple roles, users must have at least one of them (it's like an OR condition) - 'roles' => ['ROLE_MANAGER', 'ROLE_ADMIN'], - ], + ] ], ]); @@ -130,11 +121,6 @@ if ``ip``, ``port``, ``host`` or ``method`` are not specified for an entry, that | ``/admin/user`` | 168.0.0.1 | 80 | example.com | POST | rule #4 (``ROLE_USER_METHOD``) | The ``ip`` and ``host`` don't match the first two entries, | | | | | | | | but the third - ``ROLE_USER_METHOD`` - matches and is used. | +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+ -| ``/admin/user`` | 168.0.0.1 | 80 | example.com | GET | rule #4 (``ROLE_MANAGER``) | The ``ip``, ``host`` and ``method`` prevent the first | -| | | | | | | three entries from matching. But since the URI matches the | -| | | | | | | ``path`` pattern, then the ``ROLE_MANAGER`` (or the | -| | | | | | | ``ROLE_ADMIN``) is used. | -+-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+ | ``/foo`` | 127.0.0.1 | 80 | symfony.com | POST | matches no entries | This doesn't match any ``access_control`` rules, since its | | | | | | | | URI doesn't match any of the ``path`` values. | +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+ diff --git a/security/auth_providers.rst b/security/auth_providers.rst index f5ec3723c7b..69fd0abaaa2 100644 --- a/security/auth_providers.rst +++ b/security/auth_providers.rst @@ -21,8 +21,6 @@ use-case matches one of these exactly, they're a great option: * :doc:`json_login ` * :ref:`X.509 Client Certificate Authentication (x509) ` * :ref:`REMOTE_USER Based Authentication (remote_user) ` -* ``simple_form`` -* ``simple_pre_auth`` .. _security-http_basic: diff --git a/security/csrf.rst b/security/csrf.rst index 620df0f887e..45520e4bf2b 100644 --- a/security/csrf.rst +++ b/security/csrf.rst @@ -113,10 +113,6 @@ You can also customize the rendering of the CSRF form field creating a custom the field (e.g. define ``{% block csrf_token_widget %} ... {% endblock %}`` to customize the entire form field contents). -.. versionadded:: 4.3 - - The ``csrf_token`` form field prefix was introduced in Symfony 4.3. - CSRF Protection in Login Forms ------------------------------ diff --git a/security/guard_authentication.rst b/security/guard_authentication.rst index 13000f1aea7..13d1b5486d8 100644 --- a/security/guard_authentication.rst +++ b/security/guard_authentication.rst @@ -300,7 +300,7 @@ Each authenticator needs the following methods: (or throw an :ref:`AuthenticationException `), authentication will fail. -**onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)** +**onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey)** This is called after successful authentication and your job is to either return a :class:`Symfony\\Component\\HttpFoundation\\Response` object that will be sent to the client or ``null`` to continue the request diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 338f377d0b8..d9d1deba976 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -98,10 +98,6 @@ special role, for instance, to show a link to exit impersonation in a template: Finding the Original User ------------------------- -.. versionadded:: 4.3 - - The ``SwitchUserToken`` class was introduced in Symfony 4.3. - In some cases, you may need to get the object that represents the impersonator user rather than the impersonated user. When a user is impersonated the token stored in the token storage will be a ``SwitchUserToken`` instance. Use the diff --git a/security/ldap.rst b/security/ldap.rst index 180879a16cd..f29909dbc4a 100644 --- a/security/ldap.rst +++ b/security/ldap.rst @@ -34,12 +34,6 @@ This means that the following scenarios will work: * Loading user information from an LDAP server, while using another authentication strategy (token-based pre-authentication, for example). -.. deprecated:: 4.4 - - The class ``Symfony\Component\Security\Core\User\LdapUserProvider`` - has been deprecated in Symfony 4.4. Use the class - ``Symfony\Component\Ldap\Security\LdapUserProvider`` instead. - Installation ------------ @@ -281,10 +275,6 @@ extra_fields **type**: ``array`` **default**: ``null`` -.. versionadded:: 4.4 - - The ``extra_fields`` option was introduced in Symfony 4.4. - Defines the custom fields to pull from the LDAP server. If any field does not exist, an ``\InvalidArgumentException`` will be thrown. @@ -537,11 +527,6 @@ Configuration example for form login and query_string ] ]); -.. deprecated:: 4.4 - - Using the ``query_string`` config option without defining ``search_dn`` and - ``search_password`` is deprecated since Symfony 4.4. - .. _`LDAP PHP extension`: http://www.php.net/manual/en/intro.ldap.php .. _`RFC4515`: http://www.faqs.org/rfcs/rfc4515.html .. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection diff --git a/security/password_migration.rst b/security/password_migration.rst index 78455b1f06d..912ded38d0e 100644 --- a/security/password_migration.rst +++ b/security/password_migration.rst @@ -4,10 +4,6 @@ How to Migrate a Password Hash ============================== -.. versionadded:: 4.4 - - Password migration was introduced in Symfony 4.4. - In order to protect passwords, it is recommended to store them using the latest hash algorithms. This means that if a better hash algorithm is supported on your system, the user's password should be *rehashed* using the newer algorithm and diff --git a/serializer.rst b/serializer.rst index a3b269fefd3..e6c7eedb82b 100644 --- a/serializer.rst +++ b/serializer.rst @@ -70,10 +70,6 @@ As well as the following normalizers: * :class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer` to denormalize arrays of objects using a format like `MyObject[]` (note the `[]` suffix) -.. versionadded:: 4.3 - - The ``DateTimeZoneNormalizer`` was introduced in Symfony 4.3. - Custom normalizers and/or encoders can also be loaded by tagging them as :ref:`serializer.normalizer ` and :ref:`serializer.encoder `. It's also diff --git a/service_container.rst b/service_container.rst index a09187552f7..5eefce21d5d 100644 --- a/service_container.rst +++ b/service_container.rst @@ -743,10 +743,6 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type // ... }; -.. versionadded:: 4.4 - - The feature to bind tagged services was introduced in Symfony 4.4. - By putting the ``bind`` key under ``_defaults``, you can specify the value of *any* argument for *any* service defined in this file! You can bind arguments by name (e.g. ``$adminEmail``), by type (e.g. ``Psr\Log\LoggerInterface``) or both @@ -791,10 +787,6 @@ constructor arguments without any configuration. Linting Service Definitions --------------------------- -.. versionadded:: 4.4 - - The ``lint:container`` command was introduced in Symfony 4.4. - The ``lint:container`` command checks that the arguments injected into services match their type declarations. It's useful to run it before deploying your application to production (e.g. in your continuous integration server): @@ -820,7 +812,7 @@ this file is ``public: false`` by default. What does this mean? When a service **is** public, you can access it directly from the container object, which is accessible from any controller that extends -``Controller``:: +:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController`:: use App\Service\MessageGenerator; diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst index 09b2d11376c..ce7a1251ebe 100644 --- a/service_container/alias_private.rst +++ b/service_container/alias_private.rst @@ -217,10 +217,6 @@ The message is actually a message template, which replaces occurrences of the ``%alias_id%`` placeholder by the service alias id. You **must** have at least one occurrence of the ``%alias_id%`` placeholder in your template. -.. versionadded:: 4.3 - - The ``deprecated`` option for service aliases was introduced in Symfony 4.3. - Anonymous Services ------------------ diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 7a23745b728..4d4a32cfc63 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -263,11 +263,6 @@ class is type-hinted. adds an alias: ``Psr\Log\LoggerInterface`` that points to the ``logger`` service. This is why arguments type-hinted with ``Psr\Log\LoggerInterface`` can be autowired. -.. versionadded:: 4.2 - - Since Monolog Bundle 3.5 each channel bind into container by type-hinted alias. - More info in the part about :ref:`how to autowire monolog channels `. - .. _autowiring-interface-alias: Working with Interfaces @@ -524,10 +519,6 @@ If the argument is named ``$shoutyTransformer``, But, you can also manually wire any *other* service by specifying the argument under the arguments key. -.. versionadded:: 4.2 - - Named autowiring aliases have been introduced in Symfony 4.2. - Fixing Non-Autowireable Arguments --------------------------------- diff --git a/service_container/calls.rst b/service_container/calls.rst index 23003ebfdc4..448be1f6623 100644 --- a/service_container/calls.rst +++ b/service_container/calls.rst @@ -78,10 +78,6 @@ To configure the container to call the ``setLogger`` method, use the ``calls`` k }; -.. versionadded:: 4.3 - - The ``immutable-setter`` injection was introduced in Symfony 4.3. - To provide immutable services, some classes implement immutable setters. Such setters return a new instance of the configured class instead of mutating the object they were called on:: diff --git a/service_container/configurators.rst b/service_container/configurators.rst index 01029d96181..ec5e566fbbb 100644 --- a/service_container/configurators.rst +++ b/service_container/configurators.rst @@ -188,10 +188,6 @@ all the classes are already loaded as services. All you need to do is specify th .. _configurators-invokable: -.. versionadded:: 4.3 - - Invokable configurators for services were introduced in Symfony 4.3. - Services can be configured via invokable configurators (replacing the ``configure()`` method with ``__invoke()``) by omitting the method name, just as routes can reference :ref:`invokable controllers `. diff --git a/service_container/factories.rst b/service_container/factories.rst index bc0f73b3475..52b843eb88a 100644 --- a/service_container/factories.rst +++ b/service_container/factories.rst @@ -181,10 +181,6 @@ factory service can be used as a callback:: } } -.. versionadded:: 4.3 - - Invokable factories for services were introduced in Symfony 4.3. - Services can be created and configured via invokable factories by omitting the method name, just as routes can reference :ref:`invokable controllers `. diff --git a/service_container/injection_types.rst b/service_container/injection_types.rst index 2a728de4879..cc42c1cdf32 100644 --- a/service_container/injection_types.rst +++ b/service_container/injection_types.rst @@ -108,10 +108,6 @@ then extending it and overriding the constructor becomes problematic. Immutable-setter Injection -------------------------- -.. versionadded:: 4.3 - - The ``immutable-setter`` injection was introduced in Symfony 4.3. - Another possible injection is to use a method which returns a separate instance by cloning the original service, this approach allows you to make a service immutable:: diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 5a12cf1c3e6..e178932f53e 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -326,17 +326,6 @@ service definition to pass a collection of services to the service locator: ; }; -.. versionadded:: 4.1 - - The service locator autoconfiguration was introduced in Symfony 4.1. In - previous Symfony versions you always needed to add the - ``container.service_locator`` tag explicitly. - -.. versionadded:: 4.2 - - The ability to add services without specifying their id was introduced in - Symfony 4.2. - .. note:: The services defined in the service locator argument must include keys, diff --git a/setup.rst b/setup.rst index 20cc14e6355..5b8a74f0b9c 100644 --- a/setup.rst +++ b/setup.rst @@ -17,7 +17,7 @@ Technical Requirements Before creating your first Symfony application you must: -* Install PHP 7.1 or higher and these PHP extensions (which are installed and +* 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`_, `PCRE`_, `Session`_, `SimpleXML`_, and `Tokenizer`_; * `Install Composer`_, which is used to install PHP packages; diff --git a/setup/built_in_web_server.rst b/setup/built_in_web_server.rst deleted file mode 100644 index b8155a0302e..00000000000 --- a/setup/built_in_web_server.rst +++ /dev/null @@ -1,127 +0,0 @@ -.. index:: - single: Web Server; Built-in Web Server - -How to Use PHP's built-in Web Server -==================================== - -.. deprecated:: 4.4 - - This article explains how to use the WebServerBundle to run Symfony - applications on your local computer. However, that bundle is deprecated - since Symfony 4.4 and will be removed in Symfony 5.0. - - Instead of using WebServerBundle, the preferred way to run your Symfony - applications locally is to use the :doc:`Symfony Local Web Server `. - -The PHP CLI SAPI comes with a `built-in web server`_. It can be used to run your -PHP applications locally during development, for testing or for application -demonstrations. This way, you don't have to bother configuring a full-featured -web server such as :doc:`Apache or nginx `. - -.. caution:: - - The built-in web server is meant to be run in a controlled environment. - It is not designed to be used on public networks. - -Symfony provides a web server built on top of this PHP server to simplify your -local setup. This server is distributed as a bundle, so you must first install -and enable the server bundle. - -Installing the Web Server Bundle --------------------------------- - -Move into your project directory and run this command: - -.. code-block:: terminal - - $ cd your-project/ - $ composer require --dev symfony/web-server-bundle - -Starting the Web Server ------------------------ - -To run a Symfony application using PHP's built-in web server, execute the -``server:start`` command: - -.. code-block:: terminal - - $ php bin/console server:start - -This starts the web server at ``localhost:8000`` in the background that serves -your Symfony application. - -By default, the web server listens on port 8000 on the loopback device. You -can change the socket passing an IP address and a port as a command-line argument: - -.. code-block:: terminal - - # passing a specific IP and port - $ php bin/console server:start 192.168.0.1:8080 - - # passing '*' as the IP means to use 0.0.0.0 (i.e. any local IP address) - $ php bin/console server:start *:8080 - -.. note:: - - You can use the ``server:status`` command to check if a web server is - listening: - - .. code-block:: terminal - - $ php bin/console server:status - -.. tip:: - - Some systems do not support the ``server:start`` command, in these cases - you can execute the ``server:run`` command. This command behaves slightly - different. Instead of starting the server in the background, it will block - the current terminal until you terminate it (this is usually done by - pressing Ctrl and C). - -.. sidebar:: Using the built-in Web Server from inside a Virtual Machine - - If you want to use the built-in web server from inside a virtual machine - and then load the site from a browser on your host machine, you'll need - to listen on the ``0.0.0.0:8000`` address (i.e. on all IP addresses that - are assigned to the virtual machine): - - .. code-block:: terminal - - $ php bin/console server:start 0.0.0.0:8000 - - .. caution:: - - You should **NEVER** listen to all interfaces on a computer that is - directly accessible from the Internet. The built-in web server is - not designed to be used on public networks. - -Command Options -~~~~~~~~~~~~~~~ - -The built-in web server expects a "router" script (read about the "router" -script on `php.net`_) as an argument. Symfony already passes such a router -script when the command is executed in the ``prod`` or ``dev`` environment. -Use the ``--router`` option to use your own router script: - -.. code-block:: terminal - - $ php bin/console server:start --router=config/my_router.php - -If your application's document root differs from the standard directory layout, -you have to pass the correct location using the ``--docroot`` option: - -.. code-block:: terminal - - $ php bin/console server:start --docroot=public_html - -Stopping the Server -------------------- - -When you finish your work, you can stop the web server with the following command: - -.. code-block:: terminal - - $ php bin/console server:stop - -.. _`built-in web server`: https://php.net/manual/en/features.commandline.webserver.php -.. _`php.net`: https://php.net/manual/en/features.commandline.webserver.php#example-411 diff --git a/setup/upgrade_patch.rst b/setup/upgrade_patch.rst index de532e02d36..632f6602550 100644 --- a/setup/upgrade_patch.rst +++ b/setup/upgrade_patch.rst @@ -1,7 +1,7 @@ .. index:: single: Upgrading; Patch Version -Upgrading a Patch Version (e.g. 4.1.0 to 4.1.1) +Upgrading a Patch Version (e.g. 5.0.0 to 5.0.1) =============================================== When a new patch version is released (only the last number changed), it is a diff --git a/templates.rst b/templates.rst index e31c6539d89..2b289af7d93 100644 --- a/templates.rst +++ b/templates.rst @@ -477,8 +477,9 @@ definition. Use the special ``TemplateController`` provided by Symfony: sharedAge: 86400 # optionally you can define some arguments passed to the template - site_name: 'ACME' - theme: 'dark' + context: + site_name: 'ACME' + theme: 'dark' .. code-block:: xml @@ -499,8 +500,10 @@ definition. Use the special ``TemplateController`` provided by Symfony: 86400 - ACME - dark + + ACME + dark + @@ -522,12 +525,18 @@ definition. Use the special ``TemplateController`` provided by Symfony: 'sharedAge' => 86400, // optionally you can define some arguments passed to the template - 'site_name' => 'ACME', - 'theme' => 'dark', + 'context' => [ + 'site_name' => 'ACME', + 'theme' => 'dark', + ] ]) ; }; +.. versionadded:: 5.1 + + The ``context`` option was introduced in Symfony 5.1. + Checking if a Template Exists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -576,12 +585,6 @@ errors. It's useful to run it before deploying your application to production # you can also show the deprecated features used in your templates $ php bin/console lint:twig --show-deprecations templates/email/ -.. versionadded:: 4.4 - - The feature that checks all the application templates when not passing any - arguments to ``lint:twig`` and the ``--show-deprecations`` option were - introduced in Symfony 4.4. - Inspecting Twig Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1008,12 +1011,6 @@ When rendering a template, Symfony looks for it first in the ``twig.paths`` directories that don't define a namespace and then falls back to the default template directory (usually, ``templates/``). -.. deprecated:: 4.2 - - Symfony looks for templates in the ``src/Resources/views/`` too before - falling back to the default directory. But that behavior is deprecated since - Symfony 4.2 and will be removed in Symfony 5.0. - Using the above configuration, if your application renders for example the ``layout.html.twig`` template, Symfony will first look for ``email/default/templates/layout.html.twig`` and ``backend/templates/layout.html.twig``. diff --git a/templating/PHP.rst b/templating/PHP.rst index f26815dc558..9928984f8d8 100644 --- a/templating/PHP.rst +++ b/templating/PHP.rst @@ -4,571 +4,7 @@ How to Use PHP instead of Twig for Templates ============================================ -.. deprecated:: 4.3 - - PHP templates have been deprecated in Symfony 4.3 and they will no longer be - supported in Symfony 5.0. Use :ref:`Twig templates ` instead. - -Symfony defaults to Twig for its template engine, but you can still use -plain PHP code if you want. Both templating engines are supported equally in -Symfony. Symfony adds some nice features on top of PHP to make writing -templates with PHP more powerful. - -.. tip:: - - If you choose *not* use Twig and you disable it, you'll need to implement - your own exception handler via the ``kernel.exception`` event. - -Rendering PHP Templates ------------------------ - -If you want to use the PHP templating engine, first install the templating component: - -.. code-block:: terminal - - $ composer require symfony/templating - -.. deprecated:: 4.3 - - The integration of the Templating component in FrameworkBundle has been - deprecated since version 4.3 and will be removed in 5.0. - -Next, enable the PHP engine: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - # ... - templating: - engines: ['twig', 'php'] - - .. code-block:: xml - - - - - - - - - - - - - - - .. code-block:: php - - // config/packages/framework.php - $container->loadFromExtension('framework', [ - // ... - 'templating' => [ - 'engines' => ['twig', 'php'], - ], - ]); - -You can now render a PHP template instead of a Twig one by using the ``.php`` -extension in the template name instead of ``.twig``. The controller below -renders the ``index.html.php`` template:: - - // src/Controller/HelloController.php - - // ... - public function index($name) - { - // template is stored in src/Resources/views/hello/index.html.php - return $this->render('hello/index.html.php', [ - 'name' => $name - ]); - } - .. caution:: - Enabling the ``php`` and ``twig`` template engines simultaneously is - allowed, but it will produce an undesirable side effect in your application: - the ``@`` notation for Twig namespaces will no longer be supported for the - ``render()`` method:: - - public function index() - { - // ... - - // namespaced templates will no longer work in controllers - $this->render('@SomeNamespace/hello/index.html.twig'); - - // you must use the traditional template notation - $this->render('hello/index.html.twig'); - } - - .. code-block:: twig - - {# inside a Twig template, namespaced templates work as expected #} - {{ include('@SomeNamespace/hello/index.html.twig') }} - - {# traditional template notation will also work #} - {{ include('hello/index.html.twig') }} - -.. index:: - single: Templating; Layout - single: Layout - -Decorating Templates --------------------- - -More often than not, templates in a project share common elements, like the -well-known header and footer. In Symfony, this problem is thought about -differently: a template can be decorated by another one. - -The ``index.html.php`` template is decorated by ``layout.html.php``, thanks to -the ``extend()`` call: - -.. code-block:: html+php - - - extend('layout.html.php') ?> - - Hello ! - -Now, have a look at the ``layout.html.php`` file: - -.. code-block:: html+php - - - extend('base.html.php') ?> - -

Hello Application

- - output('_content') ?> - -The layout is itself decorated by another one (``base.html.php``). Symfony -supports multiple decoration levels: a layout can itself be decorated by -another one: - -.. code-block:: html+php - - - - - - - <?php $view['slots']->output('title', 'Hello Application') ?> - - - output('_content') ?> - - - -For both layouts, the ``$view['slots']->output('_content')`` expression is -replaced by the content of the child template, ``index.html.php`` and -``layout.html.php`` respectively (more on slots in the next section). - -As you can see, Symfony provides methods on a mysterious ``$view`` object. In -a template, the ``$view`` variable is always available and refers to a special -object that provides a bunch of methods that makes the template engine tick. - -.. index:: - single: Templating; Slot - single: Slot - -Working with Slots ------------------- - -A slot is a snippet of code, defined in a template, and reusable in any layout -decorating the template. In the ``index.html.php`` template, define a -``title`` slot: - -.. code-block:: html+php - - - extend('layout.html.php') ?> - - set('title', 'Hello World Application') ?> - - Hello ! - -The base layout already has the code to output the title in the header: - -.. code-block:: html+php - - - - - <?php $view['slots']->output('title', 'Hello Application') ?> - - -The ``output()`` method inserts the content of a slot and optionally takes a -default value if the slot is not defined. And ``_content`` is just a special -slot that contains the rendered child template. - -For large slots, there is also an extended syntax: - -.. code-block:: html+php - - start('title') ?> - Some large amount of HTML - stop() ?> - -.. index:: - single: Templating; Include - -Including other Templates -------------------------- - -The best way to share a snippet of template code is to define a template that -can then be included into other templates. - -Create a ``hello.html.php`` template: - -.. code-block:: html+php - - - Hello ! - -And change the ``index.html.php`` template to include it: - -.. code-block:: html+php - - - extend('layout.html.php') ?> - - render('hello/hello.html.php', ['name' => $name]) ?> - -The ``render()`` method evaluates and returns the content of another template -(this is the exact same method as the one used in the controller). - -.. index:: - single: Templating; Embedding pages - -Embedding other Controllers ---------------------------- - -And what if you want to embed the result of another controller in a template? -That's very useful when working with Ajax, or when the embedded template needs -some variable not available in the main template. - -If you create a ``fancy`` action, and want to include it into the -``index.html.php`` template, use the following code: - -.. code-block:: html+php - - - render( - new \Symfony\Component\HttpKernel\Controller\ControllerReference( - 'App\Controller\HelloController::fancy', - [ - 'name' => $name, - 'color' => 'green', - ] - ) - ) ?> - -But where is the ``$view['actions']`` array element defined? Like -``$view['slots']``, it's called a template helper, and the next section tells -you more about those. - -.. index:: - single: Templating; Helpers - -Using Template Helpers ----------------------- - -The Symfony templating system can be extended via helpers. Helpers are -PHP objects that provide features useful in a template context. ``actions`` and -``slots`` are two of the built-in Symfony helpers. - -Creating Links between Pages -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Speaking of web applications, creating links between pages is a must. Instead -of hardcoding URLs in templates, the ``router`` helper knows how to generate -URLs based on the routing configuration. That way, all your URLs can be -updated by changing the configuration: - -.. code-block:: html+php - -
- Greet Thomas! - - -The ``path()`` method takes the route name and an array of parameters as -arguments. The route name is the main key under which routes are referenced -and the parameters are the values of the placeholders defined in the route -pattern: - -.. code-block:: yaml - - # config/routes.yaml - hello: - path: /hello/{name} - controller: App\Controller\HelloController::index - -Using Assets: Images, JavaScripts and Stylesheets -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -What would the Internet be without images, JavaScripts, and stylesheets? -Symfony provides the ``assets`` tag to deal with them: - -.. code-block:: html+php - - - - - -The ``assets`` helper's main purpose is to make your application more -portable. Thanks to this helper, you can move the application root directory -anywhere under your web root directory without changing anything in your -template's code. - -Profiling Templates -~~~~~~~~~~~~~~~~~~~ - -By using the ``stopwatch`` helper, you are able to time parts of your template -and display it on the timeline of the WebProfilerBundle:: - - start('foo') ?> - ... things that get timed - stop('foo') ?> - -.. tip:: - - If you use the same name more than once in your template, the times are - grouped on the same line in the timeline. - -Output Escaping ---------------- - -When using PHP templates, escape variables whenever they are displayed to the -user:: - - escape($var) ?> - -By default, the ``escape()`` method assumes that the variable is outputted -within an HTML context. The second argument lets you change the context. For -instance, to output something in a JavaScript script, use the ``js`` context:: - - escape($var, 'js') ?> - -Form Theming in PHP -------------------- - -When using PHP as a templating engine, the only method to customize a fragment -is to create a new template file - this is similar to the second method used by -Twig. - -The template file must be named after the fragment. You must create a ``integer_widget.html.php`` -file in order to customize the ``integer_widget`` fragment. - -.. code-block:: html+php - - -
- block( - $form, - 'form_widget_simple', - ['type' => isset($type) ? $type : "number"] - ) ?> -
- -Now that you've created the customized form template, you need to tell Symfony -to use it. Inside the template where you're actually rendering your form, -tell Symfony to use the theme via the ``setTheme()`` helper method:: - - setTheme($form, [':form']) ?> - - widget($form['age']) ?> - -When the ``form.age`` widget is rendered, Symfony will use the customized -``integer_widget.html.php`` template and the ``input`` tag will be wrapped in -the ``div`` element. - -If you want to apply a theme to a specific child form, pass it to the ``setTheme()`` -method:: - - setTheme($form['child'], ':form') ?> - -.. note:: - - The ``:form`` syntax is based on the functional names for templates: - ``Bundle:Directory``. As the form directory lives in the - ``templates/`` directory, the ``Bundle`` part is empty, resulting - in ``:form``. - -Making Application-wide Customizations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you'd like a certain form customization to be global to your application, -you can accomplish this by making the form customizations in an external -template and then importing it inside your application configuration. - -By using the following configuration, any customized form fragments inside the -``templates/form`` folder will be used globally when a -form is rendered. - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - templating: - form: - resources: - - 'App:Form' - # ... - - .. code-block:: xml - - - - - - - - - App:Form - - - - - - - .. code-block:: php - - // config/packages/framework.php - // PHP - $container->loadFromExtension('framework', [ - 'templating' => [ - 'form' => [ - 'resources' => [ - 'App:Form', - ], - ], - ], - - // ... - ]); - -By default, the PHP engine uses a *div* layout when rendering forms. Some people, -however, may prefer to render forms in a *table* layout. Use the ``FrameworkBundle:FormTable`` -resource to use such a layout: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - templating: - form: - resources: - - 'FrameworkBundle:FormTable' - - .. code-block:: xml - - - - - - - - - FrameworkBundle:FormTable - - - - - - - .. code-block:: php - - // config/packages/framework.php - $container->loadFromExtension('framework', [ - 'templating' => [ - 'form' => [ - 'resources' => [ - 'FrameworkBundle:FormTable', - ], - ], - ], - - // ... - ]); - -If you only want to make the change in one template, add the following line to -your template file rather than adding the template as a resource: - -.. code-block:: html+php - - setTheme($form, ['FrameworkBundle:FormTable']) ?> - -Note that the ``$form`` variable in the above code is the form view variable -that you passed to your template. - -Adding a "Required" Asterisk to Field Labels -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you want to denote all of your required fields with a required asterisk -(``*``), you can do this by customizing the ``form_label`` fragment. - -When using PHP as a templating engine you have to copy the content from the -original template: - -.. code-block:: html+php - - - - - - - humanize($name); } ?> - - - - - * - - -Adding "help" Messages -~~~~~~~~~~~~~~~~~~~~~~ - -You can also customize your form widgets to have an optional "help" message. - -When using PHP as a templating engine you have to copy the content from the -original template: - -.. code-block:: html+php - - - - - value="escape($value) ?>" - block($form, 'widget_attributes') ?> - /> - - - - escape($help) ?> - + Starting from Symfony 5.0, PHP templates are no longer supported. Use + :doc:`Twig ` instead to create your templates. diff --git a/templating/hinclude.rst b/templating/hinclude.rst index def7939ab17..b192ad08b8a 100644 --- a/templating/hinclude.rst +++ b/templating/hinclude.rst @@ -67,12 +67,6 @@ default content rendering some template: ], ]); -.. versionadded:: 4.3 - - The ``framework.fragments.hinclude_default_template`` option was introduced - in Symfony 4.3. In previous Symfony versions it was called - ``framework.templating.hinclude_default_template``. - You can define default templates per ``render()`` function (which will override any global default template that is defined): diff --git a/testing.rst b/testing.rst index 4fd211cee26..99fcdd2e3bb 100644 --- a/testing.rst +++ b/testing.rst @@ -215,10 +215,6 @@ its existence, attributes, text, etc. The ``assertSelectorTextContains`` method is not a native PHPUnit assertion and is available thanks to the ``WebTestCase`` class. -.. versionadded:: 4.3 - - The ``WebTestCase`` assertions were introduced in Symfony 4.3 - .. seealso:: Using native PHPUnit methods, the same assertion would look like this:: @@ -711,10 +707,6 @@ The Crawler can extract information from the nodes:: return $node->attr('href'); }); -.. versionadded:: 4.4 - - The option to trim white spaces in ``text()`` was introduced in Symfony 4.4. - Links ~~~~~ @@ -820,10 +812,6 @@ their type:: :method:`Symfony\\Component\\DomCrawler\\Form::getName` method to get the form name. - .. versionadded:: 4.4 - - The ``getName()`` method was introduced in Symfony 4.4. - .. tip:: If you purposefully want to select "invalid" select/radio values, see diff --git a/testing/database.rst b/testing/database.rst index 0ecf9149eba..5ed19b4e91f 100644 --- a/testing/database.rst +++ b/testing/database.rst @@ -221,7 +221,7 @@ so, get the entity manager via the service container as follows:: */ private $entityManager; - protected function setUp() + protected function setUp(): void { $kernel = self::bootKernel(); @@ -240,7 +240,7 @@ so, get the entity manager via the service container as follows:: $this->assertSame(14.50, $product->getPrice()); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); diff --git a/testing/functional_tests_assertions.rst b/testing/functional_tests_assertions.rst index 6cff835e1f0..68c38455741 100644 --- a/testing/functional_tests_assertions.rst +++ b/testing/functional_tests_assertions.rst @@ -4,11 +4,6 @@ Functional Test specific Assertions =================================== -.. versionadded:: 4.3 - - The shortcut methods for assertions using ``WebTestCase`` were introduced - in Symfony 4.3. - When doing functional tests, sometimes you need to make complex assertions in order to check whether the ``Request``, the ``Response`` or the ``Crawler`` contain the expected information to make your test succeed. @@ -32,12 +27,6 @@ Now here is the example with the assertions specific to Symfony:: Assertions Reference --------------------- -.. versionadded:: 4.4 - - Starting from Symfony 4.4, when using `symfony/panther`_ for end-to-end - testing, you can use all the following assertions except the ones related to - the :doc:`Crawler `. - Response ~~~~~~~~ @@ -68,6 +57,11 @@ Browser Crawler ~~~~~~~ +.. note:: + + You cannot use the :doc:`Crawler ` assertions, + when using `symfony/panther`_ for end-to-end testing. + - ``assertSelectorExists()`` - ``assertSelectorNotExists()`` - ``assertSelectorTextContains()`` @@ -96,8 +90,4 @@ Mailer - ``assertEmailHeaderNotSame()`` - ``assertEmailAddressContains()`` -.. versionadded:: 4.4 - - The mailer assert methods were introduced in Symfony 4.4. - .. _`symfony/panther`: https://github.com/symfony/panther diff --git a/translation.rst b/translation.rst index bc2f8e03a72..f1c224ba23d 100644 --- a/translation.rst +++ b/translation.rst @@ -292,12 +292,6 @@ To manage these situations, Symfony follows the `ICU MessageFormat`_ syntax by using PHP's :phpclass:`MessageFormatter` class. Read more about this in :doc:`/translation/message_format`. -.. versionadded:: 4.2 - - Support for ICU MessageFormat was introduced in Symfony 4.2. Prior to this, - pluralization was managed by the - :method:`Symfony\\Component\\Translation\\Translator::transChoice` method. - .. _translation-in-templates: Translations in Templates @@ -354,11 +348,6 @@ The ``translation:update`` command looks for missing translations in: * Any PHP file/class that injects or :doc:`autowires ` the ``translator`` service and makes calls to the ``trans()`` function. -.. versionadded:: 4.3 - - The extraction of missing translation strings from PHP files was introduced - in Symfony 4.3. - .. _translation-resource-locations: Translation Resource/File Names and Locations @@ -366,18 +355,11 @@ Translation Resource/File Names and Locations Symfony looks for message files (i.e. translations) in the following default locations: -#. the ``translations/`` directory (at the root of the project); -#. the ``src/Resources//translations/`` directory; -#. the ``Resources/translations/`` directory inside of any bundle. - -.. deprecated:: 4.2 - - Using the ``src/Resources//translations/`` directory to store - translations was deprecated in Symfony 4.2. Use instead the directory - defined in the ``default_path`` option (which is ``translations/`` by default). +* the ``translations/`` directory (at the root of the project); +* the ``Resources/translations/`` directory inside of any bundle. The locations are listed here with the highest priority first. That is, you can -override the translation messages of a bundle in any of the top two directories. +override the translation messages of a bundle in the first directory. The override mechanism works at a key level: only the overridden keys need to be listed in a higher priority message file. When a key is not found @@ -477,13 +459,6 @@ if you're generating translations with specialized programs or teams. :class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface. See the :ref:`dic-tags-translation-loader` tag for more information. -.. versionadded:: 4.3 - - Starting from Symfony 4.3, when you create a new translation file (or - install a bundle that includes translation files), you don't have to clear - the cache with the command ``php bin/console cache:clear`` as you had to do - in previous Symfony versions. - Handling the User's Locale -------------------------- @@ -550,12 +525,6 @@ checks translation resources for several locales: // ... ]); -.. deprecated:: 4.4 - - In Symfony versions before 4.4, the ``fallbacks`` option was initialized to - ``en`` (English) when not configured explicitly. Starting from Symfony 4.4, - this option is initialized to the same value as the ``default_locale`` option. - .. note:: When Symfony can't find a translation in the given locale, it will diff --git a/translation/lint.rst b/translation/lint.rst index 29cec3c5008..bcdd42eae9b 100644 --- a/translation/lint.rst +++ b/translation/lint.rst @@ -32,3 +32,16 @@ The linter results can be exported to JSON using the ``--format`` option: $ php bin/console lint:yaml translations/ --format=json $ php bin/console lint:xliff translations/ --format=json + +.. tip:: + + The Yaml component provides a stand-alone ``yaml-lint`` binary to lint YAML + files without using the entire Symfony console application: + + .. code-block:: terminal + + $ php vendor/bin/yaml-lint translations/ + + .. versionadded:: 5.1 + + The ``yaml-lint`` binary was introduced in Symfony 5.1. diff --git a/translation/message_format.rst b/translation/message_format.rst index 4c660c7023a..187b3513df5 100644 --- a/translation/message_format.rst +++ b/translation/message_format.rst @@ -4,10 +4,6 @@ How to Translate Messages using the ICU MessageFormat ===================================================== -.. versionadded:: 4.2 - - Support for ICU MessageFormat was introduced in Symfony 4.2. - Messages (i.e. strings) in applications are almost never completely static. They contain variables or other complex logic like pluralization. In order to handle this, the Translator component supports the `ICU MessageFormat`_ syntax. diff --git a/translation/templates.rst b/translation/templates.rst index 903f1934d92..b820bfb0fba 100644 --- a/translation/templates.rst +++ b/translation/templates.rst @@ -9,27 +9,13 @@ Twig Templates Using Twig Tags ~~~~~~~~~~~~~~~ -Symfony provides specialized Twig tags (``trans`` and ``transchoice``) to -help with message translation of *static blocks of text*: +Symfony provides a specialized Twig tag ``trans`` to help with message +translation of *static blocks of text*: .. code-block:: twig {% trans %}Hello %name%{% endtrans %} - {% transchoice count %} - {0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples - {% endtranschoice %} - -The ``transchoice`` tag automatically gets the ``%count%`` variable from -the current context and passes it to the translator. This mechanism only -works when you use a placeholder following the ``%var%`` pattern. - -.. deprecated:: 4.2 - - The ``transchoice`` tag is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` tag instead. - .. caution:: The ``%var%`` notation of placeholders is required when translating in @@ -48,34 +34,19 @@ You can also specify the message domain and pass some additional variables: {% trans with {'%name%': 'Fabien'} from 'app' into 'fr' %}Hello %name%{% endtrans %} - {% transchoice count with {'%name%': 'Fabien'} from 'app' %} - {0} %name%, there are no apples|{1} %name%, there is one apple|]1,Inf[ %name%, there are %count% apples - {% endtranschoice %} - .. _translation-filters: Using Twig Filters ~~~~~~~~~~~~~~~~~~ -The ``trans`` and ``transchoice`` filters can be used to translate *variable -texts* and complex expressions: +The ``trans`` filter can be used to translate *variable texts* and complex expressions: .. code-block:: twig {{ message|trans }} - {{ message|transchoice(5) }} - {{ message|trans({'%name%': 'Fabien'}, 'app') }} - {{ message|transchoice(5, {'%name%': 'Fabien'}, 'app') }} - -.. deprecated:: 4.2 - - The ``transchoice`` filter is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` filter instead. - .. tip:: Using the translation tags or filters have the same effect, but with @@ -116,8 +87,3 @@ The translator service is accessible in PHP templates through the trans('Symfony is great') ?> - transChoice( - '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples', - 10, - ['%count%' => 10] - ) ?> diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index 9af22a03480..69fcfe07ee1 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -93,11 +93,6 @@ The validator class is also simple, and only has one required method ``validate( } } -.. versionadded:: 4.4 - - The feature to allow passing an object as the ``buildViolation()`` argument - was introduced in Symfony 4.4. - Inside ``validate``, you don't need to return a value. Instead, you add violations to the validator's ``context`` property and a value will be considered valid if it causes no violations. The ``buildViolation()`` method takes the error diff --git a/workflow.rst b/workflow.rst index db131726b85..21c9488ed01 100644 --- a/workflow.rst +++ b/workflow.rst @@ -345,16 +345,19 @@ order: * ``workflow.[workflow name].announce`` * ``workflow.[workflow name].announce.[transition name]`` + You can avoid triggering those events by using the context:: + + $workflow->apply($subject, $transitionName, [Workflow::DISABLE_ANNOUNCE_EVENT => true]); + + .. versionadded:: 5.1 + + The ``Workflow::DISABLE_ANNOUNCE_EVENT`` constant was introduced in Symfony 5.1. + .. note:: The leaving and entering events are triggered even for transitions that stay in same place. -.. versionadded:: 4.3 - - Following events are also dispatched when the subject enters the workflow - for the first time: ``workflow.entered`` and ``workflow.[worflow name].entered``. - Here is an example of how to enable logging for every time a "blog_publishing" workflow leaves a place:: @@ -549,10 +552,6 @@ place:: } } -.. versionadded:: 4.1 - - The transition blockers were introduced in Symfony 4.1. - Usage in Twig ------------- @@ -606,10 +605,6 @@ The following example shows these functions in action: Storing Metadata ---------------- -.. versionadded:: 4.1 - - The feature to store metadata in workflows was introduced in Symfony 4.1. - In case you need it, you can store arbitrary metadata in workflows, their places, and their transitions using the ``metadata`` option. This metadata can be as simple as the title of the workflow or as complex as your own application