Skip to content

Improve naming in documentation #9430

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 13, 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
38 changes: 19 additions & 19 deletions components/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,43 @@ instantiate :class:`Symfony\\Component\\Cache\\Simple\\FilesystemCache`::
Now you can create, retrieve, update and delete items using this object::

// save a new item in the cache
$cache->set('stats.num_products', 4711);
$cache->set('stats.products_count', 4711);

// or set it with a custom ttl
// $cache->set('stats.num_products', 4711, 3600);
// $cache->set('stats.products_count', 4711, 3600);

// retrieve the cache item
if (!$cache->has('stats.num_products')) {
if (!$cache->has('stats.products_count')) {
// ... item does not exists in the cache
}

// retrieve the value stored by the item
$numProducts = $cache->get('stats.num_products');
$productsCount = $cache->get('stats.products_count');

// or specify a default value, if the key doesn't exist
// $numProducts = $cache->get('stats.num_products', 100);
// $productsCount = $cache->get('stats.products_count', 100);

// remove the cache key
$cache->delete('stats.num_products');
$cache->delete('stats.products_count');

// clear *all* cache keys
$cache->clear();

You can also work with multiple items at once::

$cache->setMultiple(array(
'stats.num_products' => 4711,
'stats.num_users' => 1356,
'stats.products_count' => 4711,
'stats.users_count' => 1356,
));

$stats = $cache->getMultiple(array(
'stats.num_products',
'stats.num_users',
'stats.products_count',
'stats.users_count',
));

$cache->deleteMultiple(array(
'stats.num_products',
'stats.num_users',
'stats.products_count',
'stats.users_count',
));

Available Simple Cache (PSR-16) Classes
Expand Down Expand Up @@ -162,22 +162,22 @@ a filesystem-based cache, instantiate :class:`Symfony\\Component\\Cache\\Adapter
Now you can create, retrieve, update and delete items using this cache pool::

// create a new item by trying to get it from the cache
$numProducts = $cache->getItem('stats.num_products');
$productsCount = $cache->getItem('stats.products_count');

// assign a value to the item and save it
$numProducts->set(4711);
$cache->save($numProducts);
$productsCount->set(4711);
$cache->save($productsCount);

// retrieve the cache item
$numProducts = $cache->getItem('stats.num_products');
if (!$numProducts->isHit()) {
$productsCount = $cache->getItem('stats.products_count');
if (!$productsCount->isHit()) {
// ... item does not exists in the cache
}
// retrieve the value stored by the item
$total = $numProducts->get();
$total = $productsCount->get();

// remove the cache item
$cache->deleteItem('stats.num_products');
$cache->deleteItem('stats.products_count');

For a list of all of the supported adapters, see :doc:`/components/cache/cache_pools`.

Expand Down
2 changes: 1 addition & 1 deletion components/cache/adapters/doctrine_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ third parameters::

$provider = new SQLite3Cache(new \SQLite3(__DIR__.'/cache/data.sqlite'), 'youTableName');

$symfonyCache = new DoctrineAdapter(
$cache = new DoctrineAdapter(

// a cache provider instance
CacheProvider $provider,
Expand Down
6 changes: 3 additions & 3 deletions components/cache/adapters/php_array_cache_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ that is optimized and preloaded into OPcache memory storage::
if ($needsWarmup) {
// some static values
$values = array(
'stats.num_products' => 4711,
'stats.num_users' => 1356,
'stats.products_count' => 4711,
'stats.users_count' => 1356,
);

$cache = new PhpArrayAdapter(
Expand All @@ -29,7 +29,7 @@ that is optimized and preloaded into OPcache memory storage::
}

// ... then, use the cache!
$cacheItem = $cache->getItem('stats.num_users');
$cacheItem = $cache->getItem('stats.users_count');
echo $cacheItem->get();

.. note::
Expand Down
10 changes: 5 additions & 5 deletions components/cache/cache_items.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ Cache items are created with the ``getItem($key)`` method of the cache pool. The
argument is the key of the item::

// $cache pool object was created before
$numProducts = $cache->getItem('stats.num_products');
$productsCount = $cache->getItem('stats.products_count');

Then, use the :method:`Psr\\Cache\\CacheItemInterface::set` method to set
the data stored in the cache item::

// storing a simple integer
$numProducts->set(4711);
$cache->save($numProducts);
$productsCount->set(4711);
$cache->save($productsCount);

// storing an array
$numProducts->set(array(
$productsCount->set(array(
'category1' => 4711,
'category2' => 2387,
));
$cache->save($numProducts);
$cache->save($productsCount);

The key and the value of any given cache item can be obtained with the
corresponding *getter* methods::
Expand Down
6 changes: 3 additions & 3 deletions components/filesystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ The :method:`Symfony\\Component\\Filesystem\\Filesystem::readlink` method provid
by the Filesystem component always behaves in the same way::

// returns the next direct target of the link without considering the existence of the target
$fs->readlink('/path/to/link');
$fileSystem->readlink('/path/to/link');

// returns its absolute fully resolved final version of the target (if there are nested links, they are resolved)
$fs->readlink('/path/to/link', true);
$fileSystem->readlink('/path/to/link', true);

Its behavior is the following::

Expand Down Expand Up @@ -304,7 +304,7 @@ appendToFile
:method:`Symfony\\Component\\Filesystem\\Filesystem::appendToFile` adds new
contents at the end of some file::

$fs->appendToFile('logs.txt', 'Email sent to user@example.com');
$fileSystem->appendToFile('logs.txt', 'Email sent to user@example.com');

If either the file or its containing directory doesn't exist, this method
creates them before appending the contents.
Expand Down
8 changes: 4 additions & 4 deletions components/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ delete existing ones::
'objectClass' => array('inetOrgPerson'),
));

$em = $ldap->getEntryManager();
$entityManager = $ldap->getEntryManager();

// Creating a new entry
$em->add($entry);
$entityManager->add($entry);

// Finding and updating an existing entry
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
$result = $query->execute();
$entry = $result[0];
$entry->setAttribute('email', array('fabpot@symfony.com'));
$em->update($entry);
$entityManager->update($entry);

// Removing an existing entry
$em->remove(new Entry('cn=Test User,dc=symfony,dc=com'));
$entityManager->remove(new Entry('cn=Test User,dc=symfony,dc=com'));

.. _Packagist: https://packagist.org/packages/symfony/ldap
12 changes: 6 additions & 6 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ routes with UTF-8 characters:
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

$collection = new RouteCollection();
$collection->add('route1', new Route('/category/{name}',
$routes = new RouteCollection();
$routes->add('route1', new Route('/category/{name}',
array(
'_controller' => 'AppBundle:Default:category',
),
Expand All @@ -426,7 +426,7 @@ routes with UTF-8 characters:

// ...

return $collection;
return $routes;

In this route, the ``utf8`` option set to ``true`` makes Symfony consider the
``.`` requirement to match any UTF-8 characters instead of just a single
Expand Down Expand Up @@ -494,8 +494,8 @@ You can also include UTF-8 strings as routing requirements:
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

$collection = new RouteCollection();
$collection->add('route2', new Route('/default/{default}',
$routes = new RouteCollection();
$routes->add('route2', new Route('/default/{default}',
array(
'_controller' => 'AppBundle:Default:default',
),
Expand All @@ -509,7 +509,7 @@ You can also include UTF-8 strings as routing requirements:

// ...

return $collection;
return $routes;

.. tip::

Expand Down
10 changes: 5 additions & 5 deletions console/lazy_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ with command names as keys and service identifiers as values::
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;

$container = new ContainerBuilder();
$container->register(FooCommand::class, FooCommand::class);
$container->compile();
$containerBuilder = new ContainerBuilder();
$containerBuilder->register(FooCommand::class, FooCommand::class);
$containerBuilder->compile();

$commandLoader = new ContainerCommandLoader($container, array(
$commandLoader = new ContainerCommandLoader($containerBuilder, array(
'app:foo' => FooCommand::class,
));

Like this, executing the ``app:foo`` command will load the ``FooCommand`` service
by calling ``$container->get(FooCommand::class)``.
by calling ``$containerBuilder->get(FooCommand::class)``.
6 changes: 3 additions & 3 deletions doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ a controller, this is pretty easy. Add the following method to the
public function createAction()
{
// you can fetch the EntityManager via $this->getDoctrine()
// or you can add an argument to your action: createAction(EntityManagerInterface $em)
// or you can add an argument to your action: createAction(EntityManagerInterface $entityManager)
$entityManager = $this->getDoctrine()->getManager();

$product = new Product();
Expand All @@ -525,8 +525,8 @@ a controller, this is pretty easy. Add the following method to the
public function editAction()
{
$doctrine = $this->getDoctrine();
$em = $doctrine->getManager();
$em2 = $doctrine->getManager('other_connection');
$entityManager = $doctrine->getManager();
$otherEntityManager = $doctrine->getManager('other_connection');
}

.. note::
Expand Down
6 changes: 3 additions & 3 deletions event_dispatcher/method_behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ could listen to the ``mailer.post_send`` event and change the method's return va
{
public function onMailerPostSend(AfterSendMailEvent $event)
{
$ret = $event->getReturnValue();
// modify the original ``$ret`` value
$returnValue = $event->getReturnValue();
// modify the original ``$returnValue`` value

$event->setReturnValue($ret);
$event->setReturnValue($returnValue);
}

public static function getSubscribedEvents()
Expand Down
8 changes: 4 additions & 4 deletions form/create_custom_field_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ add a ``__construct()`` method like normal::

class ShippingType extends AbstractType
{
private $em;
private $entityManager;

public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $em;
$this->entityManager = $entityManager;
}

// use $this->em down anywhere you want ...
// use $this->entityManager down anywhere you want ...
}

If you're using the default ``services.yml`` configuration (i.e. services from the
Expand Down
4 changes: 2 additions & 2 deletions form/form_dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ create your form::
// ...
public function newAction()
{
$em = $this->getDoctrine()->getManager();
$entityManager = $this->getDoctrine()->getManager();

$task = ...;
$form = $this->createForm(TaskType::class, $task, array(
'entity_manager' => $em,
'entity_manager' => $entityManager,
));

// ...
Expand Down
12 changes: 6 additions & 6 deletions security/form_login_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ Great! Next, add the logic to ``loginAction()`` that displays the login form::
// src/AppBundle/Controller/SecurityController.php
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

public function loginAction(Request $request, AuthenticationUtils $authUtils)
public function loginAction(Request $request, AuthenticationUtils $authenticationUtils)
{
// get the login error if there is one
$error = $authUtils->getLastAuthenticationError();
$error = $authenticationUtils->getLastAuthenticationError();

// last username entered by the user
$lastUsername = $authUtils->getLastUsername();
$lastUsername = $authenticationUtils->getLastUsername();

return $this->render('security/login.html.twig', array(
'last_username' => $lastUsername,
Expand All @@ -159,9 +159,9 @@ Great! Next, add the logic to ``loginAction()`` that displays the login form::

.. note::

If you get an error that the ``$authUtils`` argument is missing, it's
probably because you need to activate this new feature in Symfony 3.4. See
this :ref:`controller service argument note <controller-service-arguments-tag>`.
If you get an error that the ``$authenticationUtils`` argument is missing,
it's probably because you need to activate this new feature in Symfony 3.4.
See this :ref:`controller service argument note <controller-service-arguments-tag>`.

Don't let this controller confuse you. As you'll see in a moment, when the
user submits the form, the security system automatically handles the form
Expand Down
6 changes: 3 additions & 3 deletions security/json_login_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ path:
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

$collection = new RouteCollection();
$collection->add('login', new Route('/login', array(
$routes = new RouteCollection();
$routes->add('login', new Route('/login', array(
'_controller' => 'AppBundle:Security:login',
)));

return $collection;
return $routes;

Don't let this empty controller confuse you. When you submit a ``POST`` request
to the ``/login`` URL with the following JSON document as the body, the security
Expand Down
2 changes: 1 addition & 1 deletion workflow/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ what actions are allowed on a blog post::
// Update the currentState on the post
try {
$workflow->apply($post, 'to_review');
} catch (LogicException $e) {
} catch (LogicException $exception) {
// ...
}

Expand Down