diff --git a/components/cache.rst b/components/cache.rst index b4faad6af41..d728f4455e0 100644 --- a/components/cache.rst +++ b/components/cache.rst @@ -63,24 +63,24 @@ 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(); @@ -88,18 +88,18 @@ Now you can create, retrieve, update and delete items using this object:: 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 @@ -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`. diff --git a/components/cache/adapters/doctrine_adapter.rst b/components/cache/adapters/doctrine_adapter.rst index 98580a9dbf5..f8f95126ae9 100644 --- a/components/cache/adapters/doctrine_adapter.rst +++ b/components/cache/adapters/doctrine_adapter.rst @@ -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, diff --git a/components/cache/adapters/php_array_cache_adapter.rst b/components/cache/adapters/php_array_cache_adapter.rst index c2c722eae3f..716a0abd75e 100644 --- a/components/cache/adapters/php_array_cache_adapter.rst +++ b/components/cache/adapters/php_array_cache_adapter.rst @@ -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( @@ -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:: diff --git a/components/cache/cache_items.rst b/components/cache/cache_items.rst index b534721859e..73410ea2c54 100644 --- a/components/cache/cache_items.rst +++ b/components/cache/cache_items.rst @@ -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:: diff --git a/components/filesystem.rst b/components/filesystem.rst index 15077ee2fc1..0747270c08e 100644 --- a/components/filesystem.rst +++ b/components/filesystem.rst @@ -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:: @@ -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. diff --git a/components/ldap.rst b/components/ldap.rst index cfc4f78e8ec..743380d7179 100644 --- a/components/ldap.rst +++ b/components/ldap.rst @@ -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 diff --git a/components/routing.rst b/components/routing.rst index a765977d478..b7d10117b9c 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -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', ), @@ -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 @@ -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', ), @@ -509,7 +509,7 @@ You can also include UTF-8 strings as routing requirements: // ... - return $collection; + return $routes; .. tip:: diff --git a/console/lazy_commands.rst b/console/lazy_commands.rst index b05e17009e0..497b3cd33a0 100644 --- a/console/lazy_commands.rst +++ b/console/lazy_commands.rst @@ -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)``. diff --git a/doctrine.rst b/doctrine.rst index 0bd4b9c5e5a..cb43023746e 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -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(); @@ -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:: diff --git a/event_dispatcher/method_behavior.rst b/event_dispatcher/method_behavior.rst index 70cd455cdb0..ffd58b25d9c 100644 --- a/event_dispatcher/method_behavior.rst +++ b/event_dispatcher/method_behavior.rst @@ -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() diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index cd1a360ed87..c62928c3632 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -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 diff --git a/form/form_dependencies.rst b/form/form_dependencies.rst index 873c94ad864..080af486b83 100644 --- a/form/form_dependencies.rst +++ b/form/form_dependencies.rst @@ -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, )); // ... diff --git a/security/form_login_setup.rst b/security/form_login_setup.rst index 52800587f79..ca7a64d28b3 100644 --- a/security/form_login_setup.rst +++ b/security/form_login_setup.rst @@ -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, @@ -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 `. + 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 `. 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 diff --git a/security/json_login_setup.rst b/security/json_login_setup.rst index 5483f694c61..3d1c12ffd40 100644 --- a/security/json_login_setup.rst +++ b/security/json_login_setup.rst @@ -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 diff --git a/workflow/usage.rst b/workflow/usage.rst index c40450f18ea..4e94c47fdd6 100644 --- a/workflow/usage.rst +++ b/workflow/usage.rst @@ -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) { // ... }