Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5398a93

Browse files
committed
minor #15266 Fixed syntax errors on 4.4 (Nyholm)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Fixed syntax errors on 4.4 I ran the [new parser](#15257) on 4.4. There are about 130 more syntax errors that I decided not to fix. Some are false positives (ie a code example where we only have a PHP array). Others show some limitations of the parser. Ie, we cannot automatically detect a code block with no language, we currently assume it is PHP but that is not always correct. This is the last fixes I'll do for 4.4. Commits ------- 2a9103c Fixed syntax errors on 4.4
2 parents 8c38a35 + 2a9103c commit 5398a93

38 files changed

+105
-74
lines changed

components/console/helpers/formatterhelper.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ you can write::
7878
$truncatedMessage = $formatter->truncate($message, 7);
7979
$output->writeln($truncatedMessage);
8080

81-
And the output will be::
81+
And the output will be:
82+
83+
.. code-block:: text
8284
8385
This is...
8486
@@ -93,7 +95,9 @@ from the end of the string::
9395

9496
$truncatedMessage = $formatter->truncate($message, -5);
9597

96-
This will result in::
98+
This will result in:
99+
100+
.. code-block:: text
97101
98102
This is a very long message, which should be trun...
99103

components/console/helpers/table.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ You can add a table separator anywhere in the output by passing an instance of
7272
You can optionally display titles at the top and the bottom of the table::
7373

7474
// ...
75-
$table->setHeaderTitle('Books')
76-
$table->setFooterTitle('Page 1/2')
75+
$table->setHeaderTitle('Books');
76+
$table->setFooterTitle('Page 1/2');
7777
$table->render();
7878

7979
.. code-block:: terminal

components/dom_crawler.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ You can virtually set and get values on the form::
555555
// where "registration" is its own array
556556
$values = $form->getPhpValues();
557557

558-
To work with multi-dimensional fields::
558+
To work with multi-dimensional fields:
559+
560+
.. code-block:: html
559561

560562
<form>
561563
<input name="multi[]"/>

components/event_dispatcher.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ determine which instance is passed.
238238
$containerBuilder->addCompilerPass(new AddEventAliasesPass([
239239
\AcmeFooActionEvent::class => 'acme.foo.action',
240240
]));
241-
$containerBuilder->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING)
241+
$containerBuilder->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
242242

243243
$containerBuilder->register('event_dispatcher', EventDispatcher::class);
244244

components/filesystem.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ absolute paths and returns the relative path from the second path to the first o
252252
'/var/lib/symfony/src/Symfony/Component'
253253
);
254254
// returns 'videos/'
255-
$filesystem->makePathRelative('/tmp/videos', '/tmp')
255+
$filesystem->makePathRelative('/tmp/videos', '/tmp');
256256

257257
``mirror``
258258
~~~~~~~~~~

components/http_foundation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ represented by a PHP callable instead of a string::
547547
header in the response::
548548

549549
// disables FastCGI buffering in nginx only for this response
550-
$response->headers->set('X-Accel-Buffering', 'no')
550+
$response->headers->set('X-Accel-Buffering', 'no');
551551

552552
.. _component-http-foundation-serving-files:
553553

components/intl.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The Intl Component
1111
.. caution::
1212

1313
The replacement layer is limited to the ``en`` locale. If you want to use
14-
other locales, you should `install the intl extension`_. There is no conflict
14+
other locales, you should `install the intl extension`_. There is no conflict
1515
between the two because, even if you use the extension, this package can still
1616
be useful to access the ICU data.
1717

@@ -231,9 +231,9 @@ Locales
231231
~~~~~~~
232232

233233
A locale is the combination of a language, a region and some parameters that
234-
define the interface preferences of the user. For example, "Chinese" is the
235-
language and ``zh_Hans_MO`` is the locale for "Chinese" (language) + "Simplified"
236-
(script) + "Macau SAR China" (region). The ``Locales`` class provides access to
234+
define the interface preferences of the user. For example, "Chinese" is the
235+
language and ``zh_Hans_MO`` is the locale for "Chinese" (language) + "Simplified"
236+
(script) + "Macau SAR China" (region). The ``Locales`` class provides access to
237237
the name of all locales::
238238

239239
use Symfony\Component\Intl\Locales;
@@ -351,7 +351,7 @@ translate into any locale with the ``getName()`` method shown earlier::
351351
The reverse lookup is also possible thanks to the ``getCountryCode()`` method,
352352
which returns the code of the country where the given timezone ID belongs to::
353353

354-
$countryCode = Timezones::getCountryCode('America/Vancouver')
354+
$countryCode = Timezones::getCountryCode('America/Vancouver');
355355
// => $countryCode = 'CA' (CA = Canada)
356356

357357
The `UTC/GMT time offsets`_ of all timezones are provided by ``getRawOffset()``

components/lock.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ method can be safely called repeatedly, even if the lock is already acquired.
6363

6464
Unlike other implementations, the Lock Component distinguishes lock
6565
instances even when they are created for the same resource. It means that for
66-
a given scope and resource one lock instance can be acquired multiple times.
66+
a given scope and resource one lock instance can be acquired multiple times.
6767
If a lock has to be used by several services, they should share the same ``Lock``
6868
instance returned by the ``LockFactory::createLock`` method.
6969

