Skip to content

Commit 22fd27b

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Clarify unanimous access strategy description Improved variable naming
2 parents f7df95f + 02da88e commit 22fd27b

File tree

94 files changed

+571
-575
lines changed

Some content is hidden

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

94 files changed

+571
-575
lines changed

best_practices/configuration.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,20 @@ to control the number of posts to display on the blog homepage:
101101
102102
# app/config/config.yml
103103
parameters:
104-
homepage.num_items: 10
104+
homepage.number_of_items: 10
105105
106106
If you've done something like this in the past, it's likely that you've in fact
107107
*never* actually needed to change that value. Creating a configuration
108108
option for a value that you are never going to configure just isn't necessary.
109109
Our recommendation is to define these values as constants in your application.
110-
You could, for example, define a ``NUM_ITEMS`` constant in the ``Post`` entity::
110+
You could, for example, define a ``NUMBER_OF_ITEMS`` constant in the ``Post`` entity::
111111

112112
// src/AppBundle/Entity/Post.php
113113
namespace AppBundle\Entity;
114114

115115
class Post
116116
{
117-
const NUM_ITEMS = 10;
117+
const NUMBER_OF_ITEMS = 10;
118118

119119
// ...
120120
}
@@ -129,7 +129,7 @@ Constants can be used for example in your Twig templates thanks to the
129129
.. code-block:: html+twig
130130

131131
<p>
132-
Displaying the {{ constant('NUM_ITEMS', post) }} most recent results.
132+
Displaying the {{ constant('NUMBER_OF_ITEMS', post) }} most recent results.
133133
</p>
134134

