Skip to content

Commit 2761a8f

Browse files
committed
minor #9194 Make code comments consistent (javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- Make code comments consistent This finishes #9088 by doing the opposite change: when the comment describes what the code does instead of what the user must do, use the format: `// returns a ...` instead of `// return a ...` Commits ------- a439f63 Make code comments consistent
2 parents b749bf0 + a439f63 commit 2761a8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+209
-209
lines changed

components/asset.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ suffix to any asset path::
114114
In case you want to modify the version format, pass a sprintf-compatible format
115115
string as the second argument of the ``StaticVersionStrategy`` constructor::
116116

117-
// put the 'version' word before the version value
117+
// puts the 'version' word before the version value
118118
$package = new Package(new StaticVersionStrategy('v1', '%s?version=%s'));
119119

120120
echo $package->getUrl('/image.png');
121121
// result: /image.png?version=v1
122122

123-
// put the asset version before its path
123+
// puts the asset version before its path
124124
$package = new Package(new StaticVersionStrategy('v1', '%2$s/%1$s'));
125125

126126
echo $package->getUrl('/image.png');

components/class_loader/cache_class_loader.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ ApcClassLoader
3434
// sha1(__FILE__) generates an APC namespace prefix
3535
$cachedLoader = new ApcClassLoader(sha1(__FILE__), $loader);
3636

37-
// register the cached class loader
37+
// registers the cached class loader
3838
$cachedLoader->register();
3939

40-
// deactivate the original, non-cached loader if it was registered previously
40+
// deactivates the original, non-cached loader if it was registered previously
4141
$loader->unregister();
4242

4343
XcacheClassLoader
@@ -54,10 +54,10 @@ it is straightforward::
5454
// sha1(__FILE__) generates an XCache namespace prefix
5555
$cachedLoader = new XcacheClassLoader(sha1(__FILE__), $loader);
5656

57-
// register the cached class loader
57+
// registers the cached class loader
5858
$cachedLoader->register();
5959

60-
// deactivate the original, non-cached loader if it was registered previously
60+
// deactivates the original, non-cached loader if it was registered previously
6161
$loader->unregister();
6262

6363
.. _APC: http://php.net/manual/en/book.apc.php

components/class_loader/class_loader.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ your classes::
4040
// register a single namespaces
4141
$loader->addPrefix('Symfony', __DIR__.'/vendor/symfony/symfony/src');
4242

43-
// register several namespaces at once
43+
// registers several namespaces at once
4444
$loader->addPrefixes(array(
4545
'Symfony' => __DIR__.'/../vendor/symfony/symfony/src',
4646
'Monolog' => __DIR__.'/../vendor/monolog/monolog/src',
4747
));
4848

49-
// register a prefix for a class following the PEAR naming conventions
49+
// registers a prefix for a class following the PEAR naming conventions
5050
$loader->addPrefix('Twig_', __DIR__.'/vendor/twig/twig/lib');
5151

5252
$loader->addPrefixes(array(

components/console/events.rst

+13-13
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ dispatched. Listeners receive a
4040
use Symfony\Component\Console\ConsoleEvents;
4141

4242
$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
43-
// get the input instance
43+
// gets the input instance
4444
$input = $event->getInput();
4545

46-
// get the output instance
46+
// gets the output instance
4747
$output = $event->getOutput();
4848

49-
// get the command to be executed
49+
// gets the command to be executed
5050
$command = $event->getCommand();
5151

52-
// write something about the command
52+
// writes something about the command
5353
$output->writeln(sprintf('Before running command <info>%s</info>', $command->getName()));
5454

55-
// get the application
55+
// gets the application
5656
$application = $command->getApplication();
5757
});
5858

@@ -74,12 +74,12 @@ C/C++ standard.::
7474
use Symfony\Component\Console\ConsoleEvents;
7575

7676
$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
77-
// get the command to be executed
77+
// gets the command to be executed
7878
$command = $event->getCommand();
7979

8080
// ... check if the command can be executed
8181

82-
// disable the command, this will result in the command being skipped
82+
// disables the command, this will result in the command being skipped
8383
// and code 113 being returned from the Application
8484
$event->disableCommand();
8585

@@ -112,10 +112,10 @@ Listeners receive a
112112

113113
$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));
114114

115-
// get the current exit code (the exception code or the exit code set by a ConsoleEvents::TERMINATE event)
115+
// gets the current exit code (the exception code or the exit code set by a ConsoleEvents::TERMINATE event)
116116
$exitCode = $event->getExitCode();
117117

118-
// change the exception to another one
118+
// changes the exception to another one
119119
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
120120
});
121121

@@ -138,16 +138,16 @@ Listeners receive a
138138
use Symfony\Component\Console\ConsoleEvents;
139139

