Skip to content

Commit 87d9046

Browse files
committed
improve naming
1 parent 2b3c6d9 commit 87d9046

13 files changed

+36
-39
lines changed

best_practices/business-logic.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ looking for mapping information::
211211
*/
212212
class Post
213213
{
214-
const NUM_ITEMS = 10;
214+
const NUMBER_OF_ITEMS = 10;
215215

216216
/**
217217
* @ORM\Id

best_practices/templates.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ Markdown content into HTML::
107107

108108
public function toHtml($text)
109109
{
110-
$html = $this->parser->text($text);
111-
112-
return $html;
110+
return $this->parser->text($text);
113111
}
114112
}
115113

components/form.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Your integration with the Validation component will look something like this::
307307
use Symfony\Component\Validator\Validation;
308308

309309
$vendorDirectory = realpath(__DIR__.'/../vendor');
310-
$vendorFormDirectory = $vendorDir.'/symfony/form';
310+
$vendorFormDirectory = $vendorDirectory.'/symfony/form';
311311
$vendorValidatorDirectory = $vendorDirectory.'/symfony/validator';
312312

313313
// creates the validator - details will vary

components/serializer.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,14 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`::
407407

408408
$serializer = new Serializer(array($normalizer), array(new JsonEncoder()));
409409

410-
$obj = new Company();
411-
$obj->name = 'Acme Inc.';
412-
$obj->address = '123 Main Street, Big City';
410+
$company = new Company();
411+
$company->name = 'Acme Inc.';
412+
$company->address = '123 Main Street, Big City';
413413

414-
$json = $serializer->serialize($obj, 'json');
414+
$json = $serializer->serialize($company, 'json');
415415
// {"org_name": "Acme Inc.", "org_address": "123 Main Street, Big City"}
416-
$objCopy = $serializer->deserialize($json, Company::class, 'json');
417-
// Same data as $obj
416+
$companyCopy = $serializer->deserialize($json, Company::class, 'json');
417+
// Same data as $company
418418

419419
.. _using-camelized-method-names-for-underscored-attributes:
420420

console/commands_as_services.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ store the default value in some ``%command.default_name%`` parameter::
9898
{
9999
// try to avoid work here (e.g. database query)
100100
// this method is *always* called - see warning below
101-
$defaultName = $this->defaultName;
102101

103102
$this
104103
->setName('demo:greet')
@@ -108,7 +107,7 @@ store the default value in some ``%command.default_name%`` parameter::
108107
'-n',
109108
InputOption::VALUE_REQUIRED,
110109
'Who do you want to greet?',
111-
$defaultName
110+
$this->defaultName
112111
)
113112
;
114113
}

controller/soap_web_service.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Below is an example calling the service using a `NuSOAP`_ client. This example
131131
assumes that the ``indexAction()`` in the controller above is accessible via the
132132
route ``/soap``::
133133

134-
$soapClient = new \Soapclient('http://example.com/app.php/soap?wsdl');
134+
$soapClient = new \SoapClient('http://example.com/app.php/soap?wsdl');
135135

136136
$result = $soapClient->call('hello', array('name' => 'Scott'));
137137

event_dispatcher/class_extension.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ use this pattern of class extension::
6666
/**
6767
* Sets the value to return and stops other listeners from being notified
6868
*/
69-
public function setReturnValue($val)
69+
public function setReturnValue($returnValue)
7070
{
71-
$this->returnValue = $val;
71+
$this->returnValue = $returnValue;
7272
$this->isProcessed = true;
7373
$this->stopPropagation();
7474
}

form/unit_testing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,20 @@ make sure the ``FormRegistry`` uses the created instance::
131131

132132
class TestedTypeTest extends TypeTestCase
133133
{
134-
private $entityManager;
134+
private $objectManager;
135135

136136
protected function setUp()
137137
{
138138
// mock any dependencies
139-
$this->entityManager = $this->createMock(ObjectManager::class);
139+
$this->objectManager = $this->createMock(ObjectManager::class);
140140

141141
parent::setUp();
142142
}
143143

144144
protected function getExtensions()
145145
{
146146
// create a type instance with the mocked dependencies
147-
$type = new TestedType($this->entityManager);
147+
$type = new TestedType($this->objectManager);
148148

149149
return array(
150150
// register the type instances with the PreloadedExtension

routing/custom_route_loader.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ and configure the service and method to call:
9898
// app/config/routing.php
9999
use Symfony\Component\Routing\RouteCollection;
100100
101-
$collection = new RouteCollection();
102-
$collection->addCollection(
101+
$routes = new RouteCollection();
102+
$routes->addCollection(
103103
$loader->import("admin_route_loader:loadRoutes", "service")
104104
);
105105
106-
return $collection;
106+
return $routes;
107107
108108
In this example, the routes are loaded by calling the ``loadRoutes()`` method of
109109
the service whose ID is ``admin_route_loader``. Your service doesn't have to

security/custom_authentication_provider.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ the ``PasswordDigest`` header value matches with the user's password::
212212
class WsseProvider implements AuthenticationProviderInterface
213213
{
214214
private $userProvider;
215-
private $cacheDir;
215+
private $cacheDirectory;
216216

217-
public function __construct(UserProviderInterface $userProvider, $cacheDir)
217+
public function __construct(UserProviderInterface $userProvider, $cacheDirectory)
218218
{
219-
$this->userProvider = $userProvider;
220-
$this->cacheDir = $cacheDir;
219+
$this->userProvider = $userProvider;
220+
$this->cacheDirectory = $cacheDirectory;
221221
}
222222

223223
public function authenticate(TokenInterface $token)
@@ -255,16 +255,16 @@ the ``PasswordDigest`` header value matches with the user's password::
255255
// Validate that the nonce is *not* used in the last 5 minutes
256256
// if it has, this could be a replay attack
257257
if (
258-
file_exists($this->cacheDir.'/'.md5($nonce))
259-
&& file_get_contents($this->cacheDir.'/'.md5($nonce)) + 300 > time()
258+
file_exists($this->cacheDirectory.'/'.md5($nonce))
259+
&& file_get_contents($this->cacheDirectory.'/'.md5($nonce)) + 300 > time()
260260
) {
261261
throw new NonceExpiredException('Previously used nonce detected');
262262
}
263263
// If cache directory does not exist we create it
264-
if (!is_dir($this->cacheDir)) {
265-
mkdir($this->cacheDir, 0777, true);
264+
if (!is_dir($this->cacheDirectory)) {
265+
mkdir($this->cacheDirectory, 0777, true);
266266
}
267-
file_put_contents($this->cacheDir.'/'.md5($nonce), time());
267+
file_put_contents($this->cacheDirectory.'/'.md5($nonce), time());
268268

269269
// Validate Secret
270270
$expected = base64_encode(sha1(base64_decode($nonce).$created.$secret, true));

security/custom_password_authenticator.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ the user::
5858
throw new CustomUserMessageAuthenticationException('Invalid username or password');
5959
}
6060

61-
$passwordValid = $this->encoder->isPasswordValid($user, $token->getCredentials());
61+
$isPasswordValid = $this->encoder->isPasswordValid($user, $token->getCredentials());
6262

63-
if ($passwordValid) {
63+
if ($isPasswordValid) {
6464
$currentHour = date('G');
6565
if ($currentHour < 14 || $currentHour > 16) {
6666
// CAUTION: this message will be returned to the client
@@ -142,7 +142,7 @@ inside of it.
142142

143143
Inside this method, the password encoder is needed to check the password's validity::
144144

145-
$passwordValid = $this->encoder->isPasswordValid($user, $token->getCredentials());
145+
$isPasswordValid = $this->encoder->isPasswordValid($user, $token->getCredentials());
146146

147147
This is a service that is already available in Symfony and it uses the password algorithm
148148
that is configured in the security configuration (e.g. ``security.yml``) under

security/expressions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ Additionally, you have access to a number of functions inside the expression:
7575
use Symfony\Component\ExpressionLanguage\Expression;
7676
// ...
7777

78-
$ac = $this->get('security.authorization_checker');
79-
$access1 = $ac->isGranted('IS_AUTHENTICATED_REMEMBERED');
78+
$authorizationChecker = $this->get('security.authorization_checker');
79+
$access1 = $authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED');
8080

81-
$access2 = $ac->isGranted(new Expression(
81+
$access2 = $authorizationChecker->isGranted(new Expression(
8282
'is_remember_me() or is_fully_authenticated()'
8383
));
8484

security/guard_authentication.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ Customizing Error Messages
442442
--------------------------
443443

444444
When ``onAuthenticationFailure()`` is called, it is passed an ``AuthenticationException``
445-
that describes *how* authentication failed via its ``$e->getMessageKey()`` (and
446-
``$e->getMessageData()``) method. The message will be different based on *where*
445+
that describes *how* authentication failed via its ``$exception->getMessageKey()`` (and
446+
``$exception->getMessageData()``) method. The message will be different based on *where*
447447
authentication fails (i.e. ``getUser()`` versus ``checkCredentials()``).
448448

449449
But, you can easily return a custom message by throwing a

0 commit comments

Comments
 (0)