diff --git a/best_practices/security.rst b/best_practices/security.rst index 00b52f9910b..0ba606e0ec3 100644 --- a/best_practices/security.rst +++ b/best_practices/security.rst @@ -129,7 +129,7 @@ Using Expressions for Complex Security Restrictions If your security logic is a little bit more complex, you can use an :doc:`expression ` inside ``@Security``. In the following example, a user can only access the -controller if their email matches the value returned by the ``getAuthorEmail`` +controller if their email matches the value returned by the ``getAuthorEmail()`` method on the ``Post`` object: .. code-block:: php @@ -258,7 +258,7 @@ of magnitude easier than :doc:`ACLs ` and will give you the flexibility you need in almost all cases. First, create a voter class. The following example shows a voter that implements -the same ``getAuthorEmail`` logic you used above: +the same ``getAuthorEmail()`` logic you used above: .. code-block:: php diff --git a/bundles/extension.rst b/bundles/extension.rst index 811cae3bbdc..bda1a9def0d 100644 --- a/bundles/extension.rst +++ b/bundles/extension.rst @@ -90,7 +90,7 @@ but it is more common if you put these definitions in a configuration file the extension! For instance, assume you have a file called ``services.xml`` in the -``Resources/config`` directory of your bundle, your load method looks like:: +``Resources/config`` directory of your bundle, your ``load()`` method looks like:: use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; diff --git a/bundles/inheritance.rst b/bundles/inheritance.rst index 90457f54320..2e9e3cb36f9 100644 --- a/bundles/inheritance.rst +++ b/bundles/inheritance.rst @@ -40,7 +40,7 @@ simply by creating a file with the same name. Overriding Controllers ~~~~~~~~~~~~~~~~~~~~~~ -Suppose you want to add some functionality to the ``registerAction`` of a +Suppose you want to add some functionality to the ``registerAction()`` of a ``RegistrationController`` that lives inside FOSUserBundle. To do so, just create your own ``RegistrationController.php`` file, override the bundle's original method, and change its functionality:: diff --git a/changelog.rst b/changelog.rst index d4aa9c0a289..9486a547071 100644 --- a/changelog.rst +++ b/changelog.rst @@ -75,7 +75,7 @@ Minor Documentation Changes * `#30 `_ Moved the rest of the book chapters (javiereguiluz) * `#24 `_ Moved book chapters out of the book (javiereguiluz) * `#20 `_ Creating the Controller topic (xabbuh) -* `#6747 `_ Correcting reference to ``isSuccessful`` method for Process (aedmonds) +* `#6747 `_ Correcting reference to ``isSuccessful()`` method for Process (aedmonds) * `#6600 `_ Removing some extra details from #6444 (weaverryan) * `#6715 `_ [Book] Remove DI extension info and link the cookbook article instead (WouterJ) * `#6745 `_ Branch fix (Talita Kocjan Zager, weaverryan) diff --git a/components/config/definition.rst b/components/config/definition.rst index bfcb98dac0f..d82df6ac634 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -475,7 +475,7 @@ methods:: ->defaultFalse() ; -The ``canBeDisabled`` method looks about the same except that the section +The ``canBeDisabled()`` method looks about the same except that the section would be enabled by default. Merging Options @@ -655,7 +655,7 @@ a second argument:: ->end() ; -As well as fixing this, ``fixXmlConfig`` ensures that single XML elements +As well as fixing this, ``fixXmlConfig()`` ensures that single XML elements are still turned into an array. So you may have: .. code-block:: xml @@ -671,7 +671,7 @@ and sometimes only: By default ``connection`` would be an array in the first case and a string in the second making it difficult to validate. You can ensure it is always -an array with ``fixXmlConfig``. +an array with ``fixXmlConfig()``. You can further control the normalization process if you need to. For example, you may want to allow a string to be set and used as a particular key or diff --git a/components/console/changing_default_command.rst b/components/console/changing_default_command.rst index 994da675b17..2ce1f04a8a6 100644 --- a/components/console/changing_default_command.rst +++ b/components/console/changing_default_command.rst @@ -6,7 +6,7 @@ Changing the Default Command The Console component will always run the ``ListCommand`` when no command name is passed. In order to change the default command you just need to pass the command -name to the ``setDefaultCommand`` method:: +name to the ``setDefaultCommand()`` method:: namespace Acme\Console\Command; diff --git a/components/console/helpers/dialoghelper.rst b/components/console/helpers/dialoghelper.rst index f45c1e1e95f..70176801257 100644 --- a/components/console/helpers/dialoghelper.rst +++ b/components/console/helpers/dialoghelper.rst @@ -177,8 +177,8 @@ Let the User Choose from a List of Answers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you have a predefined set of answers the user can choose from, you -could use the ``ask`` method described above or, to make sure the user -provided a correct answer, the ``askAndValidate`` method. Both have +could use the ``ask()`` method described above or, to make sure the user +provided a correct answer, the ``askAndValidate()`` method. Both have the disadvantage that you need to handle incorrect values yourself. Instead, you can use the diff --git a/components/console/helpers/progresshelper.rst b/components/console/helpers/progresshelper.rst index da2b8f507cb..7f0f86a23ac 100644 --- a/components/console/helpers/progresshelper.rst +++ b/components/console/helpers/progresshelper.rst @@ -5,7 +5,7 @@ Progress Helper =============== .. versionadded:: 2.3 - The ``setCurrent`` method was introduced in Symfony 2.3. + The ``setCurrent()`` method was introduced in Symfony 2.3. .. caution:: diff --git a/components/css_selector.rst b/components/css_selector.rst index 5b7b8648f02..6805c740bbc 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -34,7 +34,7 @@ long and unwieldy expressions. Many developers -- particularly web developers -- are more comfortable using CSS selectors to find elements. As well as working in stylesheets, -CSS selectors are used in JavaScript with the ``querySelectorAll`` function +CSS selectors are used in JavaScript with the ``querySelectorAll()`` function and in popular JavaScript libraries such as jQuery, Prototype and MooTools. CSS selectors are less powerful than XPath, but far easier to write, read diff --git a/components/dependency_injection/compilation.rst b/components/dependency_injection/compilation.rst index 0fe80e32564..30190cd4324 100644 --- a/components/dependency_injection/compilation.rst +++ b/components/dependency_injection/compilation.rst @@ -44,16 +44,16 @@ and can be registered with the container with:: $container->registerExtension($extension); -The main work of the extension is done in the ``load`` method. In the ``load`` +The main work of the extension is done in the ``load()`` method. In the ``load()`` method you can load configuration from one or more configuration files as well as manipulate the container definitions using the methods shown in :doc:`/service_container/definitions`. -The ``load`` method is passed a fresh container to set up, which is then +The ``load()`` method is passed a fresh container to set up, which is then merged afterwards into the container it is registered with. This allows you to have several extensions managing container definitions independently. The extensions do not add to the containers configuration when they are -added but are processed when the container's ``compile`` method is called. +added but are processed when the container's ``compile()`` method is called. A very simple extension may just load configuration files into the container:: @@ -85,7 +85,7 @@ sections of config files loaded directly into the container as being for a particular extension. These sections on the config will not be processed directly by the container but by the relevant Extension. -The Extension must specify a ``getAlias`` method to implement the interface:: +The Extension must specify a ``getAlias()`` method to implement the interface:: // ... @@ -100,7 +100,7 @@ The Extension must specify a ``getAlias`` method to implement the interface:: } For YAML configuration files specifying the alias for the extension as a -key will mean that those values are passed to the Extension's ``load`` method: +key will mean that those values are passed to the Extension's ``load()`` method: .. code-block:: yaml @@ -133,7 +133,7 @@ are loaded:: or an exception will be thrown. The values from those sections of the config files are passed into the first -argument of the ``load`` method of the extension:: +argument of the ``load()`` method of the extension:: public function load(array $configs, ContainerBuilder $container) { @@ -190,7 +190,7 @@ the XML configuration:: .. note:: - XSD validation is optional, returning ``false`` from the ``getXsdValidationBasePath`` + XSD validation is optional, returning ``false`` from the ``getXsdValidationBasePath()`` method will disable it. The XML version of the config would then look like this: @@ -316,7 +316,7 @@ interface. The compiler pass gives you an opportunity to manipulate the service definitions that have been compiled. This can be very powerful, but is not something needed in everyday use. -The compiler pass must have the ``process`` method which is passed the container +The compiler pass must have the ``process()`` method which is passed the container being compiled:: use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 55b832848b7..6f52cc1e68e 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -298,13 +298,13 @@ and :phpclass:`DOMNode` objects: $html = $crawler->html(); - The ``html`` method is new in Symfony 2.3. + The ``html()`` method is new in Symfony 2.3. Links ~~~~~ To find a link by name (or a clickable image by its ``alt`` attribute), use -the ``selectLink`` method on an existing crawler. This returns a Crawler +the ``selectLink()`` method on an existing crawler. This returns a Crawler instance with just the selected link(s). Calling ``link()`` gives you a special :class:`Symfony\\Component\\DomCrawler\\Link` object:: diff --git a/components/event_dispatcher.rst b/components/event_dispatcher.rst index fc32129fcde..c636b8f78e4 100644 --- a/components/event_dispatcher.rst +++ b/components/event_dispatcher.rst @@ -152,7 +152,7 @@ The ``addListener()`` method takes up to three arguments: A `PHP callable`_ is a PHP variable that can be used by the ``call_user_func()`` function and returns ``true`` when passed to the ``is_callable()`` function. It can be a ``\Closure`` instance, an object - implementing an ``__invoke`` method (which is what closures are in fact), + implementing an ``__invoke()`` method (which is what closures are in fact), a string representing a function or an array representing an object method or a class method. diff --git a/components/event_dispatcher/immutable_dispatcher.rst b/components/event_dispatcher/immutable_dispatcher.rst index da757aeacce..905d1db5b01 100644 --- a/components/event_dispatcher/immutable_dispatcher.rst +++ b/components/event_dispatcher/immutable_dispatcher.rst @@ -35,4 +35,4 @@ Now, inject that into an ``ImmutableEventDispatcher``:: You'll need to use this new dispatcher in your project. If you are trying to execute one of the methods which modifies the dispatcher -(e.g. ``addListener``), a ``BadMethodCallException`` is thrown. +(e.g. ``addListener()``), a ``BadMethodCallException`` is thrown. diff --git a/components/filesystem/lock_handler.rst b/components/filesystem/lock_handler.rst index 5d442e79547..3b16517da19 100644 --- a/components/filesystem/lock_handler.rst +++ b/components/filesystem/lock_handler.rst @@ -54,7 +54,7 @@ second argument of the constructor. The :method:`Symfony\\Component\\Filesystem\\LockHandler::lock` method tries to acquire the lock. If the lock is acquired, the method returns ``true``, -``false`` otherwise. If the ``lock`` method is called several times on the same +``false`` otherwise. If the ``lock()`` method is called several times on the same instance it will always return ``true`` if the lock was acquired on the first call. diff --git a/components/form.rst b/components/form.rst index 7c12ef1159e..0fb4813d434 100644 --- a/components/form.rst +++ b/components/form.rst @@ -369,7 +369,7 @@ Creating a simple Form If you're using the Symfony Framework, then the form factory is available automatically as a service called ``form.factory``. Also, the default base controller class has a :method:`Symfony\\Bundle\\FrameworkBundle\\Controller::createFormBuilder` - method, which is a shortcut to fetch the form factory and call ``createBuilder`` + method, which is a shortcut to fetch the form factory and call ``createBuilder()`` on it. Creating a form is done via a :class:`Symfony\\Component\\Form\\FormBuilder` @@ -414,8 +414,8 @@ is created from the form factory. } } -As you can see, creating a form is like writing a recipe: you call ``add`` -for each new field you want to create. The first argument to ``add`` is the +As you can see, creating a form is like writing a recipe: you call ``add()`` +for each new field you want to create. The first argument to ``add()`` is the name of your field, and the second is the field "type". The Form component comes with a lot of :doc:`built-in types `. @@ -685,7 +685,7 @@ method to access the list of errors. It returns a $errorsAsArray = iterator_to_array($form->getErrors()); - This is useful, for example, if you want to use PHP's ``array_`` function + This is useful, for example, if you want to use PHP's ``array_*()`` function on the form errors. Learn more diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 7c4caf8e68e..5895d7ab182 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -11,7 +11,7 @@ The HttpFoundation Component In PHP, the request is represented by some global variables (``$_GET``, ``$_POST``, ``$_FILES``, ``$_COOKIE``, ``$_SESSION``, ...) and the response is -generated by some functions (``echo``, ``header``, ``setcookie``, ...). +generated by some functions (``echo``, ``header()``, ``setcookie()``, ...). The Symfony HttpFoundation component replaces these default PHP global variables and functions by an object-oriented layer. diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 04330019252..e2f9f251583 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -209,7 +209,7 @@ and is one of the constructor arguments to ``HttpKernel``. :align: center Your job is to create a class that implements the interface and fill in its -two methods: ``getController`` and ``getArguments``. In fact, one default +two methods: ``getController()`` and ``getArguments()``. In fact, one default implementation already exists, which you can use directly or learn from: :class:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver`. This implementation is explained more in the sidebar below:: @@ -225,7 +225,7 @@ This implementation is explained more in the sidebar below:: public function getArguments(Request $request, $controller); } -Internally, the ``HttpKernel::handle`` method first calls +Internally, the ``HttpKernel::handle()`` method first calls :method:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface::getController` on the controller resolver. This method is passed the ``Request`` and is responsible for somehow determining and returning a PHP callable (the controller) based @@ -260,7 +260,7 @@ will be called after another event - ``kernel.controller`` - is dispatched. constructor arguments. c) If the controller implements :class:`Symfony\\Component\\DependencyInjection\\ContainerAwareInterface`, - ``setContainer`` is called on the controller object and the container + ``setContainer()`` is called on the controller object and the container is passed to it. This step is also specific to the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver` sub-class used by the Symfony Framework. @@ -274,7 +274,7 @@ the controller is executed. :ref:`Kernel Events Information Table ` -After the controller callable has been determined, ``HttpKernel::handle`` +After the controller callable has been determined, ``HttpKernel::handle()`` dispatches the ``kernel.controller`` event. Listeners to this event might initialize some part of the system that needs to be initialized after certain things have been determined (e.g. the controller, routing information) but before @@ -306,10 +306,10 @@ on the event object that's passed to listeners on this event. 4) Getting the Controller Arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Next, ``HttpKernel::handle`` calls +Next, ``HttpKernel::handle()`` calls :method:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface::getArguments`. -Remember that the controller returned in ``getController`` is a callable. -The purpose of ``getArguments`` is to return the array of arguments that +Remember that the controller returned in ``getController()`` is a callable. +The purpose of ``getArguments()`` is to return the array of arguments that should be passed to that controller. Exactly how this is done is completely up to your design, though the built-in :class:`Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver` is a good example. @@ -343,7 +343,7 @@ of arguments that should be passed when executing that callable. 5) Calling the Controller ~~~~~~~~~~~~~~~~~~~~~~~~~ -The next step is simple! ``HttpKernel::handle`` executes the controller. +The next step is simple! ``HttpKernel::handle()`` executes the controller. .. image:: /_images/components/http_kernel/08-call-controller.png :align: center @@ -464,7 +464,7 @@ been streamed to the user :ref:`Kernel Events Information Table ` The final event of the HttpKernel process is ``kernel.terminate`` and is unique -because it occurs *after* the ``HttpKernel::handle`` method, and after the +because it occurs *after* the ``HttpKernel::handle()`` method, and after the response is sent to the user. Recall from above, then the code that uses the kernel, ends like this:: @@ -509,8 +509,8 @@ Handling Exceptions: the ``kernel.exception`` Event :ref:`Kernel Events Information Table ` -If an exception is thrown at any point inside ``HttpKernel::handle``, another -event - ``kernel.exception`` is thrown. Internally, the body of the ``handle`` +If an exception is thrown at any point inside ``HttpKernel::handle()``, another +event - ``kernel.exception`` is thrown. Internally, the body of the ``handle()`` function is wrapped in a try-catch block. When any exception is thrown, the ``kernel.exception`` event is dispatched so that your system can somehow respond to the exception. @@ -554,7 +554,7 @@ below for more details). 2) If the original exception implements :class:`Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface`, - then ``getStatusCode`` and ``getHeaders`` are called on the exception + then ``getStatusCode()`` and ``getHeaders()`` are called on the exception and used to populate the headers and status code of the ``FlattenException`` object. The idea is that these are used in the next step when creating the final response. @@ -577,7 +577,7 @@ Creating an Event Listener -------------------------- As you've seen, you can create and attach event listeners to any of the events -dispatched during the ``HttpKernel::handle`` cycle. Typically a listener is a PHP +dispatched during the ``HttpKernel::handle()`` cycle. Typically a listener is a PHP class with a method that's executed, but it can be anything. For more information on creating and attaching event listeners, see :doc:`/components/event_dispatcher`. @@ -653,7 +653,7 @@ a built-in ControllerResolver that can be used to create a working example:: Sub Requests ------------ -In addition to the "main" request that's sent into ``HttpKernel::handle``, +In addition to the "main" request that's sent into ``HttpKernel::handle()``, you can also send so-called "sub request". A sub request looks and acts like any other request, but typically serves to render just one small portion of a page instead of a full page. You'll most commonly make sub-requests from @@ -663,7 +663,7 @@ your controller). .. image:: /_images/components/http_kernel/sub-request.png :align: center -To execute a sub request, use ``HttpKernel::handle``, but change the second +To execute a sub request, use ``HttpKernel::handle()``, but change the second argument as follows:: use Symfony\Component\HttpFoundation\Request; diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 4c438486109..dc556c72d2c 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -79,9 +79,9 @@ There are four ways to mark a test as legacy: * Make its class name start with the ``Legacy`` prefix; -* Make its method name start with ``testLegacy`` instead of ``test``; +* Make its method name start with ``testLegacy*()`` instead of ``test*()``; -* Make its data provider start with ``provideLegacy`` or ``getLegacy``. +* Make its data provider start with ``provideLegacy*()`` or ``getLegacy*()``. Configuration ------------- diff --git a/components/process.rst b/components/process.rst index 675ea0e644e..925cc651f3b 100644 --- a/components/process.rst +++ b/components/process.rst @@ -132,7 +132,7 @@ Stopping a Process ------------------ .. versionadded:: 2.3 - The ``signal`` parameter of the ``stop`` method was introduced in Symfony 2.3. + The ``signal`` parameter of the ``stop()`` method was introduced in Symfony 2.3. Any asynchronous process can be stopped at any time with the :method:`Symfony\\Component\\Process\\Process::stop` method. This method takes @@ -250,7 +250,7 @@ Process Signals --------------- .. versionadded:: 2.3 - The ``signal`` method was introduced in Symfony 2.3. + The ``signal()`` method was introduced in Symfony 2.3. When running a program asynchronously, you can send it POSIX signals with the :method:`Symfony\\Component\\Process\\Process::signal` method:: @@ -276,7 +276,7 @@ Process Pid ----------- .. versionadded:: 2.3 - The ``getPid`` method was introduced in Symfony 2.3. + The ``getPid()`` method was introduced in Symfony 2.3. You can access the `pid`_ of a running process with the :method:`Symfony\\Component\\Process\\Process::getPid` method. @@ -314,10 +314,10 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and You can not enable or disable the output while the process is running. - If you disable the output, you cannot access ``getOutput``, - ``getIncrementalOutput``, ``getErrorOutput`` or ``getIncrementalErrorOutput``. - Moreover, you could not pass a callback to the ``start``, ``run`` or ``mustRun`` - methods or use ``setIdleTimeout``. + If you disable the output, you cannot access ``getOutput()``, + ``getIncrementalOutput()``, ``getErrorOutput()`` or ``getIncrementalErrorOutput()``. + Moreover, you could not pass a callback to the ``start()``, ``run()`` or ``mustRun()`` + methods or use ``setIdleTimeout()``. .. _`Symfony Issue#5759`: https://github.com/symfony/symfony/issues/5759 .. _`PHP Bug#39992`: https://bugs.php.net/bug.php?id=39992 diff --git a/components/property_access.rst b/components/property_access.rst index e646ce90ea3..fafa979d3b1 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -70,7 +70,7 @@ You can also use multi dimensional arrays:: Reading from Objects -------------------- -The ``getValue`` method is a very robust method, and you can see all of its +The ``getValue()`` method is a very robust method, and you can see all of its features when working with objects. Accessing public Properties @@ -100,10 +100,10 @@ To read from properties, use the "dot" notation:: Using Getters ~~~~~~~~~~~~~ -The ``getValue`` method also supports reading using getters. The method will +The ``getValue()`` method also supports reading using getters. The method will be created using common naming conventions for getters. It camelizes the property name (``first_name`` becomes ``FirstName``) and prefixes it with -``get``. So the actual method becomes ``getFirstName``:: +``get``. So the actual method becomes ``getFirstName()``:: // ... class Person @@ -158,7 +158,7 @@ This will produce: ``He is an author`` Magic ``__get()`` Method ~~~~~~~~~~~~~~~~~~~~~~~~ -The ``getValue`` method can also use the magic ``__get`` method:: +The ``getValue()`` method can also use the magic ``__get()`` method:: // ... class Person @@ -182,7 +182,7 @@ The ``getValue`` method can also use the magic ``__get`` method:: Magic ``__call()`` Method ~~~~~~~~~~~~~~~~~~~~~~~~~ -At last, ``getValue`` can use the magic ``__call`` method, but you need to +At last, ``getValue()`` can use the magic ``__call()`` method, but you need to enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder`:: // ... @@ -220,7 +220,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert .. caution:: - The ``__call`` feature is disabled by default, you can enable it by calling + The ``__call()`` feature is disabled by default, you can enable it by calling :method:`PropertyAccessorBuilder::enableMagicCall` see `Enable other Features`_. @@ -244,8 +244,8 @@ method:: Writing to Objects ------------------ -The ``setValue`` method has the same features as the ``getValue`` method. You -can use setters, the magic ``__set`` method or properties to set values:: +The ``setValue()`` method has the same features as the ``getValue()`` method. You +can use setters, the magic ``__set()`` method or properties to set values:: // ... class Person @@ -277,7 +277,7 @@ can use setters, the magic ``__set`` method or properties to set values:: var_dump($person->getLastName()); // 'de Jong' var_dump($person->children); // array(Person()); -You can also use ``__call`` to set values but you need to enable the feature, +You can also use ``__call()`` to set values but you need to enable the feature, see `Enable other Features`_. .. code-block:: php diff --git a/components/templating.rst b/components/templating.rst index 6a5f7f52b48..98ea31eb2dc 100644 --- a/components/templating.rst +++ b/components/templating.rst @@ -73,7 +73,7 @@ Including Templates The best way to share a snippet of template code is to create a template that can then be included by other templates. As the ``$view`` variable is an -instance of ``PhpEngine``, you can use the ``render`` method (which was used +instance of ``PhpEngine``, you can use the ``render()`` method (which was used to render the template originally) inside the template to render another template:: diff --git a/components/templating/assetshelper.rst b/components/templating/assetshelper.rst index 837b94255bc..3a4af66ab8d 100644 --- a/components/templating/assetshelper.rst +++ b/components/templating/assetshelper.rst @@ -59,7 +59,7 @@ You can also use the third argument of the helper to force an absolute URL: .. note:: If you already set a URL in the constructor, using the third argument of - ``getUrl`` will not affect the generated URL. + ``getUrl()`` will not affect the generated URL. Versioning ---------- diff --git a/components/translation.rst b/components/translation.rst index 2b073cccd46..dfbf9fd6259 100644 --- a/components/translation.rst +++ b/components/translation.rst @@ -111,7 +111,7 @@ Loading Messages with the ``ArrayLoader`` Loading messages can be done by calling :method:`Symfony\\Component\\Translation\\Translator::addResource`. The first -argument is the loader name (this was the first argument of the ``addLoader`` +argument is the loader name (this was the first argument of the ``addLoader()`` method), the second is the resource and the third argument is the locale:: // ... @@ -122,7 +122,7 @@ method), the second is the resource and the third argument is the locale:: Loading Messages with the File Loaders ...................................... -If you use one of the file loaders, you should also use the ``addResource`` +If you use one of the file loaders, you should also use the ``addResource()`` method. The only difference is that you should put the file name to the resource file as the second argument, instead of an array:: diff --git a/components/validator/metadata.rst b/components/validator/metadata.rst index 645ab9f0ac9..ed100943beb 100755 --- a/components/validator/metadata.rst +++ b/components/validator/metadata.rst @@ -41,7 +41,7 @@ feature allows to validate your objects dynamically. Suppose that, for security reasons, you want to validate that a password field doesn't match the first name of the user. First, create a public method called -``isPasswordSafe`` to define this custom validation logic:: +``isPasswordSafe()`` to define this custom validation logic:: public function isPasswordSafe() { diff --git a/components/var_dumper.rst b/components/var_dumper.rst index 83c526b51f7..bd6babfb8f7 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -127,7 +127,7 @@ This will provide you with two new assertions: :method:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait::assertDumpMatchesFormat` is like the previous method but accepts placeholders in the expected dump, - based on the ``assertStringMatchesFormat`` method provided by PHPUnit. + based on the ``assertStringMatchesFormat()`` method provided by PHPUnit. Example:: diff --git a/configuration.rst b/configuration.rst index 7e4291849c8..d7833f819ea 100644 --- a/configuration.rst +++ b/configuration.rst @@ -177,7 +177,7 @@ it *also* loads other configuration files via its ``imports`` key: // ... -The ``imports`` key works a lot like the PHP ``include`` function: the contents of +The ``imports`` key works a lot like the PHP ``include()`` function: the contents of ``parameters.yml``, ``security.yml`` and ``services.yml`` are read and loaded. You can also load XML files or PHP files. diff --git a/configuration/override_dir_structure.rst b/configuration/override_dir_structure.rst index 4189d3214bd..bf24441d65b 100644 --- a/configuration/override_dir_structure.rst +++ b/configuration/override_dir_structure.rst @@ -29,7 +29,7 @@ directory structure is: Override the ``cache`` Directory -------------------------------- -You can change the default cache directory by overriding the ``getCacheDir`` method +You can change the default cache directory by overriding the ``getCacheDir()`` method in the ``AppKernel`` class of your application:: // app/AppKernel.php @@ -62,7 +62,7 @@ Override the ``logs`` Directory ------------------------------- Overriding the ``logs`` directory is the same as overriding the ``cache`` -directory. The only difference is that you need to override the ``getLogDir`` +directory. The only difference is that you need to override the ``getLogDir()`` method:: // app/AppKernel.php diff --git a/console/commands_as_services.rst b/console/commands_as_services.rst index 1485fde9a4d..ab96bfa8c57 100644 --- a/console/commands_as_services.rst +++ b/console/commands_as_services.rst @@ -14,7 +14,7 @@ While making life easier, this has some limitations: * There's no way to conditionally register your service based on the environment or availability of some dependencies; * You can't access the container in the ``configure()`` method (because - ``setContainer`` hasn't been called yet); + ``setContainer()`` hasn't been called yet); * You can't use the same class to create many commands (i.e. each with different configuration). diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index bb268977261..0993b4a786e 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -159,8 +159,8 @@ Structure * Declare class properties before methods; * Declare public methods first, then protected ones and finally private ones. - The exceptions to this rule are the class constructor and the ``setUp`` and - ``tearDown`` methods of PHPUnit tests, which must always be the first methods + The exceptions to this rule are the class constructor and the ``setUp()`` and + ``tearDown()`` methods of PHPUnit tests, which must always be the first methods to increase readability; * Declare all the arguments on the same line as the method/function name, no diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index cb4a868e3b5..fafb7a21c95 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -178,7 +178,7 @@ Symfony, you should precede your description of the change with a .. code-block:: rst .. versionadded:: 2.7 - The ``askHiddenResponse`` method was introduced in Symfony 2.7. + The ``askHiddenResponse()`` method was introduced in Symfony 2.7. You can also ask a question and hide the response. This is particularly [...] diff --git a/controller.rst b/controller.rst index 1c986fd681e..0bb7a196b60 100644 --- a/controller.rst +++ b/controller.rst @@ -219,7 +219,7 @@ creating unnecessarily deep structures:: // renders app/Resources/views/lottery/lucky/number.html.twig return $this->render('lottery/lucky/number.html.twig', array( - 'name' => $name + 'name' => $name, )); The Symfony templating system and Twig are explained more in the @@ -398,7 +398,7 @@ For example, imagine you're processing a :doc:`form ` submission:: 'notice', 'Your changes were saved!' ); - // $this->addFlash is equivalent to $request->getSession()->getFlashBag()->add + // $this->addFlash() is equivalent to $request->getSession()->getFlashBag()->add() return $this->redirectToRoute(...); } @@ -536,7 +536,7 @@ final ``Response`` object that will be returned to the user. To make life easier, you'll probably extend the base ``Controller`` class because this gives two things: -A) Shortcut methods (like ``render()`` and ``redirectToRoute``); +A) Shortcut methods (like ``render()`` and ``redirectToRoute()``); B) Access to *all* of the useful objects (services) in the system via the :ref:`get() ` method. diff --git a/controller/service.rst b/controller/service.rst index dfffc7ddd54..90ef29736e4 100644 --- a/controller/service.rst +++ b/controller/service.rst @@ -169,7 +169,7 @@ Symfony's base controller:: } } -If you look at the source code for the ``render`` function in Symfony's +If you look at the source code for the ``render()`` function in Symfony's `base Controller class`_, you'll see that this method actually uses the ``templating`` service:: @@ -342,7 +342,7 @@ controller: .. tip:: - ``getRequest`` has been deprecated. Instead, have an argument to your + ``getRequest()`` has been deprecated. Instead, have an argument to your controller action method called ``Request $request``. The order of the parameters is not important, but the typehint must be provided. diff --git a/controller/soap_web_service.rst b/controller/soap_web_service.rst index 134c67fb044..b1dcb3efb37 100644 --- a/controller/soap_web_service.rst +++ b/controller/soap_web_service.rst @@ -121,7 +121,7 @@ into the content of the Response and clear the output buffer. Finally, you're ready to return the ``Response``. 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 +assumes that the ``indexAction()`` in the controller above is accessible via the route ``/soap``:: $client = new \Soapclient('http://example.com/app.php/soap?wsdl'); diff --git a/doctrine.rst b/doctrine.rst index 625efee4650..4767b769c1d 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -630,7 +630,7 @@ Once you have a repository object, you can access all sorts of helpful methods:: Of course, you can also issue complex queries, which you'll learn more about in the :ref:`doctrine-queries` section. -You can also take advantage of the useful ``findBy`` and ``findOneBy`` methods +You can also take advantage of the useful ``findBy()`` and ``findOneBy()`` methods to easily fetch objects based on multiple conditions:: $repository = $this->getDoctrine()->getRepository('AppBundle:Product'); diff --git a/doctrine/event_listeners_subscribers.rst b/doctrine/event_listeners_subscribers.rst index a2026e03543..91a8973c14f 100644 --- a/doctrine/event_listeners_subscribers.rst +++ b/doctrine/event_listeners_subscribers.rst @@ -9,7 +9,7 @@ How to Register Event Listeners and Subscribers Doctrine packages a rich event system that fires events when almost anything happens inside the system. For you, this means that you can create arbitrary :doc:`services ` and tell Doctrine to notify those -objects whenever a certain action (e.g. ``prePersist``) happens within Doctrine. +objects whenever a certain action (e.g. ``prePersist()``) happens within Doctrine. This could be useful, for example, to create an independent search index whenever an object in your database is saved. @@ -122,7 +122,7 @@ Creating the Listener Class In the previous example, a service ``my.listener`` was configured as a Doctrine listener on the event ``postPersist``. The class behind that service must have -a ``postPersist`` method, which will be called when the event is dispatched:: +a ``postPersist()`` method, which will be called when the event is dispatched:: // src/AppBundle/EventListener/SearchIndexer.php namespace AppBundle\EventListener; diff --git a/doctrine/mapping_model_classes.rst b/doctrine/mapping_model_classes.rst index acace8725f2..c537599fb08 100644 --- a/doctrine/mapping_model_classes.rst +++ b/doctrine/mapping_model_classes.rst @@ -26,7 +26,7 @@ register the mappings for your model classes. .. versionadded:: 2.6 Support for defining namespace aliases was introduced in Symfony 2.6. It is safe to define the aliases with older versions of Symfony as - the aliases are the last argument to ``createXmlMappingDriver`` and + the aliases are the last argument to ``createXmlMappingDriver()`` and are ignored by PHP if that argument doesn't exist. In your bundle class, write the following code to register the compiler pass. diff --git a/event_dispatcher/before_after_filters.rst b/event_dispatcher/before_after_filters.rst index eb171b4e9ca..24405e0cd70 100644 --- a/event_dispatcher/before_after_filters.rst +++ b/event_dispatcher/before_after_filters.rst @@ -181,7 +181,7 @@ your listener to be called just before any controller is executed. )); $container->setDefinition('app.tokens.action_listener', $listener); -With this configuration, your ``TokenListener`` ``onKernelController`` method +With this configuration, your ``TokenListener`` ``onKernelController()`` method will be executed on each request. If the controller that is about to be executed implements ``TokenAuthenticatedController``, token authentication is applied. This lets you have a "before" filter on any controller that you @@ -219,7 +219,7 @@ serve as a basic flag that this request underwent token authentication:: } } -Now, add another method to this class - ``onKernelResponse`` - that looks +Now, add another method to this class - ``onKernelResponse()`` - that looks for this flag on the request object and sets a custom header on the response if it's found:: @@ -283,8 +283,8 @@ event: $container->setDefinition('app.tokens.action_listener', $listener); That's it! The ``TokenListener`` is now notified before every controller is -executed (``onKernelController``) and after every controller returns a response -(``onKernelResponse``). By making specific controllers implement the ``TokenAuthenticatedController`` +executed (``onKernelController()``) and after every controller returns a response +(``onKernelResponse()``). By making specific controllers implement the ``TokenAuthenticatedController`` interface, your listener knows which controllers it should take action on. -And by storing a value in the request's "attributes" bag, the ``onKernelResponse`` +And by storing a value in the request's "attributes" bag, the ``onKernelResponse()`` method knows to add the extra header. Have fun! diff --git a/event_dispatcher/class_extension.rst b/event_dispatcher/class_extension.rst index d6b961fb17d..111def1f811 100644 --- a/event_dispatcher/class_extension.rst +++ b/event_dispatcher/class_extension.rst @@ -116,7 +116,7 @@ and *add* the method ``bar()``: } } -Finally, add the new ``bar`` method to the ``Foo`` class by registering an +Finally, add the new ``bar()`` method to the ``Foo`` class by registering an instance of ``Bar`` with the ``foo.method_is_not_found`` event: .. code-block:: php diff --git a/event_dispatcher/method_behavior.rst b/event_dispatcher/method_behavior.rst index 5ad5da29441..3b25b0deb1a 100644 --- a/event_dispatcher/method_behavior.rst +++ b/event_dispatcher/method_behavior.rst @@ -43,7 +43,7 @@ events. These event classes would need to be created by you and should allow, in this example, the variables ``$foo``, ``$bar`` and ``$ret`` to be retrieved and set by the listeners. -For example, assuming the ``FilterSendReturnValue`` has a ``setReturnValue`` +For example, assuming the ``FilterSendReturnValue`` has a ``setReturnValue()`` method, one listener might look like this: .. code-block:: php diff --git a/expressions.rst b/expressions.rst index 2b70e21dfe1..b61335bbdc2 100644 --- a/expressions.rst +++ b/expressions.rst @@ -25,7 +25,7 @@ For more information about how to create and work with expressions, see Security: Complex Access Controls with Expressions -------------------------------------------------- -In addition to a role like ``ROLE_ADMIN``, the ``isGranted`` method also +In addition to a role like ``ROLE_ADMIN``, the ``isGranted()`` method also accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression` object:: use Symfony\Component\ExpressionLanguage\Expression; @@ -42,7 +42,7 @@ accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression` object:: In this example, if the current user has ``ROLE_ADMIN`` or if the current user object's ``isSuperAdmin()`` method returns ``true``, then access will -be granted (note: your User object may not have an ``isSuperAdmin`` method, +be granted (note: your User object may not have an ``isSuperAdmin()`` method, that method is invented for this example). This uses an expression and you can learn more about the expression language @@ -59,12 +59,12 @@ Inside the expression, you have access to a number of variables: :ref:`role hierarchy ` but not including the ``IS_AUTHENTICATED_*`` attributes (see the functions below). ``object`` - The object (if any) that's passed as the second argument to ``isGranted``. + The object (if any) that's passed as the second argument to ``isGranted()``. ``token`` The token object. ``trust_resolver`` The :class:`Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationTrustResolverInterface`, - object: you'll probably use the ``is_*`` functions below instead. + object: you'll probably use the ``is_*()`` functions below instead. Additionally, you have access to a number of functions inside the expression: @@ -72,7 +72,7 @@ Additionally, you have access to a number of functions inside the expression: Returns ``true`` if the user is authenticated via "remember-me" or authenticated "fully" - i.e. returns true if the user is "logged in". ``is_anonymous`` - Equal to using ``IS_AUTHENTICATED_ANONYMOUSLY`` with the ``isGranted`` function. + Equal to using ``IS_AUTHENTICATED_ANONYMOUSLY`` with the ``isGranted()`` function. ``is_remember_me`` Similar, but not equal to ``IS_AUTHENTICATED_REMEMBERED``, see below. ``is_fully_authenticated`` @@ -83,9 +83,9 @@ Additionally, you have access to a number of functions inside the expression: .. sidebar:: ``is_remember_me`` is different than checking ``IS_AUTHENTICATED_REMEMBERED`` - The ``is_remember_me`` and ``is_authenticated_fully`` functions are *similar* + The ``is_remember_me()`` and ``is_authenticated_fully()`` functions are *similar* to using ``IS_AUTHENTICATED_REMEMBERED`` and ``IS_AUTHENTICATED_FULLY`` - with the ``isGranted`` function - but they are **not** the same. The + with the ``isGranted()`` function - but they are **not** the same. The following shows the difference:: use Symfony\Component\ExpressionLanguage\Expression; @@ -100,7 +100,7 @@ Additionally, you have access to a number of functions inside the expression: Here, ``$access1`` and ``$access2`` will be the same value. Unlike the behavior of ``IS_AUTHENTICATED_REMEMBERED`` and ``IS_AUTHENTICATED_FULLY``, - the ``is_remember_me`` function *only* returns true if the user is authenticated + the ``is_remember_me()`` function *only* returns true if the user is authenticated via a remember-me cookie and ``is_fully_authenticated`` *only* returns true if the user has actually logged in during this session (i.e. is full-fledged). diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index a1ef772a2c9..e42bc76fc72 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -54,14 +54,14 @@ for form fields, which is ``\Form\Type``. Make sure the field extend The location of this file is not important - the ``Form\Type`` directory is just a convention. -Here, the return value of the ``getParent`` function indicates that you're +Here, the return value of the ``getParent()`` function indicates that you're extending the ``choice`` field type. This means that, by default, you inherit all of the logic and rendering of that field type. To see some of the logic, check out the `ChoiceType`_ class. There are three methods that are particularly important: ``buildForm()`` - Each field type has a ``buildForm`` method, which is where + Each field type has a ``buildForm()`` method, which is where you configure and build any field(s). Notice that this is the same method you use to setup *your* forms, and it works the same here. @@ -154,7 +154,7 @@ link for details), create a ``gender_widget`` block to handle this: .. note:: Make sure the correct widget prefix is used. In this example the name should - be ``gender_widget``, according to the value returned by ``getName``. + be ``gender_widget``, according to the value returned by ``getName()``. Further, the main config file should point to the custom form template so that it's used when rendering all forms. @@ -298,7 +298,7 @@ example, suppose that you're storing the gender parameters in configuration: To use the parameter, define your custom field type as a service, injecting the ``genders`` parameter value as the first argument to its to-be-created -``__construct`` function: +``__construct()`` function: .. configuration-block:: @@ -342,7 +342,7 @@ the ``genders`` parameter value as the first argument to its to-be-created for details. Be sure that the ``alias`` attribute of the tag corresponds with the value -returned by the ``getName`` method defined earlier. You'll see the importance +returned by the ``getName()`` method defined earlier. You'll see the importance of this in a moment when you use the custom field type. But first, add a ``__construct`` method to ``GenderType``, which receives the gender configuration:: diff --git a/form/create_form_type_extension.rst b/form/create_form_type_extension.rst index f57d3347020..40421bc01e7 100644 --- a/form/create_form_type_extension.rst +++ b/form/create_form_type_extension.rst @@ -65,17 +65,17 @@ class. In most cases, it's easier to extend the abstract class:: } } -The only method you **must** implement is the ``getExtendedType`` function. +The only method you **must** implement is the ``getExtendedType()`` function. It is used to indicate the name of the form type that will be extended by your extension. .. tip:: - The value you return in the ``getExtendedType`` method corresponds - to the value returned by the ``getName`` method in the form type class + The value you return in the ``getExtendedType()`` method corresponds + to the value returned by the ``getName()`` method in the form type class you wish to extend. -In addition to the ``getExtendedType`` function, you will probably want +In addition to the ``getExtendedType()`` function, you will probably want to override one of the following methods: * ``buildForm()`` @@ -169,9 +169,9 @@ the database:: Your form type extension class will need to do two things in order to extend the ``file`` form type: -#. Override the ``configureOptions`` method in order to add an ``image_path`` +#. Override the ``configureOptions()`` method in order to add an ``image_path`` option; -#. Override the ``buildView`` methods in order to pass the image URL to the +#. Override the ``buildView()`` methods in order to pass the image URL to the view. The logic is the following: when adding a form field of type ``file``, @@ -317,7 +317,7 @@ You can modify several form types at once by specifying their common parent (:doc:`/reference/forms/types`). For example, several form types natively available in Symfony inherit from the ``text`` form type (such as ``email``, ``search``, ``url``, etc.). A form type extension applying to ``text`` -(i.e. whose ``getExtendedType`` method returns ``text``) would apply to all of +(i.e. whose ``getExtendedType()`` method returns ``text``) would apply to all of these form types. In the same way, since **most** form types natively available in Symfony inherit diff --git a/form/data_transformers.rst b/form/data_transformers.rst index e261706fca6..9c53b94caf5 100644 --- a/form/data_transformers.rst +++ b/form/data_transformers.rst @@ -473,16 +473,16 @@ The two different types of transformers help convert to and from each of these types of data: **Model transformers**: - - ``transform``: "model data" => "norm data" - - ``reverseTransform``: "norm data" => "model data" + - ``transform()``: "model data" => "norm data" + - ``reverseTransform()``: "norm data" => "model data" **View transformers**: - - ``transform``: "norm data" => "view data" - - ``reverseTransform``: "view data" => "norm data" + - ``transform()``: "norm data" => "view data" + - ``reverseTransform()``: "view data" => "norm data" Which transformer you need depends on your situation. -To use the view transformer, call ``addViewTransformer``. +To use the view transformer, call ``addViewTransformer()``. So why Use the Model Transformer? --------------------------------- diff --git a/form/direct_submit.rst b/form/direct_submit.rst index 46b4ebb4b1b..59ace4b510d 100644 --- a/form/direct_submit.rst +++ b/form/direct_submit.rst @@ -97,7 +97,7 @@ Passing a Request to Form::submit() (Deprecated) ------------------------------------------------ .. versionadded:: 2.3 - Before Symfony 2.3, the ``submit`` method was known as ``bind``. + Before Symfony 2.3, the ``submit()`` method was known as ``bind()``. Before Symfony 2.3, the :method:`Symfony\\Component\\Form\\FormInterface::submit` method accepted a :class:`Symfony\\Component\\HttpFoundation\\Request` object as diff --git a/form/dynamic_form_modification.rst b/form/dynamic_form_modification.rst index cacacc993e2..d88035b394b 100644 --- a/form/dynamic_form_modification.rst +++ b/form/dynamic_form_modification.rst @@ -255,8 +255,8 @@ done in the constructor:: .. note:: You might wonder, now that you have access to the User (through the token - storage), why not just use it directly in ``buildForm`` and omit the - event listener? This is because doing so in the ``buildForm`` method + storage), why not just use it directly in ``buildForm()`` and omit the + event listener? This is because doing so in the ``buildForm()`` method would result in the whole form type being modified and not just this one form instance. This may not usually be a problem, but technically a single form type could be used on a single request to create many forms diff --git a/form/form_collections.rst b/form/form_collections.rst index 5f300241e1e..f62484446f4 100644 --- a/form/form_collections.rst +++ b/form/form_collections.rst @@ -262,7 +262,7 @@ great, your user can't actually add any new tags yet. once (e.g ``form_widget(form)``). To fix this you can set this directive to a higher value (either via a ``php.ini`` file or via :phpfunction:`ini_set`, for example in ``app/autoload.php``) or render each form field by hand - using ``form_row``. + using ``form_row()``. .. _form-collections-new-prototype: @@ -326,7 +326,7 @@ new "tag" forms. To render it, make the following change to your template: The ``form.tags.vars.prototype`` is a form element that looks and feels just like the individual ``form_widget(tag)`` elements inside your ``for`` loop. - This means that you can call ``form_widget``, ``form_row`` or ``form_label`` + This means that you can call ``form_widget()``, ``form_row()`` or ``form_label()`` on it. You could even choose to render only one of its fields (e.g. the ``name`` field): @@ -348,7 +348,7 @@ somewhere on your page. Add a ``script`` tag somewhere on your page so you can start writing some JavaScript. First, add a link to the bottom of the "tags" list via JavaScript. Second, -bind to the "click" event of that link so you can add a new tag form (``addTagForm`` +bind to the "click" event of that link so you can add a new tag form (``addTagForm()`` will be show next): .. code-block:: javascript @@ -379,7 +379,7 @@ will be show next): }); }); -The ``addTagForm`` function's job will be to use the ``data-prototype`` attribute +The ``addTagForm()`` function's job will be to use the ``data-prototype`` attribute to dynamically add a new form when this link is clicked. The ``data-prototype`` HTML contains the tag ``text`` input element with a name of ``task[tags][__name__][name]`` and id of ``task_tags___name___name``. The ``__name__`` is a little "placeholder", @@ -465,7 +465,7 @@ Next, add a ``by_reference`` option to the ``tags`` field and set it to ``false` } With these two changes, when the form is submitted, each new ``Tag`` object -is added to the ``Task`` class by calling the ``addTag`` method. Before this +is added to the ``Task`` class by calling the ``addTag()`` method. Before this change, they were added internally by the form by calling ``$task->getTags()->add($tag)``. That was just fine, but forcing the use of the "adder" method makes handling these new ``Tag`` objects easier (especially if you're using Doctrine, which @@ -473,9 +473,9 @@ you will learn about next!). .. caution:: - You have to create **both** ``addTag`` and ``removeTag`` methods, - otherwise the form will still use ``setTag`` even if ``by_reference`` is ``false``. - You'll learn more about the ``removeTag`` method later in this article. + You have to create **both** ``addTag()`` and ``removeTag()`` methods, + otherwise the form will still use ``setTag()`` even if ``by_reference`` is ``false``. + You'll learn more about the ``removeTag()`` method later in this article. .. sidebar:: Doctrine: Cascading Relations and saving the "Inverse" side @@ -556,7 +556,7 @@ you will learn about next!). $this->tags->add($tag); } - Inside ``Tag``, just make sure you have an ``addTask`` method:: + Inside ``Tag``, just make sure you have an ``addTask()`` method:: // src/AppBundle/Entity/Tag.php @@ -569,7 +569,7 @@ you will learn about next!). } If you have a one-to-many relationship, then the workaround is similar, - except that you can simply call ``setTask`` from inside ``addTag``. + except that you can simply call ``setTask()`` from inside ``addTag()``. .. _form-collections-remove: @@ -594,7 +594,7 @@ Start by adding the ``allow_delete`` option in the form Type:: )); } -Now, you need to put some code into the ``removeTag`` method of ``Task``:: +Now, you need to put some code into the ``removeTag()`` method of ``Task``:: // src/AppBundle/Entity/Task.php @@ -639,7 +639,7 @@ First, add a "delete this tag" link to each tag form: addTagFormDeleteLink($newFormLi); } -The ``addTagFormDeleteLink`` function will look something like this: +The ``addTagFormDeleteLink()`` function will look something like this: .. code-block:: javascript @@ -657,7 +657,7 @@ The ``addTagFormDeleteLink`` function will look something like this: } When a tag form is removed from the DOM and submitted, the removed ``Tag`` object -will not be included in the collection passed to ``setTags``. Depending on +will not be included in the collection passed to ``setTags()``. Depending on your persistence layer, this may or may not be enough to actually remove the relationship between the removed ``Tag`` and ``Task`` object. @@ -677,7 +677,7 @@ the relationship between the removed ``Tag`` and ``Task`` object. you'll need to do more work for the removed tags to persist correctly. In this case, you can modify the controller to remove the relationship - on the removed tag. This assumes that you have some ``editAction`` which + on the removed tag. This assumes that you have some ``editAction()`` which is handling the "update" of your Task:: // src/AppBundle/Controller/TaskController.php diff --git a/form/form_customization.rst b/form/form_customization.rst index 5a206616473..e7cfab504f4 100644 --- a/form/form_customization.rst +++ b/form/form_customization.rst @@ -13,7 +13,7 @@ Form Rendering Basics --------------------- Recall that the label, error and HTML widget of a form field can easily -be rendered by using the ``form_row`` Twig function or the ``row`` PHP helper +be rendered by using the ``form_row()`` Twig function or the ``row`` PHP helper method: .. configuration-block:: @@ -371,7 +371,7 @@ file in order to customize the ``integer_widget`` fragment. Now that you've created the customized form template, you need to tell Symfony to use it. Inside the template where you're actually rendering your form, -tell Symfony to use the theme via the ``setTheme`` helper method:: +tell Symfony to use the theme via the ``setTheme()`` helper method:: setTheme($form, array(':form')); ?> @@ -381,7 +381,7 @@ When the ``form.age`` widget is rendered, Symfony will use the customized ``integer_widget.html.php`` template and the ``input`` tag will be wrapped in the ``div`` element. -If you want to apply a theme to a specific child form, pass it to the ``setTheme`` +If you want to apply a theme to a specific child form, pass it to the ``setTheme()`` method: .. code-block:: php @@ -799,7 +799,7 @@ Customizing Error Output There are many different ways to customize how errors are rendered when a form is submitted with errors. The error messages for a field are rendered -when you use the ``form_errors`` helper: +when you use the ``form_errors()`` helper: .. configuration-block:: @@ -923,7 +923,7 @@ Customizing the "Form Row" ~~~~~~~~~~~~~~~~~~~~~~~~~~ When you can manage it, the easiest way to render a form field is via the -``form_row`` function, which renders the label, errors and HTML widget of +``form_row()`` function, which renders the label, errors and HTML widget of a field. To customize the markup used for rendering *all* form field rows, override the ``form_row`` fragment. For example, suppose you want to add a class to the ``div`` element around each row: diff --git a/form/form_dependencies.rst b/form/form_dependencies.rst index 3906be4ba60..745179be010 100644 --- a/form/form_dependencies.rst +++ b/form/form_dependencies.rst @@ -44,7 +44,7 @@ create your form:: } Finally, the ``entity_manager`` option is accessible in the ``$options`` argument -of your ``buildForm`` method:: +of your ``buildForm()`` method:: // src/AppBundle/Form/TaskType.php // ... diff --git a/form/form_themes.rst b/form/form_themes.rst index 621ddb952f6..00026637dc8 100644 --- a/form/form_themes.rst +++ b/form/form_themes.rst @@ -49,7 +49,7 @@ do this, create a new template file that will store the new markup: The ``form_row`` form fragment is used when rendering most fields via the -``form_row`` function. To tell the Form component to use your new ``form_row`` +``form_row()`` function. To tell the Form component to use your new ``form_row`` fragment defined above, add the following to the top of the template that renders the form: @@ -77,7 +77,7 @@ renders the form: The ``form_theme`` tag (in Twig) "imports" the fragments defined in the given template and uses them when rendering the form. In other words, when the -``form_row`` function is called later in this template, it will use the ``form_row`` +``form_row()`` function is called later in this template, it will use the ``form_row`` block from your custom theme (instead of the default ``form_row`` block that ships with Symfony). @@ -117,10 +117,10 @@ the ``Resources/views/Form`` directory of the FrameworkBundle (`view on GitHub`_ Each fragment name follows the same basic pattern and is broken up into two pieces, separated by a single underscore character (``_``). A few examples are: -* ``form_row`` - used by ``form_row`` to render most fields; -* ``textarea_widget`` - used by ``form_widget`` to render a ``textarea`` field +* ``form_row`` - used by ``form_row()`` to render most fields; +* ``textarea_widget`` - used by ``form_widget()`` to render a ``textarea`` field type; -* ``form_errors`` - used by ``form_errors`` to render errors for a field; +* ``form_errors`` - used by ``form_errors()`` to render errors for a field; Each fragment follows the same basic pattern: ``type_part``. The ``type`` portion corresponds to the field *type* being rendered (e.g. ``textarea``, ``checkbox``, @@ -128,15 +128,15 @@ corresponds to the field *type* being rendered (e.g. ``textarea``, ``checkbox``, rendered (e.g. ``label``, ``widget``, ``errors``, etc). By default, there are 4 possible *parts* of a form that can be rendered: -+-------------+--------------------------+---------------------------------------------------------+ -| ``label`` | (e.g. ``form_label``) | renders the field's label | -+-------------+--------------------------+---------------------------------------------------------+ -| ``widget`` | (e.g. ``form_widget``) | renders the field's HTML representation | -+-------------+--------------------------+---------------------------------------------------------+ -| ``errors`` | (e.g. ``form_errors``) | renders the field's errors | -+-------------+--------------------------+---------------------------------------------------------+ -| ``row`` | (e.g. ``form_row``) | renders the field's entire row (label, widget & errors) | -+-------------+--------------------------+---------------------------------------------------------+ ++-------------+----------------------------+---------------------------------------------------------+ +| ``label`` | (e.g. ``form_label()``) | renders the field's label | ++-------------+----------------------------+---------------------------------------------------------+ +| ``widget`` | (e.g. ``form_widget()``) | renders the field's HTML representation | ++-------------+----------------------------+---------------------------------------------------------+ +| ``errors`` | (e.g. ``form_errors()``) | renders the field's errors | ++-------------+----------------------------+---------------------------------------------------------+ +| ``row`` | (e.g. ``form_row()``) | renders the field's entire row (label, widget & errors) | ++-------------+----------------------------+---------------------------------------------------------+ .. note:: diff --git a/form/rendering.rst b/form/rendering.rst index 9dc978903dc..0b55bb010fb 100644 --- a/form/rendering.rst +++ b/form/rendering.rst @@ -40,9 +40,9 @@ the other functions do? Renders the label, any errors, and the HTML form widget for the given field (e.g. ``dueDate``) inside, by default, a ``div`` element. -The majority of the work is done by the ``form_row`` helper, which renders +The majority of the work is done by the ``form_row()`` helper, which renders the label, errors and HTML form widget of each field inside a ``div`` tag by -default. In the :doc:`/form/form_themes` section, you'll learn how the ``form_row`` +default. In the :doc:`/form/form_themes` section, you'll learn how the ``form_row()`` output can be customized on many different levels. .. tip:: @@ -65,11 +65,11 @@ output can be customized on many different levels. Rendering each Field by Hand ---------------------------- -The ``form_row`` helper is great because you can very quickly render each +The ``form_row()`` helper is great because you can very quickly render each field of your form (and the markup used for the "row" can be customized as well). But since life isn't always so simple, you can also render each field entirely by hand. The end-product of the following is the same as when you -used the ``form_row`` helper: +used the ``form_row()`` helper: .. configuration-block:: diff --git a/form/unit_testing.rst b/form/unit_testing.rst index b5302a446c5..e3e0f4e8e4b 100644 --- a/form/unit_testing.rst +++ b/form/unit_testing.rst @@ -75,7 +75,7 @@ The simplest ``TypeTestCase`` implementation looks like the following:: So, what does it test? Here comes a detailed explanation. First you verify if the ``FormType`` compiles. This includes basic class -inheritance, the ``buildForm`` function and options resolution. This should +inheritance, the ``buildForm()`` function and options resolution. This should be the first test you write:: $type = new TestedType(); diff --git a/form/without_class.rst b/form/without_class.rst index 3f2e99b7851..aa88d4a24d0 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -39,8 +39,8 @@ By default, a form actually assumes that you want to work with arrays of data, instead of an object. There are exactly two ways that you can change this behavior and tie the form to an object instead: -#. Pass an object when creating the form (as the first argument to ``createFormBuilder`` - or the second argument to ``createForm``); +#. Pass an object when creating the form (as the first argument to ``createFormBuilder()`` + or the second argument to ``createForm()``); #. Declare the ``data_class`` option on your form. diff --git a/forms.rst b/forms.rst index 91012b646c8..5864cfbd42e 100644 --- a/forms.rst +++ b/forms.rst @@ -255,14 +255,14 @@ your controller:: .. caution:: - Be aware that the ``createView()`` method should be called *after* ``handleRequest`` + Be aware that the ``createView()`` method should be called *after* ``handleRequest()`` is called. Otherwise, changes done in the ``*_SUBMIT`` events aren't applied to the view (like validation errors). .. versionadded:: 2.3 The :method:`Symfony\\Component\\Form\\FormInterface::handleRequest` method was introduced in Symfony 2.3. Previously, the ``$request`` was passed - to the ``submit`` method - a strategy which is deprecated and will be + to the ``submit()`` method - a strategy which is deprecated and will be removed in Symfony 3.0. For details on that method, see :ref:`form-submit-request`. This controller follows a common pattern for handling forms, and has three @@ -653,7 +653,7 @@ the choice is ultimately up to you. Every form needs to know the name of the class that holds the underlying data (e.g. ``AppBundle\Entity\Task``). Usually, this is just guessed - based off of the object passed to the second argument to ``createForm`` + based off of the object passed to the second argument to ``createForm()`` (i.e. ``$task``). Later, when you begin embedding forms, this will no longer be sufficient. So, while not always necessary, it's generally a good idea to explicitly specify the ``data_class`` option by adding the diff --git a/http_cache/esi.rst b/http_cache/esi.rst index 55fe74434d3..b6d54eaf49d 100644 --- a/http_cache/esi.rst +++ b/http_cache/esi.rst @@ -159,7 +159,7 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags: array('strategy' => 'esi'), ) ?> -By using the ``esi`` renderer (via the ``render_esi`` Twig function), you +By using the ``esi`` renderer (via the ``render_esi()`` Twig function), you tell Symfony that the action should be rendered as an ESI tag. You might be wondering why you would want to use a helper instead of just writing the ESI tag yourself. That's because using a helper makes your application work even @@ -172,14 +172,14 @@ if there is no gateway cache installed. passed through ``render_esi`` also become part of the cache key so that you have unique caches for each combination of variables and values. -When using the default ``render`` function (or setting the renderer to +When using the default ``render()`` function (or setting the renderer to ``inline``), Symfony merges the included page content into the main one before sending the response to the client. But if you use the ``esi`` renderer -(i.e. call ``render_esi``) *and* if Symfony detects that it's talking to a +(i.e. call ``render_esi()``) *and* if Symfony detects that it's talking to a gateway cache that supports ESI, it generates an ESI include tag. But if there is no gateway cache or if it does not support ESI, Symfony will just merge the included page content within the main one as it would have done if you had -used ``render``. +used ``render()``. .. note:: diff --git a/performance.rst b/performance.rst index 67bd1989652..e9f9e15ffcd 100644 --- a/performance.rst +++ b/performance.rst @@ -52,7 +52,7 @@ automatically find any new classes that you've placed in the registered directories. Unfortunately, this comes at a cost, as the loader iterates over all configured -namespaces to find a particular file, making ``file_exists`` calls until it +namespaces to find a particular file, making ``file_exists()`` calls until it finally finds the file it's looking for. The simplest solution is to tell Composer to build a "class map" (i.e. a diff --git a/profiler/matchers.rst b/profiler/matchers.rst index 0cfd3f953c0..e926c529a1d 100644 --- a/profiler/matchers.rst +++ b/profiler/matchers.rst @@ -104,7 +104,7 @@ matcher:: .. versionadded:: 2.6 The :class:`Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface` was - introduced in Symfony 2.6. Prior, you had to use the ``isGranted`` method of + introduced in Symfony 2.6. Prior, you had to use the ``isGranted()`` method of :class:`Symfony\\Component\\Security\\Core\\SecurityContextInterface`. Then, configure a new service and set it as ``private`` because the application diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index c7b08a5c1d7..40ff7d17a6f 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -224,7 +224,7 @@ Logical Controller Names For controllers, you need to reference actions using the format ``BUNDLE_NAME:CONTROLLER_NAME:ACTION_NAME``. For instance, -``AppBundle:Default:index`` maps to the ``indexAction`` method from the +``AppBundle:Default:index`` maps to the ``indexAction()`` method from the ``AppBundle\Controller\DefaultController`` class. Extending Bundles diff --git a/quick_tour/the_view.rst b/quick_tour/the_view.rst index 6302d3b17ed..91de1cfd620 100644 --- a/quick_tour/the_view.rst +++ b/quick_tour/the_view.rst @@ -196,7 +196,7 @@ And what if you want to embed the result of another controller in a template? That's very useful when working with Ajax, or when the embedded template needs some variable not available in the main template. -Suppose you've created a ``topArticlesAction`` controller method to display +Suppose you've created a ``topArticlesAction()`` controller method to display the most popular articles of your website. If you want to "render" the result of that method (usually some HTML content) inside the ``index`` template, use the ``render()`` function: @@ -207,7 +207,7 @@ use the ``render()`` function: {{ render(controller('AppBundle:Default:topArticles')) }} Here, the ``render()`` and ``controller()`` functions use the special -``AppBundle:Default:topArticles`` syntax to refer to the ``topArticlesAction`` +``AppBundle:Default:topArticles`` syntax to refer to the ``topArticlesAction()`` action of the ``Default`` controller (the ``AppBundle`` part will be explained later):: diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 8e6dcdde3b9..93c4f31345b 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1024,7 +1024,7 @@ version This option is used to *bust* the cache on assets by globally adding a query parameter to all rendered asset paths (e.g. ``/images/logo.png?v2``). This -applies only to assets rendered via the Twig ``asset`` function (or PHP +applies only to assets rendered via the Twig ``asset()`` function (or PHP equivalent) as well as assets rendered with Assetic. For example, suppose you have the following: diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 2b975cf8369..b16cf657b6e 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -250,7 +250,7 @@ notReadableMessage **type**: ``string`` **default**: ``The file is not readable.`` -The message displayed if the file exists, but the PHP ``is_readable`` function +The message displayed if the file exists, but the PHP ``is_readable()`` function fails when passed the path to the file. uploadIniSizeErrorMessage diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index a4171bcf598..8f849af4d23 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -35,7 +35,7 @@ you want to guarantee that some ``state`` property is *not* in a dynamic return in_array($this->state, $this->invalidStates); } -In this case, the underlying object is only valid if the ``isStateInvalid`` +In this case, the underlying object is only valid if the ``isStateInvalid()`` method returns **false**: .. configuration-block:: diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 76a72f27f03..b93f806985c 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -116,7 +116,7 @@ type **type**: ``string`` [:ref:`default option `] This required option is the fully qualified class name or one of the PHP -datatypes as determined by PHP's ``is_`` functions. +datatypes as determined by PHP's ``is_()`` functions. * :phpfunction:`array ` * :phpfunction:`bool ` @@ -134,7 +134,7 @@ datatypes as determined by PHP's ``is_`` functions. * :phpfunction:`scalar ` * :phpfunction:`string ` -Also, you can use ``ctype_`` functions from corresponding +Also, you can use ``ctype_()`` functions from corresponding `built-in PHP extension`_. Consider `a list of ctype functions`_: * :phpfunction:`alnum ` diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 211fb0a3753..b1a8b95291b 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -147,10 +147,10 @@ not need to be used. repositoryMethod ~~~~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``findBy`` +**type**: ``string`` **default**: ``findBy()`` The name of the repository method to use for making the query to determine -the uniqueness. If it's left blank, the ``findBy`` method will be used. +the uniqueness. If it's left blank, the ``findBy()`` method will be used. This method should return a countable result. errorPath diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 11ad2c9f4ec..ce7afcdab9d 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -506,7 +506,7 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i } } -The ``isOptional`` method should return true if it's possible to use the +The ``isOptional()`` method should return true if it's possible to use the application without calling this cache warmer. In Symfony, optional warmers are always executed by default (you can change this by using the ``--no-optional-warmers`` option when executing the command). @@ -760,7 +760,7 @@ You can add a processor globally: .. tip:: - If your service is not a callable (using ``__invoke``) you can add the + If your service is not a callable (using ``__invoke()``) you can add the ``method`` attribute in the tag to use a specific method. You can add also a processor for a specific handler by using the ``handler`` @@ -930,7 +930,7 @@ security.voter **Purpose**: To add a custom voter to Symfony's authorization logic -When you call ``isGranted`` on Symfony's authorization checker, a system of "voters" +When you call ``isGranted()`` on Symfony's authorization checker, a system of "voters" is used behind the scenes to determine if the user should have access. The ``security.voter`` tag allows you to add your own custom voter to that system. @@ -1094,7 +1094,7 @@ you need on that file in order to load your translations. If you're loading translations from a database, you'll still need a resource file, but it might either be blank or contain a little bit of information about loading those resources from the database. The file is key to trigger -the ``load`` method on your custom loader. +the ``load()`` method on your custom loader. translation.extractor --------------------- diff --git a/reference/events.rst b/reference/events.rst index 119f83a4f0f..f425cc66005 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -90,7 +90,7 @@ a view sub-system. This event is called *only* if the Controller does *not* return a ``Response`` object. The purpose of the event is to allow some other return value to be converted into a ``Response``. -The value returned by the Controller is accessible via the ``getControllerResult`` +The value returned by the Controller is accessible via the ``getControllerResult()`` method:: use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; diff --git a/reference/forms/twig_reference.rst b/reference/forms/twig_reference.rst index f5b1c58fdda..1e545e90990 100644 --- a/reference/forms/twig_reference.rst +++ b/reference/forms/twig_reference.rst @@ -136,7 +136,7 @@ form or collection of fields, each underlying form row will be rendered. {# render a widget, but add a "foo" class to it #} {{ form_widget(form.name, {'attr': {'class': 'foo'}}) }} -The second argument to ``form_widget`` is an array of variables. The most +The second argument to ``form_widget()`` is an array of variables. The most common variable is ``attr``, which is an array of HTML attributes to apply to the HTML widget. In some cases, certain types also have other template-related options that can be passed. These are discussed on a type-by-type basis. @@ -159,7 +159,7 @@ label, errors and widget. {# render a field row, but display a label with text "foo" #} {{ form_row(form.name, {'label': 'foo'}) }} -The second argument to ``form_row`` is an array of variables. The templates +The second argument to ``form_row()`` is an array of variables. The templates provided in Symfony only allow to override the label as shown in the example above. @@ -272,7 +272,7 @@ Look at the ``form_label`` as an example: This block makes use of several variables: ``compound``, ``label_attr``, ``required``, ``label``, ``name`` and ``translation_domain``. These variables are made available by the form rendering system. But more importantly, these -are the variables that you can override when calling ``form_label`` (since +are the variables that you can override when calling ``form_label()`` (since in this example, you're rendering the label). The exact variables available to override depends on which part of the form @@ -284,8 +284,8 @@ be able to see what options you have available. .. tip:: Behind the scenes, these variables are made available to the ``FormView`` - object of your form when the Form component calls ``buildView`` and - ``finishView`` on each "node" of your form tree. To see what "view" + object of your form when the Form component calls ``buildView()`` and + ``finishView()`` on each "node" of your form tree. To see what "view" variables a particular field has, find the source code for the form field (and its parent fields) and look at the above two functions. diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 63364f1bc68..af7992c5c8c 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -104,7 +104,7 @@ If you already have the exact collection of entities that you want to include in the choice element, just pass them via the ``choices`` key. For example, if you have a ``$group`` variable (passed into your form perhaps -as a form option) and ``getUsers`` returns a collection of ``User`` entities, +as a form option) and ``getUsers()`` returns a collection of ``User`` entities, then you can supply the ``choices`` option directly:: $builder->add('users', 'entity', array( diff --git a/reference/forms/types/options/error_mapping.rst.inc b/reference/forms/types/options/error_mapping.rst.inc index 851f4b5287b..dd45aa9c3e1 100644 --- a/reference/forms/types/options/error_mapping.rst.inc +++ b/reference/forms/types/options/error_mapping.rst.inc @@ -5,7 +5,7 @@ error_mapping This option allows you to modify the target of a validation error. -Imagine you have a custom method named ``matchingCityAndZipCode`` that validates +Imagine you have a custom method named ``matchingCityAndZipCode()`` that validates whether the city and zip code match. Unfortunately, there is no "matchingCityAndZipCode" field in your form, so all that Symfony can do is display the error on top of the form. diff --git a/request/load_balancer_reverse_proxy.rst b/request/load_balancer_reverse_proxy.rst index 687b74c1041..c46f45ce573 100644 --- a/request/load_balancer_reverse_proxy.rst +++ b/request/load_balancer_reverse_proxy.rst @@ -93,7 +93,7 @@ In this case, you'll need to - *very carefully* - trust *all* proxies. // ... #. Ensure that the trusted_proxies setting in your ``app/config/config.yml`` - is not set or it will overwrite the ``setTrustedProxies`` call above. + is not set or it will overwrite the ``setTrustedProxies()`` call above. That's it! It's critical that you prevent traffic from all non-trusted sources. If you allow outside traffic, they could "spoof" their true IP address and diff --git a/routing.rst b/routing.rst index da1f3026937..57e35424f6b 100644 --- a/routing.rst +++ b/routing.rst @@ -636,7 +636,7 @@ route. With this information, any URL can easily be generated:: Generating URLs with Query Strings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The ``generate`` method takes an array of wildcard values to generate the URI. +The ``generate()`` method takes an array of wildcard values to generate the URI. But if you pass extra ones, they will be added to the URI as a query string:: $this->get('router')->generate('blog', array( diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index f762c4c4203..1c050935996 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -120,7 +120,7 @@ you do. The resource name itself is not actually used in the example:: } Make sure the controller you specify really exists. In this case you -have to create an ``extraAction`` method in the ``ExtraController`` +have to create an ``extraAction()`` method in the ``ExtraController`` of the ``AppBundle``:: // src/AppBundle/Controller/ExtraController.php diff --git a/routing/generate_url_javascript.rst b/routing/generate_url_javascript.rst index b3609cc6dc1..455e36c99d2 100644 --- a/routing/generate_url_javascript.rst +++ b/routing/generate_url_javascript.rst @@ -1,8 +1,8 @@ How to Generate Routing URLs in JavaScript ========================================== -If you're in a Twig template, you can use the same ``path`` function to set JavaScript -variables. The ``escape`` function helps escape any non-JavaScript-safe values: +If you're in a Twig template, you can use the same ``path()`` function to set JavaScript +variables. The ``escape()`` function helps escape any non-JavaScript-safe values: .. configuration-block:: diff --git a/routing/redirect_in_config.rst b/routing/redirect_in_config.rst index 56b929717b9..f78c14e5305 100644 --- a/routing/redirect_in_config.rst +++ b/routing/redirect_in_config.rst @@ -156,5 +156,5 @@ action: .. caution:: Because you are redirecting to a route instead of a path, the required - option is called ``route`` in the ``redirect`` action, instead of ``path`` - in the ``urlRedirect`` action. + option is called ``route`` in the ``redirect()`` action, instead of ``path`` + in the ``urlRedirect()`` action. diff --git a/security.rst b/security.rst index 2633a45dd79..450def03ced 100644 --- a/security.rst +++ b/security.rst @@ -1064,7 +1064,7 @@ this is a quirk. If you're not logged in, the user is technically the string ``null`` for convenience. The point is this: always check to see if the user is logged in before using -the User object, and use the ``isGranted`` method (or +the User object, and use the ``isGranted()`` method (or :ref:`access_control `) to do this:: // yay! Use this to see if the user is logged in diff --git a/security/acl.rst b/security/acl.rst index 29eaa5acab7..eb97f65bb61 100644 --- a/security/acl.rst +++ b/security/acl.rst @@ -16,7 +16,7 @@ the ACL system comes in. to check if a Blog is owned by the current User), then consider using :doc:`voters `. A voter is passed the object being voted on, which you can use to make complex decisions and effectively - implement your own ACL. Enforcing authorization (e.g. the ``isGranted`` + implement your own ACL. Enforcing authorization (e.g. the ``isGranted()`` part) will look similar to what you see in this entry, but your voter class will handle the logic behind the scenes, instead of the ACL system. diff --git a/security/acl_advanced.rst b/security/acl_advanced.rst index b097fea29cd..89b1857cf66 100644 --- a/security/acl_advanced.rst +++ b/security/acl_advanced.rst @@ -183,7 +183,7 @@ Process for Reaching Authorization Decisions -------------------------------------------- The ACL class provides two methods for determining whether a security identity -has the required bitmasks, ``isGranted`` and ``isFieldGranted``. When the ACL +has the required bitmasks, ``isGranted()`` and ``isFieldGranted()``. When the ACL receives an authorization request through one of these methods, it delegates this request to an implementation of :class:`Symfony\\Component\\Security\\Acl\\Domain\\PermissionGrantingStrategy`. diff --git a/security/api_key_authentication.rst b/security/api_key_authentication.rst index d2734490149..620675cc2e9 100644 --- a/security/api_key_authentication.rst +++ b/security/api_key_authentication.rst @@ -266,7 +266,7 @@ Handling Authentication Failure In order for your ``ApiKeyAuthenticator`` to correctly display a 401 http status when either bad credentials or authentication fails you will need to implement the :class:`Symfony\\Component\\Security\\Http\\Authentication\\AuthenticationFailureHandlerInterface` on your -Authenticator. This will provide a method ``onAuthenticationFailure`` which +Authenticator. This will provide a method ``onAuthenticationFailure()`` which you can use to create an error ``Response``. .. code-block:: php diff --git a/security/csrf_in_login_form.rst b/security/csrf_in_login_form.rst index e80cd7ea623..b5dc6a69360 100644 --- a/security/csrf_in_login_form.rst +++ b/security/csrf_in_login_form.rst @@ -81,7 +81,7 @@ Rendering the CSRF field Now that Security component will check for the CSRF token, you have to add a *hidden* field to the login form containing the CSRF token. By default, this field is named ``_csrf_token``. That hidden field must contain the CSRF -token, which can be generated by using the ``csrf_token`` function. That +token, which can be generated by using the ``csrf_token()`` function. That function requires a token ID, which must be set to ``authenticate`` when using the login form: diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index 16674be9faa..887642295f4 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -287,7 +287,7 @@ the ``PasswordDigest`` header value matches with the user's password. .. note:: The :class:`Symfony\\Component\\Security\\Core\\Authentication\\Provider\\AuthenticationProviderInterface` - requires an ``authenticate`` method on the user token, and a ``supports`` + requires an ``authenticate()`` method on the user token, and a ``supports()`` method, which tells the authentication manager whether or not to use this provider for the given token. In the case of multiple providers, the authentication manager will then move to the next provider in the list. @@ -356,19 +356,19 @@ create a class which implements The :class:`Symfony\\Bundle\\SecurityBundle\\DependencyInjection\\Security\\Factory\\SecurityFactoryInterface` requires the following methods: -``create`` +``create()`` Method which adds the listener and authentication provider to the DI container for the appropriate security context. -``getPosition`` +``getPosition()`` Returns when the provider should be called. This can be one of ``pre_auth``, ``form``, ``http`` or ``remember_me``. -``getKey`` +``getKey()`` Method which defines the configuration key used to reference the provider in the firewall configuration. -``addConfiguration`` +``addConfiguration()`` Method which is used to define the configuration options underneath the configuration key in your security configuration. Setting configuration options are explained later in this chapter. @@ -568,7 +568,7 @@ by default, is 5 minutes. Make this configurable, so different firewalls can have different timeout lengths. You will first need to edit ``WsseFactory`` and define the new option in -the ``addConfiguration`` method. +the ``addConfiguration()`` method. .. code-block:: php @@ -585,7 +585,7 @@ the ``addConfiguration`` method. } } -Now, in the ``create`` method of the factory, the ``$config`` argument will +Now, in the ``create()`` method of the factory, the ``$config`` argument will contain a ``lifetime`` key, set to 5 minutes (300 seconds) unless otherwise set in the configuration. Pass this argument to your authentication provider in order to put it to use. diff --git a/security/custom_password_authenticator.rst b/security/custom_password_authenticator.rst index 0dae771883d..abab0f1fe0d 100644 --- a/security/custom_password_authenticator.rst +++ b/security/custom_password_authenticator.rst @@ -108,7 +108,7 @@ Whatever token object you create here will be passed to you later in ``authentic 3) authenticateToken ~~~~~~~~~~~~~~~~~~~~ -If ``supportsToken`` returns ``true``, Symfony will now call ``authenticateToken()``. +If ``supportsToken()`` returns ``true``, Symfony will now call ``authenticateToken()``. Your job here is to check that the token is allowed to log in by first getting the ``User`` object via the user provider and then, by checking the password and the current time. diff --git a/security/custom_provider.rst b/security/custom_provider.rst index c3b2ccede4b..f50518380f0 100644 --- a/security/custom_provider.rst +++ b/security/custom_provider.rst @@ -330,7 +330,7 @@ is compared to the hashed password returned by your ``getPassword()`` method. then you'll need to do a bit more work so that Symfony properly encodes the password. That is beyond the scope of this entry, but would include sub-classing ``MessageDigestPasswordEncoder`` and overriding the - ``mergePasswordAndSalt`` method. + ``mergePasswordAndSalt()`` method. Additionally, you can configure the details of the algorithm used to hash passwords. In this example, the application sets explicitly the cost of diff --git a/security/entity_provider.rst b/security/entity_provider.rst index bd1803bc3bd..231551fa47c 100644 --- a/security/entity_provider.rst +++ b/security/entity_provider.rst @@ -550,7 +550,7 @@ the user will be logged out for security reasons. Even though this all happens automatically, there are a few important side-effects. -First, the :phpclass:`Serializable` interface and its ``serialize`` and ``unserialize`` +First, the :phpclass:`Serializable` interface and its ``serialize()`` and ``unserialize()`` methods have been added to allow the ``User`` class to be serialized to the session. This may or may not be needed depending on your setup, but it's probably a good idea. In theory, only the ``id`` needs to be serialized, diff --git a/security/form_login_setup.rst b/security/form_login_setup.rst index b6cfa53602b..40c4524fd0f 100644 --- a/security/form_login_setup.rst +++ b/security/form_login_setup.rst @@ -138,7 +138,7 @@ configuration (``login``): return $collection; -Great! Next, add the logic to ``loginAction`` that displays the login form:: +Great! Next, add the logic to ``loginAction()`` that displays the login form:: // src/AppBundle/Controller/SecurityController.php diff --git a/security/named_encoders.rst b/security/named_encoders.rst index 0cdd0b2eb7b..0a1b0e69af3 100644 --- a/security/named_encoders.rst +++ b/security/named_encoders.rst @@ -102,7 +102,7 @@ named encoders: This creates an encoder named ``harsh``. In order for a ``User`` instance to use it, the class must implement :class:`Symfony\\Component\\Security\\Core\\Encoder\\EncoderAwareInterface`. -The interface requires one method - ``getEncoderName`` - which should return +The interface requires one method - ``getEncoderName()`` - which should return the name of the encoder to use:: // src/Acme/UserBundle/Entity/User.php diff --git a/security/password_encoding.rst b/security/password_encoding.rst index 12893a17259..1b72a38739d 100644 --- a/security/password_encoding.rst +++ b/security/password_encoding.rst @@ -30,7 +30,7 @@ In order for this to work, just make sure that you have the encoder for your user class (e.g. ``AppBundle\Entity\User``) configured under the ``encoders`` key in ``app/config/security.yml``. -The ``$encoder`` object also has an ``isPasswordValid`` method, which takes +The ``$encoder`` object also has an ``isPasswordValid()`` method, which takes the ``User`` object as the first argument and the plain password to check as the second argument. diff --git a/security/remember_me.rst b/security/remember_me.rst index 216da7fa687..c0c37691321 100644 --- a/security/remember_me.rst +++ b/security/remember_me.rst @@ -278,12 +278,12 @@ your controller using annotations: * Once the user has entered their username and password, assuming the user receives the ``ROLE_USER`` role per your configuration, the user will have the ``IS_AUTHENTICATED_FULLY`` role and be able to access - any page in the account section, including the ``editAction`` controller. + any page in the account section, including the ``editAction()`` controller. * If the user's session ends, when the user returns to the site, they will be able to access every account page - except for the edit page - without being forced to re-authenticate. However, when they try to access the - ``editAction`` controller, they will be forced to re-authenticate, since + ``editAction()`` controller, they will be forced to re-authenticate, since they are not, yet, fully authenticated. For more information on securing services or methods in this way, diff --git a/service_container.rst b/service_container.rst index 00ccfc81acf..d103db82219 100644 --- a/service_container.rst +++ b/service_container.rst @@ -151,7 +151,7 @@ later how you can configure a service that has multiple instances in the In this example, the controller extends Symfony's base Controller, which gives you access to the service container itself. You can then use the - ``get`` method to locate and retrieve the ``app.mailer`` service from + ``get()`` method to locate and retrieve the ``app.mailer`` service from the service container. .. _service-container-parameters: diff --git a/service_container/scopes.rst b/service_container/scopes.rst index b509e73a1c8..0b7540b180e 100644 --- a/service_container/scopes.rst +++ b/service_container/scopes.rst @@ -124,7 +124,7 @@ A) Changing the Scope of your Service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Changing the scope of a service should be done in its definition. This example -assumes that the ``Mailer`` class has a ``__construct`` function whose first +assumes that the ``Mailer`` class has a ``__construct()`` function whose first argument is the ``ClientConfiguration`` object: .. configuration-block:: diff --git a/templating.rst b/templating.rst index 50ad22ee7ca..a2bcae0dc27 100644 --- a/templating.rst +++ b/templating.rst @@ -103,7 +103,7 @@ by default. You can even add your own *custom* filters, functions (and more) via a :doc:`Twig Extension `. Twig code will look similar to PHP code, with subtle, nice differences. The following -example uses a standard ``for`` tag and the ``cycle`` function to print ten div tags, +example uses a standard ``for`` tag and the ``cycle()`` function to print ten div tags, with alternating ``odd``, ``even`` classes: .. code-block:: html+twig @@ -635,7 +635,7 @@ configuration: return $collection; -To link to the page, just use the ``path`` Twig function and refer to the route: +To link to the page, just use the ``path()`` Twig function and refer to the route: .. configuration-block:: @@ -733,7 +733,7 @@ correctly: .. tip:: - You can also generate an absolute URL by using the ``url`` Twig function: + You can also generate an absolute URL by using the ``url()`` Twig function: .. code-block:: html+twig @@ -764,7 +764,7 @@ Linking to Assets Templates also commonly refer to images, JavaScript, stylesheets and other assets. Of course you could hard-code the path to these assets (e.g. ``/images/logo.png``), -but Symfony provides a more dynamic option via the ``asset`` Twig function: +but Symfony provides a more dynamic option via the ``asset()`` Twig function: .. configuration-block:: @@ -780,15 +780,15 @@ but Symfony provides a more dynamic option via the ``asset`` Twig function: -The ``asset`` function's main purpose is to make your application more portable. +The ``asset()`` function's main purpose is to make your application more portable. If your application lives at the root of your host (e.g. ``http://example.com``), then the rendered paths should be ``/images/logo.png``. But if your application lives in a subdirectory (e.g. ``http://example.com/my_app``), each asset path should render with the subdirectory (e.g. ``/my_app/images/logo.png``). The -``asset`` function takes care of this by determining how your application is +``asset()`` function takes care of this by determining how your application is being used and generating the correct paths accordingly. -Additionally, if you use the ``asset`` function, Symfony can automatically +Additionally, if you use the ``asset()`` function, Symfony can automatically append a query string to your asset, in order to guarantee that updated static assets won't be loaded from cache after being deployed. For example, ``/images/logo.png`` might look like ``/images/logo.png?v2``. For more information, see the :ref:`reference-framework-assets-version` diff --git a/templating/debug.rst b/templating/debug.rst index 5a372c793f8..00f2cd9b58f 100644 --- a/templating/debug.rst +++ b/templating/debug.rst @@ -33,7 +33,7 @@ for example, inside your controller:: The output of the ``dump()`` function is then rendered in the web developer toolbar. -The same mechanism can be used in Twig templates thanks to ``dump`` function: +The same mechanism can be used in Twig templates thanks to ``dump()`` function: .. code-block:: html+twig diff --git a/templating/formats.rst b/templating/formats.rst index 840a594c788..1e435282789 100644 --- a/templating/formats.rst +++ b/templating/formats.rst @@ -29,7 +29,7 @@ pattern is to do the following:: return $this->render('article/index.'.$format.'.twig'); } -The ``getRequestFormat`` on the ``Request`` object defaults to ``html``, +The ``getRequestFormat()`` on the ``Request`` object defaults to ``html``, but can return any other format based on the format requested by the user. The request format is most often managed by the routing, where a route can be configured so that ``/contact`` sets the request format to ``html`` while diff --git a/templating/hinclude.rst b/templating/hinclude.rst index e8c38c7b215..457b6f76c73 100644 --- a/templating/hinclude.rst +++ b/templating/hinclude.rst @@ -6,7 +6,7 @@ How to Embed Asynchronous Content with hinclude.js Controllers can be embedded asynchronously using the hinclude.js_ JavaScript library. As the embedded content comes from another page (or controller for that matter), -Symfony uses a version of the standard ``render`` function to configure ``hinclude`` +Symfony uses a version of the standard ``render()`` function to configure ``hinclude`` tags: .. configuration-block:: @@ -111,7 +111,7 @@ in your application configuration: ), )); -You can define default templates per ``render`` function (which will override +You can define default templates per ``render()`` function (which will override any global default template that is defined): .. configuration-block:: diff --git a/testing.rst b/testing.rst index f46f169bb35..0da3592469a 100644 --- a/testing.rst +++ b/testing.rst @@ -362,7 +362,7 @@ giving you a nice API for uploading files. You will learn more about the ``Link`` and ``Form`` objects in the :ref:`Crawler ` section below. -The ``request`` method can also be used to simulate form submissions directly +The ``request()`` method can also be used to simulate form submissions directly or perform more complex requests. Some useful examples:: // Directly submit a form (but using the Crawler is easier!) diff --git a/validation.rst b/validation.rst index a87fae05305..b457075a3d4 100644 --- a/validation.rst +++ b/validation.rst @@ -114,7 +114,7 @@ following: Using the ``validator`` Service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Next, to actually validate an ``Author`` object, use the ``validate`` method +Next, to actually validate an ``Author`` object, use the ``validate()`` method on the ``validator`` service (class :class:`Symfony\\Component\\Validator\\Validator`). The job of the ``validator`` is easy: to read the constraints (i.e. rules) of a class and verify if the data on the object satisfies those @@ -463,7 +463,7 @@ Constraint Targets ------------------ Constraints can be applied to a class property (e.g. ``name``), a public -getter method (e.g. ``getFullName``) or an entire class. Property constraints +getter method (e.g. ``getFullName()``) or an entire class. Property constraints are the most common and easy to use. Getter constraints allow you to specify more complex validation rules. Finally, class constraints are intended for scenarios where you want to validate a class as a whole. @@ -563,7 +563,7 @@ as "getters". The benefit of this technique is that it allows you to validate your object dynamically. For example, suppose you want to make sure that a password field doesn't match the first name of the user (for security reasons). You can -do this by creating an ``isPasswordLegal`` method, and then asserting that +do this by creating an ``isPasswordLegal()`` method, and then asserting that this method must return ``true``: .. configuration-block:: diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index 482a2dcc063..9ee954d0468 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -83,10 +83,10 @@ The validator class is also simple, and only has one required method ``validate( Inside ``validate``, you don't need to return a value. Instead, you add violations to the validator's ``context`` property and a value will be considered valid -if it causes no violations. The ``buildViolation`` method takes the error +if it causes no violations. The ``buildViolation()`` method takes the error message as its argument and returns an instance of :class:`Symfony\\Component\\Validator\\Violation\\ConstraintViolationBuilderInterface`. -The ``addViolation`` method call finally adds the violation to the context. +The ``addViolation()`` method call finally adds the violation to the context. Using the new Validator ----------------------- @@ -201,7 +201,7 @@ load this service from the container. .. note:: In earlier versions of Symfony, the tag required an ``alias`` key (usually set - to the class name). This is still allowed your constraint's ``validateBy`` + to the class name). This is still allowed your constraint's ``validateBy()`` method can return this alias (instead of a class name). Class Constraint Validator diff --git a/validation/group_service_resolver.rst b/validation/group_service_resolver.rst index c7cbf93a5a5..bf731b9613a 100644 --- a/validation/group_service_resolver.rst +++ b/validation/group_service_resolver.rst @@ -3,7 +3,7 @@ How to Dynamically Configure Validation Groups Sometimes you need advanced logic to determine the validation groups. If they can't be determined by a simple callback, you can use a service. Create a -service that implements ``__invoke`` which accepts a ``FormInterface`` as a +service that implements ``__invoke()`` which accepts a ``FormInterface`` as a parameter. .. code-block:: php diff --git a/validation/raw_values.rst b/validation/raw_values.rst index ad504514fac..56e4568979e 100644 --- a/validation/raw_values.rst +++ b/validation/raw_values.rst @@ -52,7 +52,7 @@ list of the available constraints - as well as the full class name for each constraint - is available in the :doc:`constraints reference ` section. -The ``validate`` method returns a :class:`Symfony\\Component\\Validator\\ConstraintViolationList` +The ``validate()`` method returns a :class:`Symfony\\Component\\Validator\\ConstraintViolationList` object, which acts just like an array of errors. Each error in the collection is a :class:`Symfony\\Component\\Validator\\ConstraintViolation` object, -which holds the error message on its ``getMessage`` method. +which holds the error message on its ``getMessage()`` method.