Skip to content

Commit 219b7f8

Browse files
committed
improve naming
1 parent 3867ab4 commit 219b7f8

File tree

96 files changed

+595
-601
lines changed

Some content is hidden

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

96 files changed

+595
-601
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
@@ -189,9 +189,9 @@ Handling a form submit usually follows a similar template:
189189
$form->handleRequest($request);
190190
191191
if ($form->isSubmitted() && $form->isValid()) {
192-
$em = $this->getDoctrine()->getManager();
193-
$em->persist($post);
194-
$em->flush();
192+
$entityManager = $this->getDoctrine()->getManager();
193+
$entityManager->persist($post);
194+
$entityManager->flush();
195195
196196
return $this->redirect($this->generateUrl(
197197
'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
@@ -169,9 +169,9 @@ that path over and over again::
169169
use Symfony\Component\Asset\PathPackage;
170170
// ...
171171

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

174-
echo $package->getUrl('/logo.png');
174+
echo $pathPackage->getUrl('/logo.png');
175175
// result: /static/images/logo.png?v1
176176

177177
Request Context Aware Assets
@@ -185,13 +185,13 @@ class can take into account the context of the current request::
185185
use Symfony\Component\Asset\Context\RequestStackContext;
186186
// ...
187187

188-
$package = new PathPackage(
188+
$pathPackage = new PathPackage(
189189
'/static/images',
190190
new StaticVersionStrategy('v1'),
191191
new RequestStackContext($requestStack)
192192
);
193193

194-
echo $package->getUrl('/logo.png');
194+
echo $pathPackage->getUrl('/logo.png');
195195
// result: /somewhere/static/images/logo.png?v1
196196

197197
Now that the request context is set, the ``PathPackage`` will prepend the
@@ -212,25 +212,25 @@ class to generate absolute URLs for their assets::
212212
use Symfony\Component\Asset\UrlPackage;
213213
// ...
214214

215-
$package = new UrlPackage(
215+
$urlPackage = new UrlPackage(
216216
'http://static.example.com/images/',
217217
new StaticVersionStrategy('v1')
218218
);
219219

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

223223
You can also pass a schema-agnostic URL::
224224

225225
use Symfony\Component\Asset\UrlPackage;
226226
// ...
227227

228-
$package = new UrlPackage(
228+
$urlPackage = new UrlPackage(
229229
'//static.example.com/images/',
230230
new StaticVersionStrategy('v1')
231231
);
232232

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

236236
This is useful because assets will automatically be requested via HTTPS if
@@ -248,11 +248,11 @@ constructor::
248248
'//static1.example.com/images/',
249249
'//static2.example.com/images/',
250250
);
251-
$package = new UrlPackage($urls, new StaticVersionStrategy('v1'));
251+
$urlPackage = new UrlPackage($urls, new StaticVersionStrategy('v1'));
252252

253-
echo $package->getUrl('/logo.png');
253+
echo $urlPackage->getUrl('/logo.png');
254254
// result: http://static1.example.com/images/logo.png?v1
255-
echo $package->getUrl('/icon.png');
255+
echo $urlPackage->getUrl('/icon.png');
256256
// result: http://static2.example.com/images/icon.png?v1
257257

258258
For each asset, one of the URLs will be randomly used. But, the selection
@@ -271,13 +271,13 @@ protocol-relative URLs for HTTPs requests, any base URL for HTTP requests)::
271271
use Symfony\Component\Asset\Context\RequestStackContext;
272272
// ...
273273

274-
$package = new UrlPackage(
274+
$urlPackage = new UrlPackage(
275275
array('http://example.com/', 'https://example.com/'),
276276
new StaticVersionStrategy('v1'),
277277
new RequestStackContext($requestStack)
278278
);
279279

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

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
@@ -534,8 +534,8 @@ tree with ``append()``::
534534

535535
public function addParametersNode()
536536
{
537-
$builder = new TreeBuilder();
538-
$node = $builder->root('parameters');
537+
$treeBuilder = new TreeBuilder();
538+
$node = $treeBuilder->root('parameters');
539539

540540
$node
541541
->isRequired()
@@ -772,18 +772,18 @@ Otherwise the result is a clean array of configuration values::
772772
use Symfony\Component\Config\Definition\Processor;
773773
use Acme\DatabaseConfiguration;
774774

775-
$config1 = Yaml::parse(
775+
$config = Yaml::parse(
776776
file_get_contents(__DIR__.'/src/Matthias/config/config.yml')
777777
);
778-
$config2 = Yaml::parse(
778+
$extraConfig = Yaml::parse(
779779
file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yml')
780780
);
781781

782-
$configs = array($config1, $config2);
782+
$configs = array($config, $extraConfig);
783783

784784
$processor = new Processor();
785-
$configuration = new DatabaseConfiguration();
785+
$databaseConfiguration = new DatabaseConfiguration();
786786
$processedConfiguration = $processor->processConfiguration(
787-
$configuration,
787+
$databaseConfiguration,
788788
$configs
789789
);

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
$delegatingLoader->load(__DIR__.'/users.yml');

components/console/helpers/dialoghelper.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ You can also ask question with more than a simple yes/no answer. For instance,
5252
if you want to know a bundle name, you can add this to your command::
5353

5454
// ...
55-
$bundle = $dialog->ask(
55+
$bundleName = $dialog->ask(
5656
$output,
5757
'Please enter the name of the bundle',
5858
'AcmeDemoBundle'
@@ -71,7 +71,7 @@ will be autocompleted as the user types::
7171

7272
$dialog = $this->getHelper('dialog');
7373
$bundleNames = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle');
74-
$name = $dialog->ask(
74+
$bundleName = $dialog->ask(
7575
$output,
7676
'Please enter the name of a bundle',
7777
'FooBundle',
@@ -109,7 +109,7 @@ be suffixed with ``Bundle``. You can validate that by using the
109109
method::
110110

111111
// ...
112-
$bundle = $dialog->askAndValidate(
112+
$bundleName = $dialog->askAndValidate(
113113
$output,
114114
'Please enter the name of the bundle',
115115
function ($answer) {

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
Instead of advancing the bar by a number of steps (with the
3939
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::advance` method),
@@ -64,7 +64,7 @@ If you don't know the number of steps in advance, just omit the steps argument
6464
when creating the :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
6565
instance::
6666

67-
$progress = new ProgressBar($output);
67+
$progressBar = new ProgressBar($output);
6868

6969
The progress will then be displayed as a throbber:
7070

@@ -131,7 +131,7 @@ level of verbosity of the ``OutputInterface`` instance:
131131
Instead of relying on the verbosity mode of the current command, you can also
132132
force a format via ``setFormat()``::
133133

134-
$bar->setFormat('verbose');
134+
$progressBar->setFormat('verbose');
135135

136136
The built-in formats are the following:
137137

@@ -153,7 +153,7 @@ Custom Formats
153153

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

156-
$bar->setFormat('%bar%');
156+
$progressBar->setFormat('%bar%');
157157

158158
This sets the format to only display the progress bar itself:
159159

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

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

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

192192
ProgressBar::setFormatDefinition('minimal', 'Progress: %percent%%');
193193

194-
$bar = new ProgressBar($output, 3);
195-
$bar->setFormat('minimal');
194+
$progressBar = new ProgressBar($output, 3);
195+
$progressBar->setFormat('minimal');
196196

197197
This code defines a new ``minimal`` format that you can then use for your
198198
progress bars:
@@ -216,8 +216,8 @@ variant::
216216
ProgressBar::setFormatDefinition('minimal', '%percent%% %remaining%');
217217
ProgressBar::setFormatDefinition('minimal_nomax', '%percent%%');
218218

219-
$bar = new ProgressBar($output);
220-
$bar->setFormat('minimal');
219+
$progressBar = new ProgressBar($output);
220+
$progressBar->setFormat('minimal');
221221

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

248248
// the finished part of the bar
249-
$progress->setBarCharacter('<comment>=</comment>');
249+
$progressBar->setBarCharacter('<comment>=</comment>');
250250

251251
// the unfinished part of the bar
252-
$progress->setEmptyBarCharacter(' ');
252+
$progressBar->setEmptyBarCharacter(' ');
253253

254254
// the progress character
255-
$progress->setProgressCharacter('|');
255+
$progressBar->setProgressCharacter('|');
256256

257257
// the bar width
258-
$progress->setBarWidth(50);
258+
$progressBar->setBarWidth(50);
259259

260260
.. caution::
261261

@@ -265,17 +265,17 @@ to display it can be customized::
265265
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::setRedrawFrequency`,
266266
so it updates on only some iterations::
267267

268-
$progress = new ProgressBar($output, 50000);
269-
$progress->start();
268+
$progressBar = new ProgressBar($output, 50000);
269+
$progressBar->start();
270270

271271
// update every 100 iterations
272-
$progress->setRedrawFrequency(100);
272+
$progressBar->setRedrawFrequency(100);
273273

274274
$i = 0;
275275
while ($i++ < 50000) {
276276
// ... do some work
277277

278-
$progress->advance();
278+
$progressBar->advance();
279279
}
280280

281281
Custom Placeholders
@@ -288,8 +288,8 @@ that displays the number of remaining steps::
288288

289289
ProgressBar::setPlaceholderFormatterDefinition(
290290
'remaining_steps',
291-
function (ProgressBar $bar, OutputInterface $output) {
292-
return $bar->getMaxSteps() - $bar->getProgress();
291+
function (ProgressBar $progressBar, OutputInterface $output) {
292+
return $progressBar->getMaxSteps() - $progressBar->getProgress();
293293
}
294294
);
295295

0 commit comments

Comments
 (0)