@@ -223,7 +223,7 @@ Lock will be released automatically as soon as one process finishes::
223223
sleep(30);
224224
} else {
225225
// Child process
226-
echo 'The lock will be released now.'
226+
echo 'The lock will be released now.';
227227
exit(0);
228228
}
229229
// ...

components/options_resolver.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ the closure::
511511

512512
$resolver->setDefault('host', function (Options $options, $previousValue) {
513513
if ('ssl' === $options['encryption']) {
514-
return 'secure.example.org'
514+
return 'secure.example.org';
515515
}
516516

517517
// Take default value configured in the base class

components/phpunit_bridge.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ constraint to test the validity of the email domain::
629629
{
630630
public function testEmail()
631631
{
632-
$validator = ...
632+
$validator = ...;
633633
$constraint = new Email(['checkMX' => true]);
634634

635635
$result = $validator->validate('[email protected]', $constraint);
@@ -654,7 +654,7 @@ the data you expect to get for the given hosts::
654654
{
655655
DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]);
656656

657-
$validator = ...
657+
$validator = ...;
658658
$constraint = new Email(['checkMX' => true]);
659659

660660
$result = $validator->validate('[email protected]', $constraint);

components/security/authorization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ expressions have access to a number of
188188

189189
$expression = new Expression(
190190
'"ROLE_ADMIN" in roles or (not is_anonymous() and user.isSuperAdmin())'
191-
)
191+
);
192192

193193
$vote = $expressionVoter->vote($token, $object, [$expression]);
194194

components/serializer.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,9 @@ For example, take an object normalized as following::
901901

902902
['foo' => [1, 2], 'bar' => true];
903903

904-
The ``XmlEncoder`` will encode this object like that::
904+
The ``XmlEncoder`` will encode this object like that:
905+
906+
.. code-block:: xml
905907
906908
<?xml version="1.0" encoding="UTF-8" ?>
907909
<response>

components/validator/resources.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ implement the PSR-6 interface :class:`Psr\\Cache\\CacheItemPoolInterface`)::
155155

156156
$validator = Validation::createValidatorBuilder()
157157
// ... add loaders
158-
->setMappingCache(new SomePsr6Cache());
158+
->setMappingCache(new SomePsr6Cache())
159159
->getValidator();
160160

161161
.. versionadded:: 4.4

components/workflow.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ are trying to use it with::
6868
use Symfony\Component\Workflow\Registry;
6969
use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
7070

71-
$blogPostWorkflow = ...
72-
$newsletterWorkflow = ...
71+
$blogPostWorkflow = ...;
72+
$newsletterWorkflow = ...;
7373

7474
$registry = new Registry();
7575
$registry->addWorkflow($blogPostWorkflow, new InstanceOfSupportStrategy(BlogPost::class));

configuration/override_dir_structure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ option in your ``composer.json`` file like this:
230230
"config": {
231231
"bin-dir": "bin",
232232
"vendor-dir": "/some/dir/vendor"
233-
},
233+
}
234234
}
235235
236236
.. tip::

configuration/using_parameters_in_dic.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ Now, examine the results to see this closely:
8585
// true/false (depends on 2nd parameter of Kernel),
8686
// as expected, because %kernel.debug% inside configuration
8787
// gets evaluated before being passed to the extension
88-
)
89-
];
88+
]
89+
);
9090
9191
$container->loadFromExtension('my_bundle');
9292
// passes the string "%kernel.debug%".

contributing/code/conventions.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,19 @@ after the use declarations, like in this example from
188188

189189
.. _`ServiceRouterLoader`: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Routing/Loader/DependencyInjection/ServiceRouterLoader.php
190190

191-
The deprecation must be added to the ``CHANGELOG.md`` file of the impacted component::
191+
The deprecation must be added to the ``CHANGELOG.md`` file of the impacted component:
192+
193+
.. code-block:: markdown
192194
193195
4.4
194196
---
195197
196198
* Deprecate the `Deprecated` class, use `Replacement` instead
197199
198200
It must also be added to the ``UPGRADE.md`` file of the targeted minor version
199-
(``UPGRADE-4.4.md`` in our example)::
201+
(``UPGRADE-4.4.md`` in our example):
202+
203+
.. code-block:: markdown
200204
201205
DependencyInjection
202206
-------------------

