From 10e3a9e334fcf2f1939c7f72d6b8b4ce540961cb Mon Sep 17 00:00:00 2001 From: Ricardo de Vries Date: Mon, 14 Jan 2019 08:44:40 +0100 Subject: [PATCH 1/5] fix: Swap long with short syntax. --- contributing/community/review-comments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/community/review-comments.rst b/contributing/community/review-comments.rst index a317c12fa27..d64ceb880d0 100644 --- a/contributing/community/review-comments.rst +++ b/contributing/community/review-comments.rst @@ -113,7 +113,7 @@ If a piece of code is in fact wrong, explain why: * I profiled this change and it hurts performance significantly (if you don't profile, it's an opinion, so we can ignore) - * Code doesn't match Symfony's CS rules (e.g. ``use array()`` instead of ``[]``) + * Code doesn't match Symfony's CS rules (e.g. use ``[]`` instead of ``array()``) * We only provide integration with very popular projects (e.g. we integrate Bootstrap but not your own CSS framework) From 96f68fedaf40b506ab74dadd24dc5f802fe1f401 Mon Sep 17 00:00:00 2001 From: Ricardo de Vries Date: Mon, 14 Jan 2019 11:06:28 +0100 Subject: [PATCH 2/5] chore: (1/2) Replace long with short syntax. --- best_practices/business-logic.rst | 6 +- best_practices/controllers.rst | 10 +- best_practices/forms.rst | 14 +- best_practices/security.rst | 4 +- best_practices/templates.rst | 6 +- best_practices/tests.rst | 14 +- bundles.rst | 10 +- bundles/best_practices.rst | 8 +- bundles/configuration.rst | 42 ++-- bundles/extension.rst | 16 +- bundles/installation.rst | 10 +- bundles/prepend_extension.rst | 12 +- bundles/remove.rst | 6 +- components/asset.rst | 10 +- components/browser_kit.rst | 2 +- components/cache.rst | 12 +- .../cache/adapters/memcached_adapter.rst | 2 +- .../adapters/pdo_doctrine_dbal_adapter.rst | 2 +- components/config/caching.rst | 2 +- components/console/logger.rst | 2 +- components/dependency_injection.rst | 4 +- components/dom_crawler.rst | 20 +- components/event_dispatcher.rst | 18 +- components/expression_language/ast.rst | 4 +- components/expression_language/caching.rst | 4 +- components/expression_language/extending.rst | 2 +- components/expression_language/syntax.rst | 2 +- components/http_foundation.rst | 14 +- .../http_foundation/session_configuration.rst | 4 +- components/http_foundation/sessions.rst | 6 +- components/options_resolver.rst | 16 +- components/property_access.rst | 12 +- components/psr7.rst | 2 +- components/routing.rst | 10 +- components/templating.rst | 2 +- components/translation.rst | 2 +- components/translation/custom_formats.rst | 4 +- components/translation/usage.rst | 4 +- components/var_dumper.rst | 4 +- configuration.rst | 24 +-- console.rst | 4 +- contributing/code/standards.rst | 2 +- contributing/community/review-comments.rst | 2 +- controller.rst | 24 +-- deployment/fortrabbit.rst | 2 +- doctrine.rst | 39 ++-- email.rst | 8 +- event_dispatcher.rst | 16 +- form/dynamic_form_modification.rst | 4 +- form/type_guesser.rst | 10 +- form/unit_testing.rst | 2 +- form/validation_group_service_resolver.rst | 2 +- forms.rst | 34 ++-- http_cache.rst | 8 +- introduction/from_flat_php_to_symfony2.rst | 4 +- logging.rst | 48 ++--- page_creation.rst | 8 +- profiler/data_collector.rst | 2 +- reference/configuration/framework.rst | 2 +- reference/constraints/All.rst | 2 +- reference/constraints/Collection.rst | 2 +- reference/constraints/Count.rst | 2 +- reference/constraints/IsFalse.rst | 2 +- reference/forms/types/button.rst | 2 +- reference/forms/types/choice.rst | 4 +- reference/forms/types/collection.rst | 4 +- reference/forms/types/country.rst | 2 +- reference/forms/types/currency.rst | 2 +- reference/forms/types/entity.rst | 4 +- reference/forms/types/form.rst | 2 +- reference/forms/types/language.rst | 2 +- reference/forms/types/locale.rst | 2 +- reference/forms/types/options/attr.rst.inc | 2 +- .../forms/types/options/choice_attr.rst.inc | 2 +- .../forms/types/options/error_mapping.rst.inc | 2 +- .../invalid_message_parameters.rst.inc | 2 +- .../forms/types/options/label_attr.rst.inc | 2 +- .../types/options/preferred_choices.rst.inc | 2 +- reference/forms/types/repeated.rst | 6 +- reference/forms/types/reset.rst | 2 +- reference/forms/types/submit.rst | 2 +- reference/forms/types/timezone.rst | 2 +- routing.rst | 40 ++-- routing/conditions.rst | 8 +- routing/hostname_pattern.rst | 12 +- routing/requirements.rst | 4 +- routing/scheme.rst | 2 +- security.rst | 186 +++++++++--------- security/custom_authentication_provider.rst | 2 +- security/custom_password_authenticator.rst | 2 +- security/multiple_user_providers.rst | 2 +- serializer.rst | 26 +-- serializer/custom_encoders.rst | 4 +- serializer/custom_normalizer.rst | 2 +- serializer/encoders.rst | 2 +- service_container.rst | 12 +- service_container/tags.rst | 4 +- templating.rst | 8 +- templating/PHP.rst | 2 +- testing.rst | 72 +++---- testing/http_authentication.rst | 6 +- translation.rst | 24 +-- validation.rst | 38 ++-- 103 files changed, 542 insertions(+), 541 deletions(-) diff --git a/best_practices/business-logic.rst b/best_practices/business-logic.rst index a6313ae4cbf..143e1f696a4 100644 --- a/best_practices/business-logic.rst +++ b/best_practices/business-logic.rst @@ -312,11 +312,11 @@ Then, enable the bundle in ``AppKernel.php``, but only for the ``dev`` and { public function registerBundles() { - $bundles = array( + $bundles = [ // ... - ); + ]; - if (in_array($this->getEnvironment(), array('dev', 'test'))) { + if (in_array($this->getEnvironment(), ['dev', 'test'])) { // ... $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); } diff --git a/best_practices/controllers.rst b/best_practices/controllers.rst index 13beba910bd..2be1bf6f01e 100644 --- a/best_practices/controllers.rst +++ b/best_practices/controllers.rst @@ -108,9 +108,9 @@ for the homepage of our app:: ->getRepository(Post::class) ->findLatest(); - return $this->render('default/index.html.twig', array( + return $this->render('default/index.html.twig', [ 'posts' => $posts, - )); + ]); } } @@ -155,10 +155,10 @@ For example:: { $deleteForm = $this->createDeleteForm($post); - return $this->render('admin/post/show.html.twig', array( + return $this->render('admin/post/show.html.twig', [ 'post' => $post, 'delete_form' => $deleteForm->createView(), - )); + ]); } Normally, you'd expect a ``$id`` argument to ``showAction()``. Instead, by @@ -182,7 +182,7 @@ manually. In our application, we have this situation in ``CommentController``:: { $post = $this->getDoctrine() ->getRepository(Post::class) - ->findOneBy(array('slug' => $postSlug)); + ->findOneBy(['slug' => $postSlug]); if (!$post) { throw $this->createNotFoundException(); diff --git a/best_practices/forms.rst b/best_practices/forms.rst index 8c1233196af..5041e604d0d 100644 --- a/best_practices/forms.rst +++ b/best_practices/forms.rst @@ -42,9 +42,9 @@ form in its own PHP class:: public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => Post::class, - )); + ]); } } @@ -96,7 +96,7 @@ scope of that form:: { $builder // ... - ->add('save', SubmitType::class, array('label' => 'Create Post')) + ->add('save', SubmitType::class, ['label' => 'Create Post']) ; } @@ -123,10 +123,10 @@ some developers configure form buttons in the controller:: { $post = new Post(); $form = $this->createForm(PostType::class, $post); - $form->add('submit', SubmitType::class, array( + $form->add('submit', SubmitType::class, [ 'label' => 'Create', - 'attr' => array('class' => 'btn btn-default pull-right'), - )); + 'attr' => ['class' => 'btn btn-default pull-right'], + ]); // ... } @@ -215,7 +215,7 @@ Handling a form submit usually follows a similar template:: return $this->redirect($this->generateUrl( 'admin_post_show', - array('id' => $post->getId()) + ['id' => $post->getId()] )); } diff --git a/best_practices/security.rst b/best_practices/security.rst index 3e18057d02d..6eef4c6cf43 100644 --- a/best_practices/security.rst +++ b/best_practices/security.rst @@ -285,7 +285,7 @@ the same ``getAuthorEmail()`` logic you used above:: protected function supports($attribute, $subject) { - if (!in_array($attribute, array(self::CREATE, self::EDIT))) { + if (!in_array($attribute, [self::CREATE, self::EDIT])) { return false; } @@ -309,7 +309,7 @@ the same ``getAuthorEmail()`` logic you used above:: switch ($attribute) { case self::CREATE: // if the user is an admin, allow them to create new posts - if ($this->decisionManager->decide($token, array('ROLE_ADMIN'))) { + if ($this->decisionManager->decide($token, ['ROLE_ADMIN'])) { return true; } diff --git a/best_practices/templates.rst b/best_practices/templates.rst index 38a88f7610b..af12c73e8c8 100644 --- a/best_practices/templates.rst +++ b/best_practices/templates.rst @@ -122,11 +122,11 @@ class in the constructor of the Twig extension:: public function getFilters() { - return array( + return [ new TwigFilter( 'md2html', - array($this, 'markdownToHtml'), - array('is_safe' => array('html'), 'pre_escape' => 'html') + [$this, 'markdownToHtml'], + ['is_safe' => ['html'], 'pre_escape' => 'html') ), ); } diff --git a/best_practices/tests.rst b/best_practices/tests.rst index aef317a5b4f..4a26ee7139c 100644 --- a/best_practices/tests.rst +++ b/best_practices/tests.rst @@ -49,14 +49,14 @@ A functional test like this is simple to implement thanks to public function urlProvider() { - return array( - array('/'), - array('/posts'), - array('/post/fixture-post-1'), - array('/blog/category/fixture-category'), - array('/archives'), + return [ + ['/'], + ['/posts'], + ['/post/fixture-post-1'], + ['/blog/category/fixture-category'], + ['/archives'], // ... - ); + ]; } } diff --git a/bundles.rst b/bundles.rst index a4677f8a1fd..43ccbb10111 100644 --- a/bundles.rst +++ b/bundles.rst @@ -39,7 +39,7 @@ the ``registerBundles()`` method of the ``AppKernel`` class:: // app/AppKernel.php public function registerBundles() { - $bundles = array( + $bundles = [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), @@ -48,9 +48,9 @@ the ``registerBundles()`` method of the ``AppKernel`` class:: new Symfony\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new AppBundle\AppBundle(), - ); + ]; - if (in_array($this->getEnvironment(), array('dev', 'test'))) { + if (in_array($this->getEnvironment(), ['dev', 'test'])) { $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); @@ -107,12 +107,12 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class:: // app/AppKernel.php public function registerBundles() { - $bundles = array( + $bundles = [ // ... // register your bundle new Acme\TestBundle\AcmeTestBundle(), - ); + ]; // ... return $bundles; diff --git a/bundles/best_practices.rst b/bundles/best_practices.rst index 04e00f0ccfb..79607178c0f 100644 --- a/bundles/best_practices.rst +++ b/bundles/best_practices.rst @@ -232,10 +232,10 @@ following standardized instructions in your ``README.md`` file. { public function registerBundles() { - $bundles = array( + $bundles = [ // ... new \\(), - ); + ]; // ... } @@ -278,11 +278,11 @@ following standardized instructions in your ``README.md`` file. { public function registerBundles() { - $bundles = array( + $bundles = [ // ... new \\(), - ); + ]; // ... } diff --git a/bundles/configuration.rst b/bundles/configuration.rst index 2d5e830da5d..b7535d55c96 100644 --- a/bundles/configuration.rst +++ b/bundles/configuration.rst @@ -39,9 +39,9 @@ as integration of other related components: .. code-block:: php - $container->loadFromExtension('framework', array( + $container->loadFromExtension('framework', [ 'form' => true, - )); + ]); .. sidebar:: Using Parameters to Configure your Bundle @@ -91,10 +91,10 @@ allow users to configure it with some configuration that looks like this: .. code-block:: php // app/config/config.php - $container->loadFromExtension('acme_social', array( + $container->loadFromExtension('acme_social', [ 'client_id' => 123, 'client_secret' => 'your_secret', - )); + ]); The basic idea is that instead of having the user override individual parameters, you let the user configure just a few, specifically created, @@ -139,14 +139,14 @@ automatically converts XML and YAML to an array). For the configuration example in the previous section, the array passed to your ``load()`` method will look like this:: - array( - array( - 'twitter' => array( + [ + [ + 'twitter' => [ 'client_id' => 123, 'client_secret' => 'your_secret', - ), - ), - ) + ], + ], + ] Notice that this is an *array of arrays*, not just a single flat array of the configuration values. This is intentional, as it allows Symfony to parse @@ -154,21 +154,21 @@ several configuration resources. For example, if ``acme_social`` appears in another configuration file - say ``config_dev.yml`` - with different values beneath it, the incoming array might look like this:: - array( + [ // values from config.yml - array( - 'twitter' => array( + [ + 'twitter' => [ 'client_id' => 123, 'client_secret' => 'your_secret', - ), - ), + ], + ], // values from config_dev.yml - array( - 'twitter' => array( + [ + 'twitter' => [ 'client_id' => 456, - ), - ), - ) + ], + ], + ] The order of the two arrays depends on which one is set first. @@ -315,7 +315,7 @@ In your extension, you can load this and dynamically set its arguments:: public function load(array $configs, ContainerBuilder $container) { - $config = array(); + $config = []; // let resources override the previous set value foreach ($configs as $subConfig) { $config = array_merge($config, $subConfig); diff --git a/bundles/extension.rst b/bundles/extension.rst index 51b3e57abed..2daefd2fed6 100644 --- a/bundles/extension.rst +++ b/bundles/extension.rst @@ -157,17 +157,17 @@ class names:: // ... // this method can't compile classes that contain PHP annotations - $this->addClassesToCompile(array( + $this->addClassesToCompile([ UserManager::class, Slugger::class, // ... - )); + ]); // add here only classes that contain PHP annotations - $this->addAnnotatedClassesToCompile(array( + $this->addAnnotatedClassesToCompile([ 'AppBundle\\Controller\\DefaultController', // ... - )); + ]); } .. note:: @@ -186,15 +186,15 @@ The classes to compile can also be added using file path patterns:: { // ... - $this->addClassesToCompile(array( + $this->addClassesToCompile([ '**Bundle\\Manager\\', // ... - )); + ]); - $this->addAnnotatedClassesToCompile(array( + $this->addAnnotatedClassesToCompile([ '**Bundle\\Controller\\', // ... - )); + ]); } Patterns are transformed into the actual class namespaces using the classmap diff --git a/bundles/installation.rst b/bundles/installation.rst index 52adbe39fa4..c8f3e4ec1d5 100644 --- a/bundles/installation.rst +++ b/bundles/installation.rst @@ -61,10 +61,10 @@ The only thing you need to do now is register the bundle in ``AppKernel``:: public function registerBundles() { - $bundles = array( + $bundles = [ // ... new FOS\UserBundle\FOSUserBundle(), - ); + ]; // ... } @@ -85,11 +85,11 @@ and ``test`` environments, register the bundle in this way:: public function registerBundles() { - $bundles = array( + $bundles = [ // ... - ); + ]; - if (in_array($this->getEnvironment(), array('dev', 'test'))) { + if (in_array($this->getEnvironment(), ['dev', 'test'])) { $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); } diff --git a/bundles/prepend_extension.rst b/bundles/prepend_extension.rst index 28610a27154..fb9d3e5d470 100644 --- a/bundles/prepend_extension.rst +++ b/bundles/prepend_extension.rst @@ -64,7 +64,7 @@ in case a specific other bundle is not registered:: // determine if AcmeGoodbyeBundle is registered if (!isset($bundles['AcmeGoodbyeBundle'])) { // disable AcmeGoodbyeBundle in bundles - $config = array('use_acme_goodbye' => false); + $config = ['use_acme_goodbye' => false]; foreach ($container->getExtensions() as $name => $extension) { switch ($name) { case 'acme_something': @@ -90,7 +90,7 @@ in case a specific other bundle is not registered:: // check if entity_manager_name is set in the "acme_hello" configuration if (isset($config['entity_manager_name'])) { // prepend the acme_something settings with the entity_manager_name - $config = array('entity_manager_name' => $config['entity_manager_name']); + $config = ['entity_manager_name' => $config['entity_manager_name']]; $container->prependExtensionConfig('acme_something', $config); } } @@ -135,15 +135,15 @@ The above would be the equivalent of writing the following into the .. code-block:: php // app/config/config.php - $container->loadFromExtension('acme_something', array( + $container->loadFromExtension('acme_something', [ // ... 'use_acme_goodbye' => false, 'entity_manager_name' => 'non_default', - )); - $container->loadFromExtension('acme_other', array( + ]); + $container->loadFromExtension('acme_other', [ // ... 'use_acme_goodbye' => false, - )); + ]); More than one Bundle using PrependExtensionInterface ---------------------------------------------------- diff --git a/bundles/remove.rst b/bundles/remove.rst index 644e8742310..0c27eacb68b 100644 --- a/bundles/remove.rst +++ b/bundles/remove.rst @@ -19,11 +19,11 @@ bundle is only registered in the development environment:: { public function registerBundles() { - $bundles = array( + $bundles = [ new Acme\DemoBundle\AcmeDemoBundle(), - ); + ]; - if (in_array($this->getEnvironment(), array('dev', 'test'))) { + if (in_array($this->getEnvironment(), ['dev', 'test'])) { // comment or remove this line: // $bundles[] = new Acme\DemoBundle\AcmeDemoBundle(); // ... diff --git a/components/asset.rst b/components/asset.rst index 7d26723e363..b550f2ed036 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -292,10 +292,10 @@ constructor:: use Symfony\Component\Asset\UrlPackage; // ... - $urls = array( + $urls = [ '//static1.example.com/images/', '//static2.example.com/images/', - ); + ]; $urlPackage = new UrlPackage($urls, new StaticVersionStrategy('v1')); echo $urlPackage->getUrl('/logo.png'); @@ -320,7 +320,7 @@ protocol-relative URLs for HTTPs requests, any base URL for HTTP requests):: // ... $urlPackage = new UrlPackage( - array('http://example.com/', 'https://example.com/'), + ['http://example.com/', 'https://example.com/'], new StaticVersionStrategy('v1'), new RequestStackContext($requestStack) ); @@ -350,10 +350,10 @@ they all have different base paths:: $defaultPackage = new Package($versionStrategy); - $namedPackages = array( + $namedPackages = [ 'img' => new UrlPackage('http://img.example.com/', $versionStrategy), 'doc' => new PathPackage('/somewhere/deep/for/documents', $versionStrategy), - ); + ]; $packages = new Packages($defaultPackage, $namedPackages); diff --git a/components/browser_kit.rst b/components/browser_kit.rst index bab848c82c5..81bd04f01b6 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -207,7 +207,7 @@ into the client constructor:: $cookieJar->set($cookie); // create a client and set the cookies - $client = new Client(array(), null, $cookieJar); + $client = new Client([], null, $cookieJar); // ... History diff --git a/components/cache.rst b/components/cache.rst index af113fa4592..4557988c726 100644 --- a/components/cache.rst +++ b/components/cache.rst @@ -89,20 +89,20 @@ Now you can create, retrieve, update and delete items using this object:: You can also work with multiple items at once:: - $cache->setMultiple(array( + $cache->setMultiple([ 'stats.products_count' => 4711, 'stats.users_count' => 1356, - )); + ]); - $stats = $cache->getMultiple(array( + $stats = $cache->getMultiple([ 'stats.products_count', 'stats.users_count', - )); + ]); - $cache->deleteMultiple(array( + $cache->deleteMultiple([ 'stats.products_count', 'stats.users_count', - )); + ]); Available Simple Cache (PSR-16) Classes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/cache/adapters/memcached_adapter.rst b/components/cache/adapters/memcached_adapter.rst index f5eb8935774..245887460be 100644 --- a/components/cache/adapters/memcached_adapter.rst +++ b/components/cache/adapters/memcached_adapter.rst @@ -119,7 +119,7 @@ option names and their respective values:: $client = MemcachedAdapter::createConnection( // a DSN string or an array of DSN strings - array(), + [], // associative array of configuration options array( diff --git a/components/cache/adapters/pdo_doctrine_dbal_adapter.rst b/components/cache/adapters/pdo_doctrine_dbal_adapter.rst index 6ba9eb8f0b4..bbbf9507e82 100644 --- a/components/cache/adapters/pdo_doctrine_dbal_adapter.rst +++ b/components/cache/adapters/pdo_doctrine_dbal_adapter.rst @@ -32,7 +32,7 @@ third, and forth parameters:: $defaultLifetime = 0, // an array of options for configuring the database table and connection - $options = array() + $options = [] ); .. tip:: diff --git a/components/config/caching.rst b/components/config/caching.rst index 99cd4f6a2b1..9ef987a3165 100644 --- a/components/config/caching.rst +++ b/components/config/caching.rst @@ -35,7 +35,7 @@ should be regenerated:: // fill this with an array of 'users.yml' file paths $yamlUserFiles = ...; - $resources = array(); + $resources = []; foreach ($yamlUserFiles as $yamlUserFile) { // see the article "Loading resources" to diff --git a/components/console/logger.rst b/components/console/logger.rst index e38438664f9..3af034e66da 100644 --- a/components/console/logger.rst +++ b/components/console/logger.rst @@ -101,7 +101,7 @@ constructor:: LogLevel::CRITICAL => ConsoleLogger::ERROR, LogLevel::DEBUG => ConsoleLogger::INFO, ); - $logger = new ConsoleLogger($output, array(), $formatLevelMap); + $logger = new ConsoleLogger($output, [], $formatLevelMap); Errors ------ diff --git a/components/dependency_injection.rst b/components/dependency_injection.rst index 5c979c94b96..5023314048d 100644 --- a/components/dependency_injection.rst +++ b/components/dependency_injection.rst @@ -159,7 +159,7 @@ If you do want to though then the container can call the setter method:: $containerBuilder ->register('newsletter_manager', 'NewsletterManager') - ->addMethodCall('setMailer', array(new Reference('mailer'))); + ->addMethodCall('setMailer', [new Reference('mailer')]); You could then get your ``newsletter_manager`` service from the container like this:: @@ -300,7 +300,7 @@ config files: $container ->register('newsletter_manager', 'NewsletterManager') - ->addMethodCall('setMailer', array(new Reference('mailer'))); + ->addMethodCall('setMailer', [new Reference('mailer')]); Learn More ---------- diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 4288d31d97a..0fa5db13101 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -207,7 +207,7 @@ Extract attribute and/or node values from the list of nodes:: $attributes = $crawler ->filterXpath('//body/p') - ->extract(array('_text', 'class')) + ->extract(['_text', 'class']) ; .. note:: @@ -270,7 +270,7 @@ and :phpclass:`DOMNode` objects:: $crawler->addDocument($domDocument); $crawler->addNodeList($nodeList); - $crawler->addNodes(array($node)); + $crawler->addNodes([$node]); $crawler->addNode($node); $crawler->add($domDocument); @@ -428,9 +428,9 @@ form that the button lives in:: $crawler->filter('.form-vertical')->form(); // or "fill" the form fields with data - $form = $crawler->selectButton('my-super-button')->form(array( + $form = $crawler->selectButton('my-super-button')->form([ 'name' => 'Ryan', - )); + ]); The :class:`Symfony\\Component\\DomCrawler\\Form` object has lots of very useful methods for working with forms:: @@ -454,10 +454,10 @@ attribute followed by a query string of all of the form's values. You can virtually set and get values on the form:: // sets values on the form internally - $form->setValues(array( + $form->setValues([ 'registration[username]' => 'symfonyfan', 'registration[terms]' => 1, - )); + ]); // gets back an array of values - in the "flat" array like above $values = $form->getValues(); @@ -477,13 +477,13 @@ To work with multi-dimensional fields:: Pass an array of values:: // sets a single field - $form->setValues(array('multi' => array('value'))); + $form->setValues(['multi' => ['value']]); // sets multiple fields at once - $form->setValues(array('multi' => array( + $form->setValues(['multi' => [ 1 => 'value', 'dimensional' => 'an other value', - ))); + ]]); This is great, but it gets better! The ``Form`` object allows you to interact with your form like a browser, selecting radio values, ticking checkboxes, @@ -499,7 +499,7 @@ and uploading files:: $form['registration[birthday][year]']->select(1984); // selects many options from a "multiple" select - $form['registration[interests]']->select(array('symfony', 'cookies')); + $form['registration[interests]']->select(['symfony', 'cookies']); // fakes a file upload $form['registration[photo]']->upload('/path/to/lucas.jpg'); diff --git a/components/event_dispatcher.rst b/components/event_dispatcher.rst index ef5647bb4a1..077807710a7 100644 --- a/components/event_dispatcher.rst +++ b/components/event_dispatcher.rst @@ -141,7 +141,7 @@ A call to the dispatcher's ``addListener()`` method associates any valid PHP callable to an event:: $listener = new AcmeListener(); - $dispatcher->addListener('acme.foo.action', array($listener, 'onFooAction')); + $dispatcher->addListener('acme.foo.action', [$listener, 'onFooAction']); The ``addListener()`` method takes up to three arguments: @@ -214,10 +214,10 @@ determine which instance is passed. // registers an event listener $containerBuilder->register('listener_service_id', \AcmeListener::class) - ->addTag('kernel.event_listener', array( + ->addTag('kernel.event_listener', [ 'event' => 'acme.foo.action', 'method' => 'onFooAction', - )); + ]); // registers an event subscriber $containerBuilder->register('subscriber_service_id', \AcmeSubscriber::class) @@ -344,13 +344,13 @@ Take the following example of a subscriber that subscribes to the { public static function getSubscribedEvents() { - return array( - KernelEvents::RESPONSE => array( - array('onKernelResponsePre', 10), - array('onKernelResponsePost', -10), - ), + return [ + KernelEvents::RESPONSE => [ + ['onKernelResponsePre', 10], + ['onKernelResponsePost', -10], + ], OrderPlacedEvent::NAME => 'onStoreOrder', - ); + ]; } public function onKernelResponsePre(FilterResponseEvent $event) diff --git a/components/expression_language/ast.rst b/components/expression_language/ast.rst index ac1e2b62057..0f15c20647a 100644 --- a/components/expression_language/ast.rst +++ b/components/expression_language/ast.rst @@ -21,7 +21,7 @@ method after parsing any expression to get its AST:: use Symfony\Component\ExpressionLanguage\ExpressionLanguage; $ast = (new ExpressionLanguage()) - ->parse('1 + 2', array()) + ->parse('1 + 2', []) ->getNodes() ; @@ -41,7 +41,7 @@ method to turn the AST into an array:: // ... $astAsArray = (new ExpressionLanguage()) - ->parse('1 + 2', array()) + ->parse('1 + 2', []) ->getNodes() ->toArray() ; diff --git a/components/expression_language/caching.rst b/components/expression_language/caching.rst index 5bfe6ac38d4..361446a0645 100644 --- a/components/expression_language/caching.rst +++ b/components/expression_language/caching.rst @@ -58,7 +58,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and // ... // the parse() method returns a ParsedExpression - $expression = $expressionLanguage->parse('1 + 4', array()); + $expression = $expressionLanguage->parse('1 + 4', []); var_dump($expressionLanguage->evaluate($expression)); // prints 5 @@ -69,7 +69,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and $expression = new SerializedParsedExpression( '1 + 4', - serialize($expressionLanguage->parse('1 + 4', array())->getNodes()) + serialize($expressionLanguage->parse('1 + 4', [])->getNodes()) ); var_dump($expressionLanguage->evaluate($expression)); // prints 5 diff --git a/components/expression_language/extending.rst b/components/expression_language/extending.rst index 61a7846a767..4c7437d4355 100644 --- a/components/expression_language/extending.rst +++ b/components/expression_language/extending.rst @@ -129,7 +129,7 @@ or by using the second argument of the constructor:: class ExpressionLanguage extends BaseExpressionLanguage { - public function __construct(ParserCacheInterface $parser = null, array $providers = array()) + public function __construct(ParserCacheInterface $parser = null, array $providers = []) { // prepends the default provider to let users override it easily array_unshift($providers, new StringExpressionLanguageProvider()); diff --git a/components/expression_language/syntax.rst b/components/expression_language/syntax.rst index dae2c8c517a..a5aec2e7694 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -73,7 +73,7 @@ JavaScript:: { public function sayHi($times) { - $greetings = array(); + $greetings = []; for ($i = 0; $i < $times; $i++) { $greetings[] = 'Hi'; } diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 40ae2867c62..d0eff69a5d2 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -53,7 +53,7 @@ which is almost equivalent to the more verbose, but also more flexible, $request = new Request( $_GET, $_POST, - array(), + [], $_COOKIE, $_FILES, $_SERVER @@ -297,12 +297,12 @@ PHP callable that is able to create an instance of your ``Request`` class:: use Symfony\Component\HttpFoundation\Request; Request::setFactory(function ( - array $query = array(), - array $request = array(), - array $attributes = array(), - array $cookies = array(), - array $files = array(), - array $server = array(), + array $query = [], + array $request = [], + array $attributes = [], + array $cookies = [], + array $files = [], + array $server = [], $content = null ) { return new SpecialRequest( diff --git a/components/http_foundation/session_configuration.rst b/components/http_foundation/session_configuration.rst index 5ad54f7f132..8cbb690742c 100644 --- a/components/http_foundation/session_configuration.rst +++ b/components/http_foundation/session_configuration.rst @@ -45,7 +45,7 @@ Example usage:: use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; - $sessionStorage = new NativeSessionStorage(array(), new NativeFileSessionHandler()); + $sessionStorage = new NativeSessionStorage([], new NativeFileSessionHandler()); $session = new Session($sessionStorage); .. note:: @@ -84,7 +84,7 @@ Example usage:: use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; $pdo = new \PDO(...); - $sessionStorage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo)); + $sessionStorage = new NativeSessionStorage([], new PdoSessionHandler($pdo)); $session = new Session($sessionStorage); Configuring PHP Sessions diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index 609bee58191..40c97acf91b 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -33,7 +33,7 @@ Quick example:: $session->getFlashBag()->add('notice', 'Profile updated'); // retrieve messages - foreach ($session->getFlashBag()->get('notice', array()) as $message) { + foreach ($session->getFlashBag()->get('notice', []) as $message) { echo '
'.$message.'
'; } @@ -324,12 +324,12 @@ Displaying the flash messages might look as follows. Simple, display one type of message:: // display warnings - foreach ($session->getFlashBag()->get('warning', array()) as $message) { + foreach ($session->getFlashBag()->get('warning', []) as $message) { echo '
'.$message.'
'; } // display errors - foreach ($session->getFlashBag()->get('error', array()) as $message) { + foreach ($session->getFlashBag()->get('error', []) as $message) { echo '
'.$message.'
'; } diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 01bee94a151..828d56f59a7 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -30,7 +30,7 @@ Imagine you have a ``Mailer`` class which has four options: ``host``, { protected $options; - public function __construct(array $options = array()) + public function __construct(array $options = []) { $this->options = $options; } @@ -74,7 +74,7 @@ options are buried in the business logic of your code. Use the { // ... - public function __construct(array $options = array()) + public function __construct(array $options = []) { $this->options = array_replace(array( 'host' => 'smtp.example.org', @@ -107,7 +107,7 @@ class helps you to fix this problem:: { // ... - public function __construct(array $options = array()) + public function __construct(array $options = []) { $resolver = new OptionsResolver(); $resolver->setDefaults(array( @@ -158,7 +158,7 @@ It's a good practice to split the option configuration into a separate method:: { // ... - public function __construct(array $options = array()) + public function __construct(array $options = []) { $resolver = new OptionsResolver(); $this->configureOptions($resolver); @@ -651,11 +651,11 @@ can change your code to do the configuration only once per class:: // ... class Mailer { - private static $resolversByClass = array(); + private static $resolversByClass = []; protected $options; - public function __construct(array $options = array()) + public function __construct(array $options = []) { // What type of Mailer is this, a Mailer, a GoogleMailer, ... ? $class = get_class($this); @@ -684,11 +684,11 @@ method ``clearOptionsConfig()`` and call it periodically:: // ... class Mailer { - private static $resolversByClass = array(); + private static $resolversByClass = []; public static function clearOptionsConfig() { - self::$resolversByClass = array(); + self::$resolversByClass = []; } // ... diff --git a/components/property_access.rst b/components/property_access.rst index 8bf14e346e0..40eb212310f 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -144,7 +144,7 @@ getters, this means that you can do something like this:: class Person { private $author = true; - private $children = array(); + private $children = []; public function isAuthor() { @@ -243,7 +243,7 @@ also write to an array. This can be achieved using the method:: // ... - $person = array(); + $person = []; $propertyAccessor->setValue($person, '[first_name]', 'Wouter'); @@ -262,7 +262,7 @@ can use setters, the magic ``__set()`` method or properties to set values:: { public $firstName; private $lastName; - private $children = array(); + private $children = []; public function setLastName($name) { @@ -303,7 +303,7 @@ see `Enable other Features`_. // ... class Person { - private $children = array(); + private $children = []; public function __call($name, $args) { @@ -345,7 +345,7 @@ properties through *adder* and *remover* methods. /** * @var string[] */ - private $children = array(); + private $children = []; public function getChildren(): array { @@ -411,7 +411,7 @@ You can also mix objects and arrays:: class Person { public $firstName; - private $children = array(); + private $children = []; public function setChildren($children) { diff --git a/components/psr7.rst b/components/psr7.rst index 26f9fd0dbbb..35d009bc029 100644 --- a/components/psr7.rst +++ b/components/psr7.rst @@ -42,7 +42,7 @@ to a ``Zend\Diactoros\ServerRequest`` class implementing the use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory; use Symfony\Component\HttpFoundation\Request; - $symfonyRequest = new Request(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'dunglas.fr'), 'Content'); + $symfonyRequest = new Request([], [], [], [], [], array('HTTP_HOST' => 'dunglas.fr'), 'Content'); // The HTTP_HOST server key must be set to avoid an unexpected error $psr7Factory = new DiactorosFactory(); diff --git a/components/routing.rst b/components/routing.rst index 8b161e69e71..51967ed8e24 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -111,10 +111,10 @@ Take the following route, which combines several of these ideas:: '/archive/{month}', // path array('_controller' => 'showArchive'), // default values array('month' => '[0-9]{4}-[0-9]{2}', 'subdomain' => 'www|m'), // requirements - array(), // options + [], // options '{subdomain}.example.com', // host - array(), // schemes - array() // methods + [], // schemes + [] // methods ); // ... @@ -353,7 +353,7 @@ a path to the main route definition and some other settings:: public function __construct( LoaderInterface $loader, $resource, - array $options = array(), + array $options = [], RequestContext $context = null, LoggerInterface $logger = null ); @@ -447,7 +447,7 @@ routes with UTF-8 characters: array( '_controller' => 'AppBundle:Default:category', ), - array(), + [], array( 'utf8' => true, ) diff --git a/components/templating.rst b/components/templating.rst index 6d8fc3dac94..b341d216dbe 100644 --- a/components/templating.rst +++ b/components/templating.rst @@ -178,7 +178,7 @@ using the Templating component. To do that, create a new class which implements the :class:`Symfony\\Component\\Templating\\EngineInterface`. This requires 3 method: -* :method:`render($name, array $parameters = array()) ` +* :method:`render($name, array $parameters = []) ` - Renders a template * :method:`exists($name) ` - Checks if the template exists diff --git a/components/translation.rst b/components/translation.rst index 4ee67440aef..4190914db8e 100644 --- a/components/translation.rst +++ b/components/translation.rst @@ -207,7 +207,7 @@ loaded like this:: When translating strings that are not in the default domain (``messages``), you must specify the domain as the third argument of ``trans()``:: - $translator->trans('Symfony is great', array(), 'admin'); + $translator->trans('Symfony is great', [], 'admin'); Symfony will now look for the message in the ``admin`` domain of the specified locale. diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index c466a526749..c30c7dc59aa 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -37,7 +37,7 @@ create the catalog that will be returned:: { public function load($resource, $locale, $domain = 'messages') { - $messages = array(); + $messages = []; $lines = file($resource); foreach ($lines as $line) { @@ -85,7 +85,7 @@ will save a few lines:: class MyFormatDumper extends FileDumper { - public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) + public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) { $output = ''; diff --git a/components/translation/usage.rst b/components/translation/usage.rst index 9481109f1a9..f75a266b192 100644 --- a/components/translation/usage.rst +++ b/components/translation/usage.rst @@ -381,7 +381,7 @@ use for translation:: $translator->trans( 'Symfony is great', - array(), + [], 'messages', 'fr_FR' ); @@ -389,7 +389,7 @@ use for translation:: $translator->transChoice( '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples', 10, - array(), + [], 'messages', 'fr_FR' ); diff --git a/components/var_dumper.rst b/components/var_dumper.rst index 3177e830c69..14de490f875 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -176,7 +176,7 @@ then its dump representation:: 'a float' => 1.0, 'an integer' => 1, 'a boolean' => true, - 'an empty array' => array(), + 'an empty array' => [], ); dump($var); @@ -258,7 +258,7 @@ then its dump representation:: .. code-block:: php - $var = array(); + $var = []; $var[0] = 1; $var[1] =& $var[0]; $var[1] += 1; diff --git a/configuration.rst b/configuration.rst index e6a4358210a..e972de44e31 100644 --- a/configuration.rst +++ b/configuration.rst @@ -74,19 +74,19 @@ The main configuration file is called ``config.yml``: $this->import('security.yml'); $this->import('services.yml'); - $container->loadFromExtension('framework', array( + $container->loadFromExtension('framework', [ 'secret' => '%secret%', - 'router' => array( + 'router' => [ 'resource' => '%kernel.project_dir%/app/config/routing.php', - ), + ], // ... - )); + ]); // Twig Configuration - $container->loadFromExtension('twig', array( + $container->loadFromExtension('twig', [ 'debug' => '%kernel.debug%', 'strict_variables' => '%kernel.debug%', - )); + ]); // ... @@ -276,10 +276,10 @@ key: $container->setParameter('locale', 'en'); - $container->loadFromExtension('framework', array( + $container->loadFromExtension('framework', [ 'default_locale' => '%locale%', // ... - )); + ]); // ... @@ -349,15 +349,15 @@ configure DoctrineBundle and other parts of Symfony: .. code-block:: php // app/config/config.php - $container->loadFromExtension('doctrine', array( - 'dbal' => array( + $container->loadFromExtension('doctrine', [ + 'dbal' => [ 'driver' => 'pdo_mysql', // ... 'user' => '%database_user%', 'password' => '%database_password%', - ), - )); + ], + ]); But the ``parameters.yml`` file *is* special: it defines the values that usually change on each server. For example, the database credentials on your local diff --git a/console.rst b/console.rst index 477d301593b..857c6c81431 100644 --- a/console.rst +++ b/console.rst @@ -285,7 +285,7 @@ console:: $command = $application->find('app:create-user'); $commandTester = new CommandTester($command); - $commandTester->execute(array( + $commandTester->execute([ 'command' => $command->getName(), // pass arguments to the helper @@ -293,7 +293,7 @@ console:: // prefix the key with two dashes when passing options, // e.g: '--some-option' => 'option_value', - )); + ]); // the output of the command in the console $output = $commandTester->getDisplay(); diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index f734ec7946a..31786760616 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -86,7 +86,7 @@ short example containing most features described below: * * @throws \RuntimeException When an invalid option is provided */ - private function transformText($dummy, array $options = array()) + private function transformText($dummy, array $options = []) { $defaultOptions = array( 'some_default' => 'values', diff --git a/contributing/community/review-comments.rst b/contributing/community/review-comments.rst index d64ceb880d0..5207df78c9d 100644 --- a/contributing/community/review-comments.rst +++ b/contributing/community/review-comments.rst @@ -113,7 +113,7 @@ If a piece of code is in fact wrong, explain why: * I profiled this change and it hurts performance significantly (if you don't profile, it's an opinion, so we can ignore) - * Code doesn't match Symfony's CS rules (e.g. use ``[]`` instead of ``array()``) + * Code doesn't match Symfony's CS rules (e.g. use ``[]`` instead of ``[]``) * We only provide integration with very popular projects (e.g. we integrate Bootstrap but not your own CSS framework) diff --git a/controller.rst b/controller.rst index bf2c879e882..48668f8ae85 100644 --- a/controller.rst +++ b/controller.rst @@ -167,7 +167,7 @@ Generating URLs The :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl` method is just a helper method that generates the URL for a given route:: - $url = $this->generateUrl('blog_show', array('slug' => 'slug-value')); + $url = $this->generateUrl('blog_show', ['slug' => 'slug-value']); Redirecting ~~~~~~~~~~~ @@ -181,10 +181,10 @@ and ``redirect()`` methods:: return $this->redirectToRoute('homepage'); // does a permanent - 301 redirect - return $this->redirectToRoute('homepage', array(), 301); + return $this->redirectToRoute('homepage', [], 301); // redirects to a route with parameters - return $this->redirectToRoute('blog_show', array('slug' => 'my-page')); + return $this->redirectToRoute('blog_show', ['slug' => 'my-page']); // redirects to a route and mantains the original query string parameters return $this->redirectToRoute('blog_show', $request->query->all()); @@ -227,15 +227,15 @@ method renders a template **and** puts that content into a ``Response`` object for you:: // renders app/Resources/views/lucky/number.html.twig - return $this->render('lucky/number.html.twig', array('number' => $number)); + return $this->render('lucky/number.html.twig', ['number' => $number]); Templates can also live in deeper sub-directories. Just try to avoid creating unnecessarily deep structures:: // renders app/Resources/views/lottery/lucky/number.html.twig - return $this->render('lottery/lucky/number.html.twig', array( + return $this->render('lottery/lucky/number.html.twig', [ 'number' => $number, - )); + ]); The Symfony templating system and Twig are explained more in the :doc:`Creating and Using Templates article `. @@ -329,9 +329,9 @@ the argument by its name: $container->register(LuckyController::class) ->setPublic(true) - ->setBindings(array( + ->setBindings([ '$logger' => new Reference('monolog.logger.doctrine'), - )) + ]) ; You can of course also use normal :ref:`constructor injection ` @@ -484,7 +484,7 @@ type-hint to your argument and Symfony will provide you with a session:: $foobar = $session->get('foobar'); // uses a default value if the attribute doesn't exist - $filters = $session->get('filters', array()); + $filters = $session->get('filters', []); } Stored attributes remain in the session for the remainder of that user's session. @@ -590,7 +590,7 @@ the ``Request`` class:: { $request->isXmlHttpRequest(); // is it an Ajax request? - $request->getPreferredLanguage(array('en', 'fr')); + $request->getPreferredLanguage(['en', 'fr']); // retrieves GET and POST variables respectively $request->query->get('page'); @@ -658,10 +658,10 @@ This returns a special ``JsonResponse`` object that encodes the data automatical public function indexAction() { // returns '{"username":"jane.doe"}' and sets the proper Content-Type header - return $this->json(array('username' => 'jane.doe')); + return $this->json(['username' => 'jane.doe']); // the shortcut defines three optional arguments - // return $this->json($data, $status = 200, $headers = array(), $context = array()); + // return $this->json($data, $status = 200, $headers = [], $context = []); } If the :doc:`serializer service ` is enabled in your diff --git a/deployment/fortrabbit.rst b/deployment/fortrabbit.rst index ffe968e813d..0478f8cecac 100644 --- a/deployment/fortrabbit.rst +++ b/deployment/fortrabbit.rst @@ -98,7 +98,7 @@ contents:: // check if the Memcache component is present if (isset($secrets['MEMCACHE'])) { $memcache = $secrets['MEMCACHE']; - $handlers = array(); + $handlers = []; foreach (range(1, $memcache['COUNT']) as $num) { $handlers[] = $memcache['HOST'.$num].':'.$memcache['PORT'.$num]; diff --git a/doctrine.rst b/doctrine.rst index d5081462cac..aa029025461 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -100,15 +100,15 @@ information. By convention, this information is usually configured in an .. code-block:: php // app/config/config.php - $container->loadFromExtension('doctrine', array( - 'dbal' => array( + $container->loadFromExtension('doctrine', [ + 'dbal' => [ 'driver' => 'pdo_mysql', 'host' => '%database_host%', 'dbname' => '%database_name%', 'user' => '%database_user%', 'password' => '%database_password%', - ), - )); + ], + ]); By separating the database information into a separate file, you can easily keep different versions of the file on each server. You can also @@ -185,15 +185,15 @@ can automatically generate an empty ``test_project`` database for you: .. code-block:: php // app/config/config.php - $configuration->loadFromExtension('doctrine', array( - 'dbal' => array( + $configuration->loadFromExtension('doctrine', [ + 'dbal' => [ 'charset' => 'utf8mb4', - 'default_table_options' => array( + 'default_table_options' => [ 'charset' => 'utf8mb4', 'collate' => 'utf8mb4_unicode_ci', - ) - ), - )); + ] + ], + ]); We recommend against MySQL's ``utf8`` character set, since it does not support 4-byte unicode characters, and strings containing them will be @@ -248,13 +248,13 @@ can automatically generate an empty ``test_project`` database for you: .. code-block:: php // app/config/config.php - $container->loadFromExtension('doctrine', array( - 'dbal' => array( + $container->loadFromExtension('doctrine', [ + 'dbal' => [ 'driver' => 'pdo_sqlite', 'path' => '%kernel.project_dir%/app/sqlite.db', 'charset' => 'UTF-8', - ), - )); + ], + ]); Creating an Entity Class ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -664,14 +664,15 @@ to easily fetch objects based on multiple conditions:: $repository = $this->getDoctrine()->getRepository(Product::class); // looks for a single product matching the given name and price - $product = $repository->findOneBy( - array('name' => 'Keyboard', 'price' => 19.99) - ); + $product = $repository->findOneBy([ + 'name' => 'Keyboard', + 'price' => 19.99 + ]); // looks for multiple products matching the given name, ordered by price $products = $repository->findBy( - array('name' => 'Keyboard'), - array('price' => 'ASC') + ['name' => 'Keyboard'], + ['price' => 'ASC'] ); .. tip:: diff --git a/email.rst b/email.rst index 1ed48f76fd7..ed26b35fec6 100644 --- a/email.rst +++ b/email.rst @@ -60,12 +60,12 @@ already included: .. code-block:: php // app/config/config.php - $container->loadFromExtension('swiftmailer', array( + $container->loadFromExtension('swiftmailer', [ 'transport' => "%mailer_transport%", 'host' => "%mailer_host%", 'username' => "%mailer_user%", 'password' => "%mailer_password%", - )); + ]); These values (e.g. ``%mailer_transport%``), are reading from the parameters that are set in the :ref:`parameters.yml ` file. You @@ -110,7 +110,7 @@ an email is pretty straightforward:: $this->renderView( // app/Resources/views/Emails/registration.html.twig 'Emails/registration.html.twig', - array('name' => $name) + ['name' => $name] ), 'text/html' ) @@ -119,7 +119,7 @@ an email is pretty straightforward:: ->addPart( $this->renderView( 'Emails/registration.txt.twig', - array('name' => $name) + ['name' => $name] ), 'text/plain' ) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index af7a8f8c26f..edd79f985d7 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -104,7 +104,7 @@ using a special "tag": $container ->autowire(ExceptionListener::class) - ->addTag('kernel.event_listener', array('event' => 'kernel.exception')) + ->addTag('kernel.event_listener', ['event' => 'kernel.exception']) ; .. note:: @@ -151,13 +151,13 @@ listen to the same ``kernel.exception`` event:: public static function getSubscribedEvents() { // return the subscribed events, their methods and priorities - return array( - KernelEvents::EXCEPTION => array( - array('processException', 10), - array('logException', 0), - array('notifyException', -10), - ) - ); + return [ + KernelEvents::EXCEPTION => [ + ['processException', 10], + ['logException', 0], + ['notifyException', -10], + ] + ]; } public function processException(GetResponseForExceptionEvent $event) diff --git a/form/dynamic_form_modification.rst b/form/dynamic_form_modification.rst index 025bc472df4..dac2d089dbb 100644 --- a/form/dynamic_form_modification.rst +++ b/form/dynamic_form_modification.rst @@ -400,7 +400,7 @@ sport like this:: $data = $event->getData(); $sport = $data->getSport(); - $positions = null === $sport ? array() : $sport->getAvailablePositions(); + $positions = null === $sport ? [] : $sport->getAvailablePositions(); $form->add('position', EntityType::class, array( 'class' => 'AppBundle:Position', @@ -456,7 +456,7 @@ The type would now look like:: ; $formModifier = function (FormInterface $form, Sport $sport = null) { - $positions = null === $sport ? array() : $sport->getAvailablePositions(); + $positions = null === $sport ? [] : $sport->getAvailablePositions(); $form->add('position', EntityType::class, array( 'class' => 'AppBundle:Position', diff --git a/form/type_guesser.rst b/form/type_guesser.rst index bdfc2f0cfbf..853368f93f5 100644 --- a/form/type_guesser.rst +++ b/form/type_guesser.rst @@ -108,25 +108,25 @@ With this knowledge, you can easily implement the ``guessType()`` method of the case 'string': // there is a high confidence that the type is text when // @var string is used - return new TypeGuess(TextType::class, array(), Guess::HIGH_CONFIDENCE); + return new TypeGuess(TextType::class, [], Guess::HIGH_CONFIDENCE); case 'int': case 'integer': // integers can also be the id of an entity or a checkbox (0 or 1) - return new TypeGuess(IntegerType::class, array(), Guess::MEDIUM_CONFIDENCE); + return new TypeGuess(IntegerType::class, [], Guess::MEDIUM_CONFIDENCE); case 'float': case 'double': case 'real': - return new TypeGuess(NumberType::class, array(), Guess::MEDIUM_CONFIDENCE); + return new TypeGuess(NumberType::class, [], Guess::MEDIUM_CONFIDENCE); case 'boolean': case 'bool': - return new TypeGuess(CheckboxType::class, array(), Guess::HIGH_CONFIDENCE); + return new TypeGuess(CheckboxType::class, [], Guess::HIGH_CONFIDENCE); default: // there is a very low confidence that this one is correct - return new TypeGuess(TextType::class, array(), Guess::LOW_CONFIDENCE); + return new TypeGuess(TextType::class, [], Guess::LOW_CONFIDENCE); } } diff --git a/form/unit_testing.rst b/form/unit_testing.rst index 36c515c6932..6d49426d569 100644 --- a/form/unit_testing.rst +++ b/form/unit_testing.rst @@ -152,7 +152,7 @@ make sure the ``FormRegistry`` uses the created instance:: return array( // register the type instances with the PreloadedExtension - new PreloadedExtension(array($type), array()), + new PreloadedExtension(array($type), []), ); } diff --git a/form/validation_group_service_resolver.rst b/form/validation_group_service_resolver.rst index ec575067696..b5b704de5ef 100644 --- a/form/validation_group_service_resolver.rst +++ b/form/validation_group_service_resolver.rst @@ -29,7 +29,7 @@ parameter:: */ public function __invoke(FormInterface $form) { - $groups = array(); + $groups = []; // ... determine which groups to apply and return an array diff --git a/forms.rst b/forms.rst index 771462b60ea..0596254d57e 100644 --- a/forms.rst +++ b/forms.rst @@ -100,12 +100,12 @@ from inside a controller:: $form = $this->createFormBuilder($task) ->add('task', TextType::class) ->add('dueDate', DateType::class) - ->add('save', SubmitType::class, array('label' => 'Create Task')) + ->add('save', SubmitType::class, ['label' => 'Create Task']) ->getForm(); - return $this->render('default/new.html.twig', array( + return $this->render('default/new.html.twig', [ 'form' => $form->createView(), - )); + ]); } } @@ -224,7 +224,7 @@ your controller:: $form = $this->createFormBuilder($task) ->add('task', TextType::class) ->add('dueDate', DateType::class) - ->add('save', SubmitType::class, array('label' => 'Create Task')) + ->add('save', SubmitType::class, ['label' => 'Create Task']) ->getForm(); $form->handleRequest($request); @@ -243,9 +243,9 @@ your controller:: return $this->redirectToRoute('task_success'); } - return $this->render('default/new.html.twig', array( + return $this->render('default/new.html.twig', [ 'form' => $form->createView(), - )); + ]); } .. caution:: @@ -444,7 +444,7 @@ boxes. However, the :doc:`DateType ` can be configured to be rendered as a single text box (where the user would enter the date as a string in the box):: - ->add('dueDate', DateType::class, array('widget' => 'single_text')) + ->add('dueDate', DateType::class, ['widget' => 'single_text']) .. image:: /_images/form/simple-form-2.png :align: center @@ -462,10 +462,10 @@ the documentation for each type. :ref:`disable HTML5 validation ` or set the ``required`` option on your field to ``false``:: - ->add('dueDate', DateType::class, array( + ->add('dueDate', DateType::class, [ 'widget' => 'single_text', 'required' => false - )) + ]) Also note that setting the ``required`` option to ``true`` will **not** result in server-side validation to be applied. In other words, if a @@ -481,10 +481,10 @@ the documentation for each type. The label for the form field can be set using the ``label`` option, which can be applied to any field:: - ->add('dueDate', DateType::class, array( + ->add('dueDate', DateType::class, [ 'widget' => 'single_text', 'label' => 'Due Date', - )) + ]) The label for a field can also be set in the template rendering the form, see below. If you don't need a label associated to your input, @@ -510,7 +510,7 @@ guess from the validation rules that both the ``task`` field is a normal $form = $this->createFormBuilder($task) ->add('task') - ->add('dueDate', null, array('widget' => 'single_text')) + ->add('dueDate', null, ['widget' => 'single_text']) ->add('save', SubmitType::class) ->getForm(); } @@ -563,7 +563,7 @@ the correct values of a number of field options. If you'd like to change one of the guessed values, you can override it by passing the option in the options field array:: - ->add('task', null, array('attr' => array('maxlength' => 4))) + ->add('task', null, ['attr' => ['maxlength' => 4]]) .. index:: single: Forms; Creating form classes @@ -591,7 +591,7 @@ that will house the logic for building the task form:: { $builder ->add('task') - ->add('dueDate', null, array('widget' => 'single_text')) + ->add('dueDate', null, ['widget' => 'single_text']) ->add('save', SubmitType::class) ; } @@ -634,9 +634,9 @@ the choice is ultimately up to you. // ... public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => Task::class, - )); + ]); } .. tip:: @@ -656,7 +656,7 @@ the choice is ultimately up to you. $builder ->add('task') ->add('dueDate') - ->add('agreeTerms', CheckboxType::class, array('mapped' => false)) + ->add('agreeTerms', CheckboxType::class, ['mapped' => false]) ->add('save', SubmitType::class) ; } diff --git a/http_cache.rst b/http_cache.rst index 0001b357d29..2f77a314a22 100644 --- a/http_cache.rst +++ b/http_cache.rst @@ -127,10 +127,10 @@ method:: { protected function getOptions() { - return array( + return [ 'default_ttl' => 0, // ... - ); + ]; } } @@ -318,14 +318,14 @@ Additionally, most cache-related HTTP headers can be set via the single :method:`Symfony\\Component\\HttpFoundation\\Response::setCache` method:: // sets cache settings in one call - $response->setCache(array( + $response->setCache([ 'etag' => $etag, 'last_modified' => $date, 'max_age' => 10, 's_maxage' => 10, 'public' => true, // 'private' => true, - )); + ]); Cache Invalidation ------------------ diff --git a/introduction/from_flat_php_to_symfony2.rst b/introduction/from_flat_php_to_symfony2.rst index 17907f1c047..95112eb780f 100644 --- a/introduction/from_flat_php_to_symfony2.rst +++ b/introduction/from_flat_php_to_symfony2.rst @@ -91,7 +91,7 @@ the code that prepares the HTML "presentation":: $result = $connection->query('SELECT id, title FROM post'); - $posts = array(); + $posts = []; while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $posts[] = $row; } @@ -163,7 +163,7 @@ of the application are isolated in a new file called ``model.php``:: $result = $connection->query('SELECT id, title FROM post'); - $posts = array(); + $posts = []; while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $posts[] = $row; } diff --git a/logging.rst b/logging.rst index 56a3675bc44..eada00a454e 100644 --- a/logging.rst +++ b/logging.rst @@ -35,10 +35,10 @@ To log a message, inject the default logger in your controller:: $logger->info('I just got the logger'); $logger->error('An error occurred'); - $logger->critical('I left the oven on!', array( + $logger->critical('I left the oven on!', [ // include extra "context" info in your logs 'cause' => 'in_hurry', - )); + ]); // ... } @@ -147,19 +147,19 @@ to write logs using the :phpfunction:`syslog` function: .. code-block:: php // app/config/config.php - $container->loadFromExtension('monolog', array( - 'handlers' => array( - 'file_log' => array( + $container->loadFromExtension('monolog', [ + 'handlers' => [ + 'file_log' => [ 'type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug', - ), - 'syslog_handler' => array( + ], + 'syslog_handler' => [ 'type' => 'syslog', 'level' => 'error', - ), - ), - )); + ], + ], + ]); This defines a *stack* of handlers and each handler is called in the order that it's defined. @@ -232,22 +232,22 @@ one of the messages reaches an ``action_level``. Take this example: .. code-block:: php // app/config/config.php - $container->loadFromExtension('monolog', array( - 'handlers' => array( - 'filter_for_errors' => array( + $container->loadFromExtension('monolog', [ + 'handlers' => [ + 'filter_for_errors' => [ 'type' => 'fingers_crossed', 'action_level' => 'error', 'handler' => 'file_log', - ), - 'file_log' => array( + ], + 'file_log' => [ 'type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug', - ), - 'syslog_handler' => array( + ], + 'syslog_handler' => [ 'type' => 'syslog', 'level' => 'error', - ), + ], ), )); @@ -329,18 +329,18 @@ option of your handler to ``rotating_file``: .. code-block:: php // app/config/config_dev.php - $container->loadFromExtension('monolog', array( - 'handlers' => array( - 'main' => array( + $container->loadFromExtension('monolog', [ + 'handlers' => [ + 'main' => [ 'type' => 'rotating_file', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug', // max number of log files to keep // defaults to zero, which means infinite files 'max_files' => 10, - ), - ), - )); + ], + ], + ]); Using a Logger inside a Service ------------------------------- diff --git a/page_creation.rst b/page_creation.rst index 7e86bb78860..441b869f170 100644 --- a/page_creation.rst +++ b/page_creation.rst @@ -131,9 +131,9 @@ variable so we can render that:: { $number = random_int(0, 100); - return $this->render('lucky/number.html.twig', array( + return $this->render('lucky/number.html.twig', [ 'number' => $number, - )); + ]); } } @@ -207,11 +207,11 @@ Bundles are registered in your ``app/AppKernel.php`` file (a rare PHP file in th { public function registerBundles() { - $bundles = array( + $bundles = [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), // ... - ); + ]; // ... return $bundles; diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 3eb694d64af..c5ffb7e1559 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -40,7 +40,7 @@ request:: public function reset() { - $this->data = array(); + $this->data = []; } public function getName() diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index be562afb786..0a760cc1648 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -374,7 +374,7 @@ method. trusted_hosts ~~~~~~~~~~~~~ -**type**: ``array`` | ``string`` **default**: ``array()`` +**type**: ``array`` | ``string`` **default**: ``[]`` A lot of different attacks have been discovered relying on inconsistencies in handling the ``Host`` header by various software (web servers, reverse diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index d3116fd4e51..bc2ef16a579 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -38,7 +38,7 @@ entry in that array: * @Assert\Length(min=5) * }) */ - protected $favoriteColors = array(); + protected $favoriteColors = []; } .. code-block:: yaml diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 629957312fa..9c221078da5 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -140,7 +140,7 @@ following: class Author { - private $options = array(); + private $options = []; public static function loadValidatorMetadata(ClassMetadata $metadata) { diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index f1e2a716935..1c7bf87f561 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -44,7 +44,7 @@ you might add the following: * maxMessage = "You cannot specify more than {{ limit }} emails" * ) */ - protected $emails = array(); + protected $emails = []; } .. code-block:: yaml diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 093c7fd78df..9562911d2ce 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -28,7 +28,7 @@ you want to guarantee that some ``state`` property is *not* in a dynamic protected $state; - protected $invalidStates = array(); + protected $invalidStates = []; public function isStateInvalid() { diff --git a/reference/forms/types/button.rst b/reference/forms/types/button.rst index f7586fc7f33..b553e376b03 100644 --- a/reference/forms/types/button.rst +++ b/reference/forms/types/button.rst @@ -31,7 +31,7 @@ of the form type tree (i.e. it cannot be used as a form type on its own). attr ~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` If you want to add extra attributes to the HTML representation of the button, you can use ``attr`` option. It's an associative array with HTML attribute diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 032d7425572..e2fd45c398e 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -159,7 +159,7 @@ Field Options choices ~~~~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` This is the most basic way to specify the choices that should be used by this field. The ``choices`` option is an array, where the array key @@ -254,7 +254,7 @@ The actual default value of this option depends on other field options: * If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''`` (empty string); -* Otherwise ``array()`` (empty array). +* Otherwise ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 51d2357486f..14412c5c722 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -296,7 +296,7 @@ may define complex conditions for considering them empty. entry_options ~~~~~~~~~~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` This is the array that's passed to the form type specified in the `entry_type`_ option. For example, if you used the :doc:`ChoiceType ` @@ -408,7 +408,7 @@ Not all options are listed here - only the most applicable to this type: .. include:: /reference/forms/types/options/empty_data.rst.inc :end-before: DEFAULT_PLACEHOLDER -The default value is ``array()`` (empty array). +The default value is ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index cb4a11afabc..85c07cb27c7 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -99,7 +99,7 @@ The actual default value of this option depends on other field options: * If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''`` (empty string); -* Otherwise ``array()`` (empty array). +* Otherwise ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index bbe9a4fb01c..249003551d6 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -88,7 +88,7 @@ The actual default value of this option depends on other field options: * If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''`` (empty string); -* Otherwise ``array()`` (empty array). +* Otherwise ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 95c7f287a2a..d4ae9428176 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -270,7 +270,7 @@ These options inherit from the :doc:`ChoiceType ` preferred_choices ~~~~~~~~~~~~~~~~~ -**type**: ``array`` or ``callable`` **default**: ``array()`` +**type**: ``array`` or ``callable`` **default**: ``[]`` This option allows you to move certain choices to the top of your list with a visual separator between them and the rest of the options. This option expects an array @@ -313,7 +313,7 @@ The actual default value of this option depends on other field options: * If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''`` (empty string); -* Otherwise ``array()`` (empty array). +* Otherwise ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index 648420384e7..b03732aadc4 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -85,7 +85,7 @@ The actual default value of this option depends on other field options: * If ``data_class`` is set and ``required`` is ``true``, then ``new $data_class()``; * If ``data_class`` is set and ``required`` is ``false``, then ``null``; -* If ``data_class`` is not set and ``compound`` is ``true``, then ``array()`` +* If ``data_class`` is not set and ``compound`` is ``true``, then ``[]`` (empty array); * If ``data_class`` is not set and ``compound`` is ``false``, then ``''`` (empty string). diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 11269c6ce2a..2a60be33e9e 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -101,7 +101,7 @@ The actual default value of this option depends on other field options: * If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''`` (empty string); -* Otherwise ``array()`` (empty array). +* Otherwise ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 8f1a0a56936..99998ec4104 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -102,7 +102,7 @@ The actual default value of this option depends on other field options: * If ``multiple`` is ``false`` and ``expanded`` is ``false``, then ``''`` (empty string); -* Otherwise ``array()`` (empty array). +* Otherwise ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER diff --git a/reference/forms/types/options/attr.rst.inc b/reference/forms/types/options/attr.rst.inc index 46238ac023b..61098336a64 100644 --- a/reference/forms/types/options/attr.rst.inc +++ b/reference/forms/types/options/attr.rst.inc @@ -1,7 +1,7 @@ attr ~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` If you want to add extra attributes to an HTML field representation you can use the ``attr`` option. It's an associative array with HTML attributes diff --git a/reference/forms/types/options/choice_attr.rst.inc b/reference/forms/types/options/choice_attr.rst.inc index e185ae1c763..f4e2e437fb8 100644 --- a/reference/forms/types/options/choice_attr.rst.inc +++ b/reference/forms/types/options/choice_attr.rst.inc @@ -1,7 +1,7 @@ choice_attr ~~~~~~~~~~~ -**type**: ``array``, ``callable`` or ``string`` **default**: ``array()`` +**type**: ``array``, ``callable`` or ``string`` **default**: ``[]`` Use this to add additional HTML attributes to each choice. This can be an associative array where the keys match the choice keys and the values diff --git a/reference/forms/types/options/error_mapping.rst.inc b/reference/forms/types/options/error_mapping.rst.inc index dd45aa9c3e1..e39122c21bf 100644 --- a/reference/forms/types/options/error_mapping.rst.inc +++ b/reference/forms/types/options/error_mapping.rst.inc @@ -1,7 +1,7 @@ error_mapping ~~~~~~~~~~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` This option allows you to modify the target of a validation error. diff --git a/reference/forms/types/options/invalid_message_parameters.rst.inc b/reference/forms/types/options/invalid_message_parameters.rst.inc index b877f04bb72..4fa60037655 100644 --- a/reference/forms/types/options/invalid_message_parameters.rst.inc +++ b/reference/forms/types/options/invalid_message_parameters.rst.inc @@ -1,7 +1,7 @@ invalid_message_parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` When setting the ``invalid_message`` option, you may need to include some variables in the string. This can be done by adding placeholders diff --git a/reference/forms/types/options/label_attr.rst.inc b/reference/forms/types/options/label_attr.rst.inc index 6817483dcbd..0fb99337e34 100644 --- a/reference/forms/types/options/label_attr.rst.inc +++ b/reference/forms/types/options/label_attr.rst.inc @@ -1,7 +1,7 @@ label_attr ~~~~~~~~~~ -**type**: ``array`` **default**: ``array()`` +**type**: ``array`` **default**: ``[]`` Sets the HTML attributes for the ``