140140
$dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) {
141-
// get the output
141+
// gets the output
142142
$output = $event->getOutput();
143143

144-
// get the command that has been executed
144+
// gets the command that has been executed
145145
$command = $event->getCommand();
146146

147-
// display something
147+
// displays the given content
148148
$output->writeln(sprintf('After running command <info>%s</info>', $command->getName()));
149149

150-
// change the exit code
150+
// changes the exit code
151151
$event->setExitCode(128);
152152
});
153153

components/console/helpers/progressbar.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ number of units, and advance the progress as the command executes::
1515

1616
use Symfony\Component\Console\Helper\ProgressBar;
1717

18-
// create a new progress bar (50 units)
18+
// creates a new progress bar (50 units)
1919
$progress = new ProgressBar($output, 50);
2020

21-
// start and displays the progress bar
21+
// starts and displays the progress bar
2222
$progress->start();
2323

2424
$i = 0;
2525
while ($i++ < 50) {
2626
// ... do some work
2727

28-
// advance the progress bar 1 unit
28+
// advances the progress bar 1 unit
2929
$progress->advance();
3030

3131
// you can also advance the progress bar by more than 1 unit
3232
// $progress->advance(3);
3333
}
3434

35-
// ensure that the progress bar is at 100%
35+
// ensures that the progress bar is at 100%
3636
$progress->finish();
3737

