Skip to content

Improve naming in documentation #9423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion best_practices/business-logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ looking for mapping information::
*/
class Post
{
const NUM_ITEMS = 10;
const NUMBER_OF_ITEMS = 10;

/**
* @ORM\Id
Expand Down
4 changes: 1 addition & 3 deletions best_practices/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ Markdown content into HTML::

public function toHtml($text)
{
$html = $this->parser->text($text);

return $html;
return $this->parser->text($text);
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Your integration with the Validation component will look something like this::
use Symfony\Component\Validator\Validation;

$vendorDirectory = realpath(__DIR__.'/../vendor');
$vendorFormDirectory = $vendorDir.'/symfony/form';
$vendorFormDirectory = $vendorDirectory.'/symfony/form';
$vendorValidatorDirectory = $vendorDirectory.'/symfony/validator';

// creates the validator - details will vary
Expand Down
12 changes: 6 additions & 6 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`::

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

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

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

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

Expand Down
3 changes: 1 addition & 2 deletions console/commands_as_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ store the default value in some ``%command.default_name%`` parameter::
{
// try to avoid work here (e.g. database query)
// this method is *always* called - see warning below
$defaultName = $this->defaultName;

$this
->setName('demo:greet')
Expand All @@ -108,7 +107,7 @@ store the default value in some ``%command.default_name%`` parameter::
'-n',
InputOption::VALUE_REQUIRED,
'Who do you want to greet?',
$defaultName
$this->defaultName
)
;
}
Expand Down
2 changes: 1 addition & 1 deletion controller/soap_web_service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Below is an example calling the service using a `NuSOAP`_ client. This example
assumes that the ``indexAction()`` in the controller above is accessible via the
route ``/soap``::

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

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

Expand Down
4 changes: 2 additions & 2 deletions event_dispatcher/class_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ use this pattern of class extension::
/**
* Sets the value to return and stops other listeners from being notified
*/
public function setReturnValue($val)
public function setReturnValue($returnValue)
{
$this->returnValue = $val;
$this->returnValue = $returnValue;
$this->isProcessed = true;
$this->stopPropagation();
}
Expand Down
6 changes: 3 additions & 3 deletions form/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,20 @@ make sure the ``FormRegistry`` uses the created instance::

class TestedTypeTest extends TypeTestCase
{
private $entityManager;
private $objectManager;

protected function setUp()
{
// mock any dependencies
$this->entityManager = $this->createMock(ObjectManager::class);
$this->objectManager = $this->createMock(ObjectManager::class);

parent::setUp();
}

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

return array(
// register the type instances with the PreloadedExtension
Expand Down
6 changes: 3 additions & 3 deletions routing/custom_route_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ and configure the service and method to call:
// app/config/routing.php
use Symfony\Component\Routing\RouteCollection;

$collection = new RouteCollection();
$collection->addCollection(
$routes = new RouteCollection();
$routes->addCollection(
$loader->import("admin_route_loader:loadRoutes", "service")
);

return $collection;
return $routes;

In this example, the routes are loaded by calling the ``loadRoutes()`` method of
the service whose ID is ``admin_route_loader``. Your service doesn't have to
Expand Down
18 changes: 9 additions & 9 deletions security/custom_authentication_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ the ``PasswordDigest`` header value matches with the user's password::
class WsseProvider implements AuthenticationProviderInterface
{
private $userProvider;
private $cacheDir;
private $cacheDirectory;

public function __construct(UserProviderInterface $userProvider, $cacheDir)
public function __construct(UserProviderInterface $userProvider, $cacheDirectory)
{
$this->userProvider = $userProvider;
$this->cacheDir = $cacheDir;
$this->userProvider = $userProvider;
$this->cacheDirectory = $cacheDirectory;
}

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

// Validate Secret
$expected = base64_encode(sha1(base64_decode($nonce).$created.$secret, true));
Expand Down
6 changes: 3 additions & 3 deletions security/custom_password_authenticator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ the user::
throw new CustomUserMessageAuthenticationException('Invalid username or password');
}

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

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

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

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

This is a service that is already available in Symfony and it uses the password algorithm
that is configured in the security configuration (e.g. ``security.yml``) under
Expand Down
6 changes: 3 additions & 3 deletions security/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ Additionally, you have access to a number of functions inside the expression:
use Symfony\Component\ExpressionLanguage\Expression;
// ...

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

$access2 = $ac->isGranted(new Expression(
$access2 = $authorizationChecker->isGranted(new Expression(
'is_remember_me() or is_fully_authenticated()'
));

Expand Down
4 changes: 2 additions & 2 deletions security/guard_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ Customizing Error Messages
--------------------------

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

But, you can easily return a custom message by throwing a
Expand Down