135135
And Doctrine entities and repositories can now easily access these values,
@@ -144,7 +144,7 @@ whereas they cannot access the container parameters:
144144
145145
class PostRepository extends EntityRepository
146146
{
147-
public function findLatest($limit = Post::NUM_ITEMS)
147+
public function findLatest($limit = Post::NUMBER_OF_ITEMS)
148148
{
149149
// ...
150150
}

best_practices/forms.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ Handling a form submit usually follows a similar template:
184184
$form->handleRequest($request);
185185
186186
if ($form->isSubmitted() && $form->isValid()) {
187-
$em = $this->getDoctrine()->getManager();
188-
$em->persist($post);
189-
$em->flush();
187+
$entityManager = $this->getDoctrine()->getManager();
188+
$entityManager->persist($post);
189+
$entityManager->flush();
190190
191191
return $this->redirect($this->generateUrl(
192192
'admin_post_show',

bundles/configuration.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ In your extension, you can load this and dynamically set its arguments::
269269
$configuration = new Configuration();
270270
$config = $this->processConfiguration($configuration, $configs);
271271

272-
$def = $container->getDefinition('acme.social.twitter_client');
273-
$def->replaceArgument(0, $config['twitter']['client_id']);
274-
$def->replaceArgument(1, $config['twitter']['client_secret']);
272+
$definition = $container->getDefinition('acme.social.twitter_client');
273+
$definition->replaceArgument(0, $config['twitter']['client_id']);
274+
$definition->replaceArgument(1, $config['twitter']['client_secret']);
275275
}
276276

277277
.. tip::

components/asset.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ that path over and over again::
179179
use Symfony\Component\Asset\PathPackage;
180180
// ...
181181

182-
$package = new PathPackage('/static/images', new StaticVersionStrategy('v1'));
182+
$pathPackage = new PathPackage('/static/images', new StaticVersionStrategy('v1'));
183183

184-
echo $package->getUrl('logo.png');
184+
echo $pathPackage->getUrl('logo.png');
185185
// result: /static/images/logo.png?v1
186186

187187
// Base path is ignored when using absolute paths
@@ -199,13 +199,13 @@ class can take into account the context of the current request::
199199
use Symfony\Component\Asset\Context\RequestStackContext;
200200
// ...
201201

202-
$package = new PathPackage(
202+
$pathPackage = new PathPackage(
203203
'/static/images',
204204
new StaticVersionStrategy('v1'),
205205
new RequestStackContext($requestStack)
206206
);
207207

208-
echo $package->getUrl('logo.png');
208+
echo $pathPackage->getUrl('logo.png');
209209
// result: /somewhere/static/images/logo.png?v1
210210

211211
// Both "base path" and "base url" are ignored when using absolute path for asset
@@ -230,25 +230,25 @@ class to generate absolute URLs for their assets::
230230
use Symfony\Component\Asset\UrlPackage;
231231
// ...
232232

233-
$package = new UrlPackage(
233+
$urlPackage = new UrlPackage(
234234
'http://static.example.com/images/',
235235
new StaticVersionStrategy('v1')
236236
);
237237

238-
echo $package->getUrl('/logo.png');
238+
echo $urlPackage->getUrl('/logo.png');
239239
// result: http://static.example.com/images/logo.png?v1
240240

241241
You can also pass a schema-agnostic URL::
242242

243243
use Symfony\Component\Asset\UrlPackage;
244244
// ...
245245

246-
$package = new UrlPackage(
246+
$urlPackage = new UrlPackage(
247247
'//static.example.com/images/',
248248
new StaticVersionStrategy('v1')
249249
);
250250

251-
echo $package->getUrl('/logo.png');
251+
echo $urlPackage->getUrl('/logo.png');
252252
// result: //static.example.com/images/logo.png?v1
253253

254254
This is useful because assets will automatically be requested via HTTPS if
@@ -266,11 +266,11 @@ constructor::
266266
'//static1.example.com/images/',
267267
'//static2.example.com/images/',
268268
);
269-
$package = new UrlPackage($urls, new StaticVersionStrategy('v1'));
269+
$urlPackage = new UrlPackage($urls, new StaticVersionStrategy('v1'));
270270

271-
echo $package->getUrl('/logo.png');
271+
echo $urlPackage->getUrl('/logo.png');
272272
// result: http://static1.example.com/images/logo.png?v1
273-
echo $package->getUrl('/icon.png');
273+
echo $urlPackage->getUrl('/icon.png');
274274
// result: http://static2.example.com/images/icon.png?v1
275275

276276
For each asset, one of the URLs will be randomly used. But, the selection
@@ -289,13 +289,13 @@ protocol-relative URLs for HTTPs requests, any base URL for HTTP requests)::
289289
use Symfony\Component\Asset\Context\RequestStackContext;
290290
// ...
291291

292-
$package = new UrlPackage(
292+
$urlPackage = new UrlPackage(
293293
array('http://example.com/', 'https://example.com/'),
294294
new StaticVersionStrategy('v1'),
295295
new RequestStackContext($requestStack)
296296
);
297297

298-
echo $package->getUrl('/logo.png');
298+
echo $urlPackage->getUrl('/logo.png');
299299
// assuming the RequestStackContext says that we are on a secure host
300300
// result: https://example.com/logo.png?v1
301301

components/browser_kit.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ retrieve any cookie while making requests with the client::
140140
// Get cookie data
141141
$name = $cookie->getName();
142142
$value = $cookie->getValue();
143-
$raw = $cookie->getRawValue();
144-
$secure = $cookie->isSecure();
143+
$rawValue = $cookie->getRawValue();
144+
$isSecure = $cookie->isSecure();
145145
$isHttpOnly = $cookie->isHttpOnly();
146146
$isExpired = $cookie->isExpired();
147147
$expires = $cookie->getExpiresTime();

components/config/definition.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ tree with ``append()``::
574574

575575
public function addParametersNode()
576576
{
577-
$builder = new TreeBuilder();
578-
$node = $builder->root('parameters');
577+
$treeBuilder = new TreeBuilder();
578+
$node = $treeBuilder->root('parameters');
579579

580580
$node
581581
->isRequired()
@@ -812,18 +812,18 @@ Otherwise the result is a clean array of configuration values::
812812
use Symfony\Component\Config\Definition\Processor;
813813
use Acme\DatabaseConfiguration;
814814

815-
$config1 = Yaml::parse(
815+
$config = Yaml::parse(
816816
file_get_contents(__DIR__.'/src/Matthias/config/config.yml')
817817
);
818-
$config2 = Yaml::parse(
818+
$extraConfig = Yaml::parse(
819819
file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yml')
820820
);
821821

822-
$configs = array($config1, $config2);
822+
$configs = array($config, $extraConfig);
823823

824824
$processor = new Processor();
825-
$configuration = new DatabaseConfiguration();
825+
$databaseConfiguration = new DatabaseConfiguration();
826826
$processedConfiguration = $processor->processConfiguration(
827-
$configuration,
827+
$databaseConfiguration,
828828
$configs
829829
);

components/config/resources.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ files. This can be done with the :class:`Symfony\\Component\\Config\\FileLocator
2121

2222
$configDirectories = array(__DIR__.'/app/config');
2323

24-
$locator = new FileLocator($configDirectories);
25-
$yamlUserFiles = $locator->locate('users.yml', null, false);
24+
$fileLocator = new FileLocator($configDirectories);
25+
$yamlUserFiles = $fileLocator->locate('users.yml', null, false);
2626

2727
The locator receives a collection of locations where it should look for
2828
files. The first argument of ``locate()`` is the name of the file to look
@@ -84,7 +84,7 @@ the resource::
8484
use Symfony\Component\Config\Loader\LoaderResolver;
8585
use Symfony\Component\Config\Loader\DelegatingLoader;
8686

87-
$loaderResolver = new LoaderResolver(array(new YamlUserLoader($locator)));
87+
$loaderResolver = new LoaderResolver(array(new YamlUserLoader($fileLocator)));
8888
$delegatingLoader = new DelegatingLoader($loaderResolver);
8989

9090
// YamlUserLoader is used to load this resource because it supports

components/console/helpers/progressbar.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ number of units, and advance the progress as the command executes::
1616
use Symfony\Component\Console\Helper\ProgressBar;
1717

1818
// creates a new progress bar (50 units)
19-
$progress = new ProgressBar($output, 50);
19+
$progressBar = new ProgressBar($output, 50);
2020

2121
// starts and displays the progress bar
22-
$progress->start();
22+
$progressBar->start();
2323

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

2828
// advances the progress bar 1 unit
29-
$progress->advance();
29+
$progressBar->advance();
3030

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

3535
// ensures that the progress bar is at 100%
36-
$progress->finish();
36+
$progressBar->finish();
3737

3838
.. tip::
3939

@@ -59,7 +59,7 @@ If you don't know the number of steps in advance, just omit the steps argument
5959
when creating the :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
6060
instance::
6161

62-
$progress = new ProgressBar($output);
62+
$progressBar = new ProgressBar($output);
6363

6464
The progress will then be displayed as a throbber:
6565

@@ -126,7 +126,7 @@ level of verbosity of the ``OutputInterface`` instance:
126126
Instead of relying on the verbosity mode of the current command, you can also
127127
force a format via ``setFormat()``::
128128

129-
$bar->setFormat('verbose');
129+
$progressBar->setFormat('verbose');
130130

131131
The built-in formats are the following:
132132

@@ -148,7 +148,7 @@ Custom Formats
148148

149149
Instead of using the built-in formats, you can also set your own::
150150

151-
$bar->setFormat('%bar%');
151+
$progressBar->setFormat('%bar%');
152152

153153
This sets the format to only display the progress bar itself:
154154

@@ -175,7 +175,7 @@ current progress of the bar. Here is a list of the built-in placeholders:
175175
For instance, here is how you could set the format to be the same as the
176176
``debug`` one::
177177

178-
$bar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
178+
$progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
179179

180180
Notice the ``:6s`` part added to some placeholders? That's how you can tweak
181181
the appearance of the bar (formatting and alignment). The part after the colon
@@ -186,8 +186,8 @@ also define global formats::
186186

187187
ProgressBar::setFormatDefinition('minimal', 'Progress: %percent%%');
188188

189-
$bar = new ProgressBar($output, 3);
190-
$bar->setFormat('minimal');
189+
$progressBar = new ProgressBar($output, 3);
190+
$progressBar->setFormat('minimal');
191191

192192
This code defines a new ``minimal`` format that you can then use for your
193193
progress bars:
@@ -211,8 +211,8 @@ variant::
211211
ProgressBar::setFormatDefinition('minimal', '%percent%% %remaining%');
212212
ProgressBar::setFormatDefinition('minimal_nomax', '%percent%%');
213213

214-
$bar = new ProgressBar($output);
215-
$bar->setFormat('minimal');
214+
$progressBar = new ProgressBar($output);
215+
$progressBar->setFormat('minimal');
216216

217217
When displaying the progress bar, the format will automatically be set to
218218
``minimal_nomax`` if the bar does not have a maximum number of steps like in
@@ -241,16 +241,16 @@ Amongst the placeholders, ``bar`` is a bit special as all the characters used
241241
to display it can be customized::
242242

243243
// the finished part of the bar
244-
$progress->setBarCharacter('<comment>=</comment>');
244+
$progressBar->setBarCharacter('<comment>=</comment>');
245245

246246
// the unfinished part of the bar
247-
$progress->setEmptyBarCharacter(' ');
247+
$progressBar->setEmptyBarCharacter(' ');
248248

249249
// the progress character
250-
$progress->setProgressCharacter('|');
250+
$progressBar->setProgressCharacter('|');
251251

252252
// the bar width
253-
$progress->setBarWidth(50);
253+
$progressBar->setBarWidth(50);
254254

255255
.. caution::
256256

@@ -260,17 +260,17 @@ to display it can be customized::
260260
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::setRedrawFrequency`,
261261
so it updates on only some iterations::
262262

263-
$progress = new ProgressBar($output, 50000);
264-
$progress->start();
263+
$progressBar = new ProgressBar($output, 50000);
264+
$progressBar->start();
265265

266266
// update every 100 iterations
267-
$progress->setRedrawFrequency(100);
267+
$progressBar->setRedrawFrequency(100);
268268

269269
$i = 0;
270270
while ($i++ < 50000) {
271271
// ... do some work
272272

273-
$progress->advance();
273+
$progressBar->advance();
274274
}
275275

276276
Custom Placeholders
@@ -283,8 +283,8 @@ that displays the number of remaining steps::
283283

284284
ProgressBar::setPlaceholderFormatterDefinition(
285285
'remaining_steps',
286-
function (ProgressBar $bar, OutputInterface $output) {
287-
return $bar->getMaxSteps() - $bar->getProgress();
286+
function (ProgressBar $progressBar, OutputInterface $output) {
287+
return $progressBar->getMaxSteps() - $progressBar->getProgress();
288288
}
289289
);
290290

0 commit comments

Comments
 (0)