3838
Instead of advancing the bar by a number of steps (with the

components/console/helpers/table.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ If the built-in styles do not fit your need, define your own::
111111
// by default, this is based on the default style
112112
$style = new TableStyle();
113113

114-
// customize the style
114+
// customizes the style
115115
$style
116116
->setHorizontalBorderChar('<fg=magenta>|</>')
117117
->setVerticalBorderChar('<fg=magenta>-</>')
118118
->setCrossingChar(' ')
119119
;
120120

121-
// use the style for this table
121+
// uses the custom style for this table
122122
$table->setStyle($style);
123123

124124
Here is a full list of things you can customize:
@@ -136,10 +136,10 @@ Here is a full list of things you can customize:
136136

137137
You can also register a style globally::
138138

139-
// register the style under the colorful name
139+
// registers the style under the colorful name
140140
Table::setStyleDefinition('colorful', $style);
141141

142-
// use it for a table
142+
// applies the custom style for the given table
143143
$table->setStyle('colorful');
144144

145145
This method can also be used to override a built-in style.

components/console/single_command_tool.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ it is possible to remove this need by extending the application::
3535
*/
3636
protected function getDefaultCommands()
3737
{
38-
// Keep the core default commands to have the HelpCommand
38+
// Keeps the core default commands to have the HelpCommand
3939
// which is used when using the --help option
4040
$defaultCommands = parent::getDefaultCommands();
4141

@@ -51,7 +51,7 @@ it is possible to remove this need by extending the application::
5151
public function getDefinition()
5252
{
5353
$inputDefinition = parent::getDefinition();
54-
// clear out the normal first argument, which is the command name
54+
// clears out the normal first argument, which is the command name
5555
$inputDefinition->setArguments();
5656

5757
return $inputDefinition;

components/dom_crawler.rst

+15-15
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ An anonymous function can be used to filter with more complex criteria::
8787
$crawler = $crawler
8888
->filter('body > p')
8989
->reduce(function (Crawler $node, $i) {
90-
// filter every other node
90+
// filters every other node
9191
return ($i % 2) == 0;
9292
});
9393

@@ -196,7 +196,7 @@ Accessing Node Values
196196

197197
Access the node name (HTML tag name) of the first node of the current selection (eg. "p" or "div")::
198198

199-
// will return the node name (HTML tag name) of the first child element under <body>
199+
// returns the node name (HTML tag name) of the first child element under <body>
200200
$tag = $crawler->filterXPath('//body/*')->nodeName();
201201

202202
Access the value of the first node of the current selection::
@@ -317,7 +317,7 @@ instance with just the selected link(s). Calling ``link()`` gives you a special
317317
The :class:`Symfony\\Component\\DomCrawler\\Link` object has several useful
318318
methods to get more information about the selected link itself::
319319

320-
// return the proper URI that can be used to make another request
320+
// returns the proper URI that can be used to make another request
321321
$uri = $link->getUri();
322322

323323
.. note::
@@ -368,13 +368,13 @@ attribute followed by a query string of all of the form's values.
368368

369369
You can virtually set and get values on the form::
370370

371-
// set values on the form internally
371+
// sets values on the form internally
372372
$form->setValues(array(
373373
'registration[username]' => 'symfonyfan',
374374
'registration[terms]' => 1,
375375
));
376376

377-
// get back an array of values - in the "flat" array like above
377+
// gets back an array of values - in the "flat" array like above
378378
$values = $form->getValues();
379379

380380
// returns the values like PHP would see them,
@@ -391,10 +391,10 @@ To work with multi-dimensional fields::
391391

392392
Pass an array of values::
393393

394-
// Set a single field
394+
// sets a single field
395395
$form->setValues(array('multi' => array('value')));
396396

397-
// Set multiple fields at once
397+
// sets multiple fields at once
398398
$form->setValues(array('multi' => array(
399399
1 => 'value',
400400
'dimensional' => 'an other value'
@@ -406,17 +406,17 @@ and uploading files::
406406

407407
$form['registration[username]']->setValue('symfonyfan');
408408

409-
// check or uncheck a checkbox
409+
// checks or unchecks a checkbox
410410
$form['registration[terms]']->tick();
411411
$form['registration[terms]']->untick();
412412

413-
// select an option
413+
// selects an option
414414
$form['registration[birthday][year]']->select(1984);
415415

416-
// select many options from a "multiple" select
416+
// selects many options from a "multiple" select
417417
$form['registration[interests]']->select(array('symfony', 'cookies'));
418418

419-
// even fake a file upload
419+
// fakes a file upload
420420
$form['registration[photo]']->upload('/path/to/lucas.jpg');
421421

422422
Using the Form Data
@@ -445,7 +445,7 @@ directly::
445445

446446
use Goutte\Client;
447447

448-
// make a real request to an external site
448+
// makes a real request to an external site
449449
$client = new Client();
450450
$crawler = $client->request('GET', 'https://github.com/login');
451451

@@ -454,7 +454,7 @@ directly::
454454
$form['login'] = 'symfonyfan';
455455
$form['password'] = 'anypass';
456456

457-
// submit that form
457+
// submits the given form
458458
$crawler = $client->submit($form);
459459

460460
.. _components-dom-crawler-invalid:
@@ -467,10 +467,10 @@ to prevent you from setting invalid values. If you want to be able to set
467467
invalid values, you can use the ``disableValidation()`` method on either
468468
the whole form or specific field(s)::
469469

470-
// Disable validation for a specific field
470+
// disables validation for a specific field
471471
$form['country']->disableValidation()->select('Invalid value');
472472

473-
// Disable validation for the whole form
473+
// disables validation for the whole form
474474
$form->disableValidation();
475475
$form['country']->select('Invalid value');
476476

components/event_dispatcher.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,18 @@ determine which instance is passed.
206206
$containerBuilder = new ContainerBuilder(new ParameterBag());
207207
$containerBuilder->addCompilerPass(new RegisterListenersPass());
208208

209-
// register the event dispatcher service
209+
// registers the event dispatcher service
210210
$containerBuilder->register('event_dispatcher', ContainerAwareEventDispatcher::class)
211211
->addArgument(new Reference('service_container'));
212212

213-
// register your event listener service
213+
// registers your event listener service
214214
$containerBuilder->register('listener_service_id', \AcmeListener::class)
215215
->addTag('kernel.event_listener', array(
216216
'event' => 'acme.foo.action',
217217
'method' => 'onFooAction',
218218
));
219219

220-
// register an event subscriber
220+
// registers an event subscriber
221221
$containerBuilder->register('subscriber_service_id', \AcmeSubscriber::class)
222222
->addTag('kernel.event_subscriber');
223223

@@ -302,7 +302,7 @@ each listener of that event::
302302
$order = new Order();
303303
// ...
304304

305-
// create the OrderPlacedEvent and dispatch it
305+
// creates the OrderPlacedEvent and dispatches it
306306
$event = new OrderPlacedEvent($order);
307307
$dispatcher->dispatch(OrderPlacedEvent::NAME, $event);
308308

components/event_dispatcher/traceable_dispatcher.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ to register event listeners and dispatch events::
2727

2828
// ...
2929

30-
// register an event listener
30+
// registers an event listener
3131
$eventListener = ...;
3232
$priority = ...;
3333
$traceableEventDispatcher->addListener(
@@ -36,7 +36,7 @@ to register event listeners and dispatch events::
3636
$priority
3737
);
3838

39-
// dispatch an event
39+
// dispatches an event
4040
$event = ...;
4141
$traceableEventDispatcher->dispatch('event.the_name', $event);
4242

components/expression_language/extending.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ or by using the second argument of the constructor::
120120
{
121121
public function __construct(ParserCacheInterface $parser = null, array $providers = array())
122122
{
123-
// prepend the default provider to let users override it easily
123+
// prepends the default provider to let users override it easily
124124
array_unshift($providers, new StringExpressionLanguageProvider());
125125

126126
parent::__construct($parser, $providers);

0 commit comments

Comments
 (0)