Foo Bar
+ // innerText() returns 'Foo' and text() returns 'Foo Bar' Access the attribute value of the first node of the current selection:: @@ -261,10 +248,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; @@ -360,19 +343,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 ~~~~~~~~~~~~~~~~~~~~~ @@ -524,10 +499,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`` @@ -661,6 +632,19 @@ the whole form or specific field(s):: $form->disableValidation(); $form['country']->select('Invalid value'); +Resolving a URI +~~~~~~~~~~~~~~~ + +The :class:`Symfony\\Component\\DomCrawler\\UriResolver` class takes an URI +(relative, absolute, fragment, etc.) and turns it into an absolute URI against +another given base URI:: + + use Symfony\Component\DomCrawler\UriResolver; + + UriResolver::resolve('/foo', 'http://localhost/bar/foo/'); // http://localhost/foo + UriResolver::resolve('?a=b', 'http://localhost/bar#foo'); // http://localhost/bar?a=b + UriResolver::resolve('../../', 'http://localhost/'); // http://localhost/ + Learn more ---------- diff --git a/components/event_dispatcher.rst b/components/event_dispatcher.rst index dd1ce9c310a..45955506e5c 100644 --- a/components/event_dispatcher.rst +++ b/components/event_dispatcher.rst @@ -254,21 +254,11 @@ determine which instance is passed. Note that ``AddEventAliasesPass`` has to be processed before ``RegisterListenersPass``. - By default, the listeners pass assumes that the event dispatcher's service + The listeners pass assumes that the event dispatcher's service id is ``event_dispatcher``, that event listeners are tagged with the ``kernel.event_listener`` tag, that event subscribers are tagged with the ``kernel.event_subscriber`` tag and that the alias mapping is - stored as parameter ``event_dispatcher.event_aliases``. You can change these - default values by passing custom values to the constructors of - ``RegisterListenersPass`` and ``AddEventAliasesPass``. - -.. versionadded:: 4.3 - - Aliasing event names is possible since Symfony 4.3. - -.. versionadded:: 4.4 - - The ``AddEventAliasesPass`` class was introduced in Symfony 4.4. + stored as parameter ``event_dispatcher.event_aliases``. .. _event_dispatcher-closures-as-listeners: 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 b78ac907ca8..de0fddf80bf 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -14,16 +14,20 @@ Supported Literals The component supports: * **strings** - single and double quotes (e.g. ``'hello'``) -* **numbers** - e.g. ``103`` +* **numbers** - integers (e.g. ``103``), decimals (e.g. ``9.95``), decimals + without leading zeros (e.g. ``.99``, equivalent to ``0.99``); all numbers + support optional underscores as separators to improve readability (e.g. + ``1_000_000``, ``3.14159_26535``) * **arrays** - using JSON-like notation (e.g. ``[1, 2]``) * **hashes** - using JSON-like notation (e.g. ``{ foo: 'bar' }``) * **booleans** - ``true`` and ``false`` * **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. +.. versionadded:: 6.1 + + Support for decimals without leading zeros and underscore separators were + introduced in Symfony 6.1. .. caution:: @@ -98,6 +102,25 @@ JavaScript:: This will print out ``Hi Hi Hi!``. +Null-safe Operator +~~~~~~~~~~~~~~~~~~ + +Use the ``?.`` syntax to access properties and methods of objects that can be +``null`` (this is equivalent to the ``$object?->propertyOrMethod`` PHP null-safe +operator):: + + // these will throw an exception when `fruit` is `null` + $expressionLanguage->evaluate('fruit.color', ['fruit' => '...']) + $expressionLanguage->evaluate('fruit.getStock()', ['fruit' => '...']) + + // these will return `null` if `fruit` is `null` + $expressionLanguage->evaluate('fruit?.color', ['fruit' => '...']) + $expressionLanguage->evaluate('fruit?.getStock()', ['fruit' => '...']) + +.. versionadded:: 6.1 + + The null safe operator was introduced in Symfony 6.1. + .. _component-expression-functions: Working with Functions @@ -187,6 +210,14 @@ Comparison Operators * ``<=`` (less than or equal to) * ``>=`` (greater than or equal to) * ``matches`` (regex match) +* ``contains`` +* ``starts with`` +* ``ends with`` + +.. versionadded:: 6.1 + + The ``contains``, ``starts with`` and ``ends with`` operators were introduced + in Symfony 6.1. .. tip:: @@ -312,6 +343,23 @@ Ternary Operators * ``foo ?: 'no'`` (equal to ``foo ? foo : 'no'``) * ``foo ? 'yes'`` (equal to ``foo ? 'yes' : ''``) +Null Coalescing Operator +~~~~~~~~~~~~~~~~~~~~~~~~ + +This is the same as the PHP `null-coalescing operator`_, which combines +the ternary operator and ``isset()``. It returns the left hand-side if it exists +and it's not ``null``; otherwise it returns the right hand-side. Note that you +can chain multiple coalescing operators. + +* ``foo ?? 'no'`` +* ``foo.baz ?? 'no'`` +* ``foo[3] ?? 'no'`` +* ``foo.baz ?? foo['baz'] ?? 'no'`` + +.. versionadded:: 6.2 + + The null-coalescing operator was introduced in Symfony 6.2. + Built-in Objects and Variables ------------------------------ @@ -322,3 +370,5 @@ expressions (e.g. the request, the current user, etc.): * :doc:`Variables available in security expressions `; * :doc:`Variables available in service container expressions `; * :ref:`Variables available in routing expressions