controller/soap_web_service.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ In this case, the SOAP service will allow the client to call a method called
3939
public function hello($name)
4040
{
4141

42-
$message = new \Swift_Message('Hello Service')
42+
$message = (new \Swift_Message('Hello Service'))
4343
->setTo('[email protected]')
4444
->setBody($name.' says hi!');
4545

create_framework/front_controller.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ the ``setContent()`` directly from the front controller script::
185185

186186
// ...
187187

188-
And the ``hello.php`` script can now be converted to a template::
188+
And the ``hello.php`` script can now be converted to a template:
189+
190+
.. code-block:: html+php
189191

190192
<!-- example.com/src/pages/hello.php -->
191193
<?php $name = $request->get('name', 'World') ?>

create_framework/routing.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ framework just a little to make templates even more readable::
3030
$response->send();
3131

3232
As we now extract the request query parameters, simplify the ``hello.php``
33-
template as follows::
33+
template as follows:
34+
35+
.. code-block:: html+php
3436

3537
<!-- example.com/src/pages/hello.php -->
3638
Hello <?= htmlspecialchars(isset($name) ? $name : 'World', ENT_QUOTES, 'UTF-8') ?>
@@ -161,7 +163,9 @@ There are a few new things in the code:
161163

162164
* ``500`` errors are now managed correctly;
163165

164-
* Request attributes are extracted to keep our templates simple::
166+
* Request attributes are extracted to keep our templates simple:
167+
168+
.. code-block:: html+php
165169

166170
// example.com/src/pages/hello.php
167171
Hello <?= htmlspecialchars($name, ENT_QUOTES, 'UTF-8') ?>

doctrine/custom_dql_functions.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,14 @@ In Symfony, you can register your custom DQL functions as follows:
131131
use App\DQL\DatetimeFunction;
132132
133133
$container->loadFromExtension('doctrine', [
134-
'doctrine' => [
135-
'orm' => [
136-
// ...
137-
'entity_managers' => [
138-
'example_manager' => [
139-
// place your functions here
140-
'dql' => [
141-
'datetime_functions' => [
142-
'test_datetime' => DatetimeFunction::class,
143-
],
134+
'orm' => [
135+
// ...
136+
'entity_managers' => [
137+
'example_manager' => [
138+
// place your functions here
139+
'dql' => [
140+
'datetime_functions' => [
141+
'test_datetime' => DatetimeFunction::class,
144142
],
145143
],
146144
],

form/create_form_type_extension.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,10 @@ Specifically, you need to override the ``file_widget`` block:
191191
{% extends 'form_div_layout.html.twig' %}
192192

193193
{% block file_widget %}
194-
{% spaceless %}
195-
196194
{{ block('form_widget') }}
197195
{% if image_url is not null %}
198196
<img src="{{ asset(image_url) }}"/>
199197
{% endif %}
200-
201-
{% endspaceless %}
202198
{% endblock %}
203199

204200
Be sure to :ref:`configure this form theme template <forms-theming-global>` so that

form/data_transformers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ to and from the issue number and the ``Issue`` object::
208208
{
209209
// no issue number? It's optional, so that's ok
210210
if (!$issueNumber) {
211-
return;
211+
return null;
212212
}
213213

214214
$issue = $this->entityManager

form/type_guesser.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ With this knowledge, you can implement the ``guessType()`` method of the
101101
$annotations = $this->readPhpDocAnnotations($class, $property);
102102

103103
if (!isset($annotations['var'])) {
104-
return; // guess nothing if the @var annotation is not available
104+
return null; // guess nothing if the @var annotation is not available
105105
}
106106

107107
// otherwise, base the type on the @var annotation

form/validation_group_service_resolver.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Then in your form, inject the resolver and set it as the ``validation_groups``::
3939
namespace App\Form;
4040

4141
use App\Validator\ValidationGroupResolver;
42-
use Symfony\Component\Form\AbstractType
42+
use Symfony\Component\Form\AbstractType;
4343
use Symfony\Component\OptionsResolver\OptionsResolver;
4444

4545
class MyClassType extends AbstractType

forms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ argument of ``createForm()``::
592592
{
593593
$task = new Task();
594594
// use some PHP logic to decide if this form field is required or not
595-
$dueDateIsRequired = ...
595+
$dueDateIsRequired = ...;
596596

597597
$form = $this->createForm(TaskType::class, $task, [
598598
'require_due_date' => $dueDateIsRequired,

http_client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ To abort a request (e.g. because it didn't complete in due time, or you want to
885885
fetch only the first bytes of the response, etc.), you can either use the
886886
``cancel()`` method of ``ResponseInterface``::
887887

888-
$response->cancel()
888+
$response->cancel();
889889

890890
Or throw an exception from a progress callback::
891891

introduction/from_flat_php_to_symfony.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ and uses Twig:
580580

581581
.. code-block:: html+twig
582582

583-
<!-- templates/blog/list.html.twig -->
583+
{# templates/blog/list.html.twig #}
584584
{% extends 'base.html.twig' %}
585585

586586
{% block title %}List of Posts{% endblock %}

mercure.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ You can instead make use of the `MockHub`::
622622

623623
$controller = new MessageController($hub);
624624

625-
...
625+
// ...
626626
}
627627
}
628628

@@ -645,13 +645,14 @@ During functional testing you can instead decorate the Hub::
645645
}
646646

647647
HubStub decorates the default hub service so no updates are actually
648-
sent. Here is the HubStub implementation::
648+
sent. Here is the HubStub implementation:
649+
650+
.. code-block:: yaml
649651
650652
# config/services_test.yaml
651653
App\Tests\Functional\Fixtures\HubStub:
652654
decorates: mercure.hub.default
653655
654-
655656
Debugging
656657
---------
657658

0 commit comments

Comments
 (0)