From 3f37f776dfab13f8e8a4b3d855c80b8fd520e582 Mon Sep 17 00:00:00 2001 From: lacpandore Date: Wed, 2 Oct 2024 12:38:32 +0200 Subject: [PATCH] add quote & update questions --- README.md | 3 +- data/Console/built_in_commands.yaml | 2 +- data/Console/built_in_helpers.yaml | 30 ++--- data/Console/verbosity_levels.yaml | 2 +- data/automated_tests/crawler_object.yaml | 36 +++++ .../framework_objects_access.yaml | 2 +- .../unit_tests_with_php_unit.yaml | 8 +- data/controllers/http_redirects.yaml | 8 +- .../built_in_validation_constraints.yaml | 4 +- data/data_validation/group_sequence.yaml | 6 +- .../dependency_injection/compiler_passes.yaml | 10 +- .../configuration_parameters.yaml | 126 ++++++++++++++++++ data/dependency_injection/factories.yaml | 2 +- .../service_container.yaml | 8 +- .../services_registration.yaml | 12 +- data/forms/built_in_form_types.yaml | 8 +- data/forms/csrf_protection.yaml | 12 +- data/forms/form_types.yaml | 14 +- data/forms/forms_creation.yaml | 2 +- data/forms/forms_handling.yaml | 2 +- data/http/client_server_interaction.yaml | 6 +- data/http/http_methods.yaml | 4 +- data/http/language_detection.yaml | 4 +- .../expiration_expires_cache_control.yaml | 2 +- ...che_process_and_serializer_components.yaml | 2 +- .../deployment_best_practices.yaml | 2 +- .../filesystem_and_finder_components.yaml | 2 +- ...web_debug_toolbar_and_data_collectors.yaml | 2 +- .../abstract_classes.yaml | 2 +- data/php_and_web_security/php_extensions.yaml | 22 +-- .../phpapi_up_to_php81_version.yaml | 14 +- .../routing/conditional_request_matching.yaml | 2 +- data/routing/domain_name_matching.yaml | 8 +- data/routing/http_methods_matching.yaml | 12 +- data/routing/router_debugging.yaml | 2 +- data/security/access_control_rules.yaml | 2 +- data/security/authentication.yaml | 4 +- data/security/authorization.yaml | 2 +- data/security/firewalls.yaml | 2 +- data/security/roles.yaml | 8 +- .../code_organization.yaml | 10 +- data/symfony_architecture/components.yaml | 4 +- .../naming_conventions.yaml | 4 +- .../official_best_practices.yaml | 10 +- data/symfony_architecture/symfony_flex.yaml | 4 +- data/templating_with_twig/auto_escaping.yaml | 2 +- .../controller_rendering.yaml | 11 -- .../global_variables.yaml | 10 +- .../string_interpolation.yaml | 6 +- .../twig_syntax_up_to33_version.yaml | 18 +-- 50 files changed, 311 insertions(+), 169 deletions(-) diff --git a/README.md b/README.md index ce52b94..5dc94e4 100644 --- a/README.md +++ b/README.md @@ -194,4 +194,5 @@ Ready to get certified? [Buy a voucher and register here](https://certification. For more information, read this [comprehensive article](https://www.itefficience.com/article/la-certification-twig-une-1ere-pour-le-chemin-de-la-certif-symfony). -Interested in training with our team? [Contact us](https://www.itefficience.com/contact)! \ No newline at end of file +Interested in training with our team? [Contact us](https://www.itefficience.com/contact)! + diff --git a/data/Console/built_in_commands.yaml b/data/Console/built_in_commands.yaml index 11e7efd..187e50c 100644 --- a/data/Console/built_in_commands.yaml +++ b/data/Console/built_in_commands.yaml @@ -103,7 +103,7 @@ questions: help: 'https://symfony.com/doc/current/service_container.html#linting-service-definitions' - uuid: 1eebf878-8ba7-6466-8627-99d84c92580c - question: 'Which Tester class should you use to test a console event?' + question: 'Which "Tester" class should you use to test a console event?' answers: - { value: Symfony\Component\Console\Tester\CommandTester, correct: false } - { value: Symfony\Component\Console\Tester\CommandCompletionTester, correct: false } diff --git a/data/Console/built_in_helpers.yaml b/data/Console/built_in_helpers.yaml index d60357d..f91ab17 100644 --- a/data/Console/built_in_helpers.yaml +++ b/data/Console/built_in_helpers.yaml @@ -28,7 +28,7 @@ questions: answers: - { value: $cursor->moveRight(3);, correct: true } - { value: $cursor->moveRight()->moveRight()->moveRight();, correct: true } - - { value: '$cursor->moveToPosition( $cursor->getCurrentPosition()[0], $cursor->getCurrentPosition()[1] + 3 );', correct: true } + - { value: "$cursor->moveToPosition($cursor->getCurrentPosition()[0], $cursor->getCurrentPosition()[1] + 3);", correct: true } help: 'https://symfony.com/doc/current/components/console/helpers/cursor.html#moving-the-cursor' - uuid: 1eebf878-8ba5-6be8-a74b-99d84c92580c @@ -51,7 +51,7 @@ questions: help: 'https://symfony.com/doc/current/components/console/helpers/formatterhelper.html' - uuid: 1eebf878-8ba5-6c74-a208-99d84c92580c - question: 'What is the correct way to truncate a message in a console with the formater helper ? $message = This is a very long message, which should be truncated ; to $message = This is a very long message, which should be!! ;' + question: 'What is the correct way to truncate a message in a console with the formater helper ? $message = "This is a very long message, which should be truncated";to $message = "This is a very long message, which should be!!";' answers: - { value: "$formatter->truncate($message, 44, '!!');", correct: true } - { value: "$formatter->truncateMessage($message, -10, '!!');", correct: false } @@ -63,7 +63,7 @@ questions: question: "In a console, how to disable the custom suffix '...' in the function truncate of the formater helper ?" answers: - { value: '$formatter->truncate($message, 7)->disableSuffix();', correct: false } - - { value: '$formatter->truncate($message, 7, );', correct: true } + - { value: '$formatter->truncate($message, 7, "");', correct: true } help: 'https://symfony.com/doc/current/components/console/helpers/formatterhelper.html#custom-suffix' - uuid: 1eebf878-8ba5-6d00-8fa6-99d84c92580c @@ -80,8 +80,8 @@ questions: uuid: 1eebf878-8ba5-6d46-ad98-99d84c92580c question: "What's the correct way to modify a rendered tables in a console ?" answers: - - { value: 'use $table->addRow([ Symfony ]);', correct: false } - - { value: 'use $table->appendRow([ Symfony ]);', correct: true } + - { value: 'use $table->addRow(["Symfony"]);', correct: false } + - { value: 'use $table->appendRow(["Symfony"]);', correct: true } help: 'https://symfony.com/doc/current/components/console/helpers/table.html#modifying-rendered-tables' - uuid: 1eebf878-8ba5-6e2c-93d3-99d84c92580c @@ -121,13 +121,13 @@ questions: uuid: 1eebf878-8ba5-6f62-b189-99d84c92580c question: 'What is the method to set the given value in the QuestionHelper for a test in the given tester: $commandTester = new CommandTester($command);' answers: - - { value: '$commandTester->setAnswer([ Test ]);', correct: false } - - { value: '$commandTester->setGivenValue([ Test ]);', correct: false } - - { value: '$commandTester->setInputs([ Test ]);', correct: true } + - { value: '$commandTester->setAnswer(["Test"]);', correct: false } + - { value: '$commandTester->setGivenValue(["Test"]);', correct: false } + - { value: '$commandTester->setInputs(["Test"]);', correct: true } help: 'https://symfony.com/doc/current/components/console/helpers/questionhelper.html#testing-a-command-that-expects-input' - uuid: 1eebf878-8ba5-6ff8-80bd-99d84c92580c - question: "In a question in your command, what is the way to set a list of valid values autocompletable that the user can answer to this question ? $question = new Question('Please enter the name of a bundle', 'FooBundle'); $bundles = ['AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle'];" + question: "In a question in your command, what is the way to set a list of valid values autocompletable that the user can answer to this question ? $question = new Question('Please enter the name of a bundle', 'FooBundle'); $bundles = ['AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle'];" answers: - { value: $question->setPossibleAnswers($bundles);, correct: false } - { value: $question->setAutocomplete($bundles);, correct: false } @@ -147,14 +147,14 @@ questions: uuid: 1eebf878-8ba6-608e-b8bd-99d84c92580c question: 'What are correct ways to give VERY VERBOSE detail on a ProgressBar in the console ?' answers: - - { value: '$progressBar->setFormat( very_verbose );', correct: true } + - { value: '$progressBar->setFormat("very_verbose");', correct: true } - { value: '$progressBar->setFormat(OutputInterface::VERBOSITY_VERY_VERBOSE);', correct: false } - - { value: 'add a -vv the end of the command launched', correct: true } + - { value: 'add a "-vv" the end of the command launched', correct: true } - { value: $progressBar->setVeryVerbose();, correct: false } help: 'https://symfony.com/doc/current/components/console/helpers/progressbar.html#customizing-the-progress-bar' - uuid: 1eebf878-8ba6-60de-91d5-99d84c92580c - question: 'For performance reasons, symfony redraws the screen once every XXXXms. If this is too fast or too slow for your application, use the methods minSecondsBetweenRedraws() and maxSecondsBetweenRedraws(): How much is XXX ?' + question: "For performance reasons, symfony redraws the screen once every XXXXms. If this is too fast or too slow for your application, use the methods minSecondsBetweenRedraws() and maxSecondsBetweenRedraws():\r\n\r\nHow much is XXX ?" answers: - { value: '50 ms', correct: false } - { value: '80 ms', correct: false } @@ -169,13 +169,13 @@ questions: answers: - { value: "$helper->run($output, 'figlet Symfony');", correct: true } - { value: "$helper->run($output, ['figlet', 'Symfony']);", correct: true } - - { value: "$process = new Process(['figlet', 'Symfony']); $helper->run($output, $process);", correct: true } + - { value: "$process = new Process(['figlet', 'Symfony']); $helper->run($output, $process);", correct: true } help: 'https://symfony.com/doc/current/components/console/helpers/processhelper.html' - uuid: 1eebf878-8ba6-6174-a67f-99d84c92580c question: "How can you customize the error message when using the Process Helper's run() method, such as in $helper->run($output, 'ls')?" answers: - - { value: "by adding ->setInvalidMesage($errorMessage) on run method like $helper->run($output, $process')->setInvalidMessage('Failed);", correct: false } - - { value: 'by adding a third argument $helper->run($output, $process, Failed );', correct: true } + - { value: "by adding ->setInvalidMesage($errorMessage) on run method like $helper->run($output, $process')->setInvalidMessage('Failed);", correct: false } + - { value: 'by adding a third argument $helper->run($output, $process, "Failed");', correct: true } - { value: 'By overring the message of the ProcessHelperException', correct: false } help: 'https://symfony.com/doc/current/components/console/helpers/processhelper.html#customized-display' diff --git a/data/Console/verbosity_levels.yaml b/data/Console/verbosity_levels.yaml index 846ecd9..b03d5b7 100644 --- a/data/Console/verbosity_levels.yaml +++ b/data/Console/verbosity_levels.yaml @@ -26,7 +26,7 @@ questions: help: 'https://symfony.com/doc/current/console/verbosity.html' - uuid: 1eebf878-8ba5-690e-84ef-99d84c92580c - question: "Is this a correct way to print information in a console for a verbose level or higher ? $output->writeln(OutputInterface::VERBOSITY_VERBOSE, 'Printed in verbose mode or higher');" + question: "Is this a correct way to print information in a console for a verbose level or higher ? $output->writeln(OutputInterface::VERBOSITY_VERBOSE, 'Printed in verbose mode or higher');" answers: - { value: 'Yes', correct: false } - { value: 'No', correct: true } diff --git a/data/automated_tests/crawler_object.yaml b/data/automated_tests/crawler_object.yaml index 0d642c0..fcaf569 100644 --- a/data/automated_tests/crawler_object.yaml +++ b/data/automated_tests/crawler_object.yaml @@ -17,3 +17,39 @@ questions: - { value: Symfony\Component\DomCrawler\CssSelector, correct: false } - { value: Symfony\Bundle\FrameworkBundle\CssSelector, correct: false } help: 'https://symfony.com/doc/current/components/css_selector.html#id1' + - + uuid: 1ef80030-6e1b-6534-8970-7d5c3695d3e1 + question: 'Which of the following methods is used to select nodes that match a CSS selector in Symfony DomCrawler?' + answers: + - { value: filterXpath(), correct: false } + - { value: filter(), correct: true } + - { value: eq(), correct: false } + - { value: first(), correct: false } + help: 'https://symfony.com/doc/7.0/testing/dom_crawler.html' + - + uuid: 1ef80033-e021-68a6-bdfe-d91142d7210b + question: 'What does the reduce() method in DomCrawler do?' + answers: + - { value: 'It reduces the number of nodes by selecting only the first node', correct: false } + - { value: 'It applies a callable to filter nodes, returning nodes for which the callable does not return false', correct: true } + - { value: 'It counts the number of nodes in the Crawler instance', correct: false } + - { value: 'It removes sibling nodes', correct: false } + help: 'https://symfony.com/doc/7.0/testing/dom_crawler.html' + - + uuid: 1ef80036-5b78-6dcc-80fa-f77948a3eeee + question: 'Which method should be used to get the parent nodes of a selected node in Symfony DomCrawler?' + answers: + - { value: 'children()', correct: false } + - { value: 'parents()', correct: true } + - { value: 'siblings()', correct: false } + - { value: 'nextAll()', correct: false } + help: 'https://symfony.com/doc/7.0/testing/dom_crawler.html' + - + uuid: 1ef80038-a364-6652-9e7e-85533c357fff + question: "What does the extract() method return when passed an array like ['_text', 'href']?" + answers: + - { value: 'It returns a string of all node values concatenated.', correct: false } + - { value: 'It extracts an array of attributes (text and href) for each node in the Crawler', correct: true } + - { value: "It returns the first node's text value only.", correct: false } + - { value: "It removes all nodes that don't have an href attribute.", correct: false } + help: 'https://symfony.com/doc/7.0/testing/dom_crawler.html' diff --git a/data/automated_tests/framework_objects_access.yaml b/data/automated_tests/framework_objects_access.yaml index fa21b2f..ca01657 100644 --- a/data/automated_tests/framework_objects_access.yaml +++ b/data/automated_tests/framework_objects_access.yaml @@ -30,7 +30,7 @@ questions: help: 'https://github.com/symfony/symfony/blob/7.0/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php' - uuid: 1eed57ff-6525-62ba-9d10-15125f5105d0 - question: 'Is this mapping correct ?/** @Column(name= number , type= integer ) */ private $number;' + question: 'Is this mapping correct ? /** @Column(name="number", type="integer") */ private $number;' answers: - { value: 'Yes', correct: false } - { value: 'No', correct: true } diff --git a/data/automated_tests/unit_tests_with_php_unit.yaml b/data/automated_tests/unit_tests_with_php_unit.yaml index 542a495..6bd88ef 100644 --- a/data/automated_tests/unit_tests_with_php_unit.yaml +++ b/data/automated_tests/unit_tests_with_php_unit.yaml @@ -53,10 +53,10 @@ questions: uuid: 1eebf878-8b9e-61c2-bcfc-99d84c92580c question: 'How to disable constructor when mocking an object?' answers: - - { value: '$this->getMock( My\Class )->disableOriginalConstructor()->getMock()', correct: false } - - { value: '$this->disableOriginalConstructor( My\Class'')', correct: false } - - { value: '$this->getMockBuilder( My\Class )->disableOriginalConstructor()->getMock()', correct: true } - - { value: '$this->getMockBuilder( My\Class )->getMock()->disableConstructor()', correct: false } + - { value: '$this->getMock("My\Class")->disableOriginalConstructor()->getMock()', correct: false } + - { value: '$this->disableOriginalConstructor("My\Class")', correct: false } + - { value: '$this->getMockBuilder("My\Class")->disableOriginalConstructor()->getMock()', correct: true } + - { value: '$this->getMockBuilder("My\Class")->getMock()->disableConstructor()', correct: false } help: 'https://phpunit.de/manual/6.5/en/test-doubles.html#test-doubles.stubs.examples.StubTest2.php' - uuid: 1eebf878-8b9e-6320-adc3-99d84c92580c diff --git a/data/controllers/http_redirects.yaml b/data/controllers/http_redirects.yaml index beef29c..0720b32 100644 --- a/data/controllers/http_redirects.yaml +++ b/data/controllers/http_redirects.yaml @@ -19,10 +19,10 @@ questions: uuid: 1eebf878-8b9e-6ffa-a320-99d84c92580c question: 'How to perform a redirection on example.org in a controller?' answers: - - { value: 'return $this->redirect($this->generateUrl( https://www.example.org ))', correct: false } - - { value: 'return $this->redirectUrl( https://www.example.org )', correct: false } - - { value: 'return $this->redirect( https://www.example.org )', correct: true } - - { value: 'return $this->generateUrl( https://www.example.org )', correct: false } + - { value: 'return $this->redirect($this->generateUrl("https://www.example.org"))', correct: false } + - { value: 'return $this->redirectUrl("https://www.example.org")', correct: false } + - { value: 'return $this->redirect("https://www.example.org")', correct: true } + - { value: 'return $this->generateUrl("https://www.example.org")', correct: false } help: 'https://symfony.com/doc/current/controller.html#redirecting' - uuid: 1eebf878-8ba8-692e-8bef-99d84c92580c diff --git a/data/data_validation/built_in_validation_constraints.yaml b/data/data_validation/built_in_validation_constraints.yaml index b19c6a5..b4073e1 100644 --- a/data/data_validation/built_in_validation_constraints.yaml +++ b/data/data_validation/built_in_validation_constraints.yaml @@ -41,7 +41,7 @@ questions: uuid: 1eebf878-8b9f-6d24-94f5-99d84c92580c question: 'How do you bind a constraint to a form field?' answers: - - { value: 'Using option constraints in $formBuilder->add()', correct: true } + - { value: 'Using option "constraints" in $formBuilder->add()', correct: true } - { value: 'Passing constraint instance in $this->createFormBuilder()', correct: false } - { value: 'Invoke $formBuilder->setConstraints() method', correct: false } - { value: 'Add an annotation in model', correct: true } @@ -71,7 +71,7 @@ questions: - { value: 'null', correct: true } - { value: '2020-01-15', correct: true } - { value: 15/01/2020, correct: false } - - { value: 'new \DateTime( 2020-01-15 )', correct: false } + - { value: 'new \DateTime("2020-01-15")', correct: false } - { value: '2020-13-15', correct: false } - { value: 15/13/2020, correct: false } help: 'https://symfony.com/doc/current/reference/constraints/Date.html' diff --git a/data/data_validation/group_sequence.yaml b/data/data_validation/group_sequence.yaml index 01c79fd..116e9fa 100644 --- a/data/data_validation/group_sequence.yaml +++ b/data/data_validation/group_sequence.yaml @@ -10,7 +10,7 @@ questions: uuid: 1eec03b4-9e6d-6856-9534-cd3903165108 question: "In which function, if there's a violation in any group, the rest of the groups are not validated. E.g. if 'User' fails, 'Premium' and 'Api' are not validated." answers: - - { value: "public function getGroupSequence(): array|GroupSequence { return ['User', 'Premium', 'Api']; }", correct: true } - - { value: "public function getGroupSequence(): array|GroupSequence { return [[['User'], 'Premium'], 'Api']; }", correct: false } - - { value: "public function getGroupSequence(): array|GroupSequence { return [['User'], ['Premium'], ['Api']]; }", correct: false } + - { value: "public function getGroupSequence(): array|GroupSequence { return ['User', 'Premium', 'Api']; }", correct: true } + - { value: "public function getGroupSequence(): array|GroupSequence { return [[['User'], 'Premium'], 'Api']; }", correct: false } + - { value: "public function getGroupSequence(): array|GroupSequence { return [['User'], ['Premium'], ['Api']]; }", correct: false } help: 'https://symfony.com/doc/current/validation/sequence_provider.html#group-sequence-providers' diff --git a/data/dependency_injection/compiler_passes.yaml b/data/dependency_injection/compiler_passes.yaml index 514bad0..9831792 100644 --- a/data/dependency_injection/compiler_passes.yaml +++ b/data/dependency_injection/compiler_passes.yaml @@ -40,7 +40,7 @@ questions: help: 'https://symfony.com/doc/current/components/dependency_injection/compilation.html#controlling-the-pass-ordering' - uuid: 1ef4935f-f7df-6ebe-bb60-7bba21e8d9fb - question: 'What is a compiler pass in Symfony?' + question: 'What is a "compiler pass" in Symfony?' answers: - { value: 'A tool to manage database migrations', correct: false } - { value: 'A mechanism to modify the service container before it is compiled', correct: true } @@ -48,7 +48,7 @@ questions: help: 'https://symfony.com/doc/current/service_container/compiler_passes.html' - uuid: 1ef49363-d37f-69d0-9063-c36a242f9461 - question: 'In which file is the build method often implemented to add a compiler pass ?' + question: 'In which file is the build method often implemented to add a "compiler pass"?' answers: - { value: config.yml, correct: false } - { value: Kernel.php, correct: true } @@ -56,7 +56,7 @@ questions: help: 'https://symfony.com/doc/current/service_container/compiler_passes.html' - uuid: 1ef49369-5acb-6f42-8894-eb7574faa390 - question: 'Where are compiler passes typically saved?' + question: 'Where are "compiler passes" typically saved?' answers: - { value: 'In config/packages', correct: false } - { value: 'In src/DependencyInjection/Compiler', correct: true } @@ -64,7 +64,7 @@ questions: help: 'https://symfony.com/doc/current/service_container/compiler_passes.html' - uuid: 1ef4936c-ce1d-65c4-b100-e7c0f56ef5bd - question: 'Which service should be used to add a compiler pass in the build method?' + question: 'Which service should be used to add a "compiler pass" in the build method?' answers: - { value: $container, correct: false } - { value: $this->containerBuilder, correct: false } @@ -72,7 +72,7 @@ questions: help: 'https://symfony.com/doc/current/service_container/compiler_passes.html' - uuid: 1ef4936f-6ee6-651c-abec-9db2348bdd73 - question: 'What is the main object used in a compiler pass to access the services?' + question: 'What is the main object used in a "compiler pass" to access the services?' answers: - { value: ContainerBuilder, correct: true } - { value: ServiceContainer, correct: false } diff --git a/data/dependency_injection/configuration_parameters.yaml b/data/dependency_injection/configuration_parameters.yaml index a92d1d8..fda2416 100644 --- a/data/dependency_injection/configuration_parameters.yaml +++ b/data/dependency_injection/configuration_parameters.yaml @@ -106,3 +106,129 @@ questions: - { value: 'A callback executed if the cache has to be refreshed', correct: true } - { value: 'The resource filename', correct: false } help: 'https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Config/ConfigCacheFactory.php' + - + uuid: 1ef80078-f45b-64da-8d99-253d4466d548 + question: 'In which file is the APP_ENV variable defined to choose the active environment for the application in Symfony?' + answers: + - { value: config/packages/framework.yaml, correct: false } + - { value: .env, correct: true } + - { value: services.yaml, correct: false } + - { value: composer.json, correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html' + - + uuid: 1ef8007c-6a77-6666-acda-f97fd898b2ef + question: 'What is the command to run a Symfony task in a specific environment without modifying the .env file?' + answers: + - { value: 'php bin/console --env=prod ', correct: false } + - { value: 'APP_ENV=prod php bin/console ', correct: true } + - { value: 'php bin/console env:prod ', correct: false } + - { value: 'php bin/console set-env prod', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html' + - + uuid: 1ef8007f-1f7a-6606-9139-fd4c956a4883 + question: 'What syntax is used to reference an environment variable in a YAML configuration file?' + answers: + - { value: '%env(VAR_NAME)%', correct: true } + - { value: '${VAR_NAME}', correct: false } + - { value: '{{ env(VAR_NAME) }}', correct: false } + - { value: '#env(VAR_NAME)#', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html' + - + uuid: 1ef80081-4f13-63a2-98e6-8390f97f5219 + question: 'If an environment variable is not defined, how can you specify a default value in a YAML file?' + answers: + - { value: 'Use env_default(VAR_NAME)', correct: true } + - { value: 'Add a comment in the YAML file', correct: false } + - { value: "Use the syntax env(VAR_NAME): 'default_value", correct: false } + - { value: "it's impossible", correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html' + - + uuid: 1ef80083-fdc1-6582-9335-8bef89e3c7cf + question: 'Where should you store environment variables that are specific to the local machine?' + answers: + - { value: '.env', correct: false } + - { value: '.env.local', correct: true } + - { value: '.env.test', correct: false } + - { value: 'services.yaml', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html' + - + uuid: 1ef800ab-a2bc-6128-be2b-511459a79806 + question: 'Which command improves performance in production by generating a .env.local.php file for environment variables?' + answers: + - { value: 'composer dump-env prod', correct: true } + - { value: 'php bin/console env:dump', correct: false } + - { value: 'php bin/console cache:clear', correct: false } + - { value: 'php bin/console debug:dotenv', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuring-environment-variables-in-production' + - + uuid: 1ef800b1-26f6-6af6-9606-5f6d32804220 + question: 'How do you define a boolean parameter in Symfony?' + answers: + - { value: "app.enable_feature: 'true'", correct: false } + - { value: 'app.enable_feature: true', correct: true } + - { value: "app.enable_feature: '1'", correct: false } + - { value: 'app.enable_feature: 1', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' + - + uuid: 1ef800b3-83c5-66cc-9f57-0dd23eb3ffa6 + question: 'Which of the following is a correct way to define an array parameter?' + answers: + - { value: "app.supported_locales: 'en, es, fr'", correct: false } + - { value: "app.supported_locales: ['en', 'es', 'fr']", correct: true } + - { value: 'app.supported_locales: en, es, fr', correct: false } + - { value: 'app.supported_locales: {en, es, fr}', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' + - + uuid: 1ef800b7-4d9d-6e06-8aa3-e1c5a7eff6e4 + question: 'How do you define a binary content parameter in Symfony?' + answers: + - { value: "app.binary_data: 'VGhpcyBpcyBhIEJlbGwgY2hhciAH'", correct: false } + - { value: 'app.binary_data: !!binary VGhpcyBpcyBhIEJlbGwgY2hhciAH', correct: false } + - { value: 'app.binary_data: !binary VGhpcyBpcyBhIEJlbGwgY2hhciAH', correct: true } + - { value: 'app.binary_data: binary:VGhpcyBpcyBhIEJlbGwgY2hhciAH', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' + - + uuid: 1ef800ba-c8df-6d82-a0bb-353743b6c517 + question: 'What syntax is used to reference a parameter in configuration files?' + answers: + - { value: '${app.admin_email}', correct: false } + - { value: '&app.admin_email', correct: false } + - { value: '%app.admin_email%', correct: true } + - { value: '@app.admin_email@', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' + - + uuid: 1ef800be-d38d-6744-9d0d-7339978c8ff1 + question: 'Which of the following is true about parameters starting with a dot (.)?' + answers: + - { value: 'They are available at runtime', correct: false } + - { value: 'They are available only during container compilation', correct: true } + - { value: 'They are ignored by Symfony', correct: false } + - { value: 'They are used for database connections', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' + - + uuid: 1ef800c4-0054-6f66-bfd3-779efb0c4390 + question: 'Which symbol indicates that a parameter is a PHP constant in symfony parameters ?' + answers: + - { value: '!php/const', correct: true } + - { value: '&php/const', correct: false } + - { value: '@php/const', correct: false } + - { value: '#php/const', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' + - + uuid: 1ef800c6-fad9-6264-a183-47b81c8e8cc0 + question: 'How can you access configuration parameters in Symfony controllers?' + answers: + - { value: 'By using the ParameterBagInterface', correct: true } + - { value: 'By using the Configurator class', correct: false } + - { value: 'By importing the parameters directly', correct: false } + - { value: 'By using the Service Locator pattern', correct: false } + help: 'https://symfony.com/blog/new-in-symfony-4-1-getting-container-parameters-as-a-service' + - + uuid: 1ef800d7-2fdf-6c5a-9de8-af45c8f65cf4 + question: 'If a parameter value includes the % character, how should it be written to escape it?' + answers: + - { value: '%%', correct: false } + - { value: '%%%', correct: false } + - { value: '%', correct: false } + - { value: '$%', correct: false } + help: 'https://symfony.com/doc/7.0/configuration.html#configuration-parameters' diff --git a/data/dependency_injection/factories.yaml b/data/dependency_injection/factories.yaml index 36a0a74..75cfe15 100644 --- a/data/dependency_injection/factories.yaml +++ b/data/dependency_injection/factories.yaml @@ -1,7 +1,7 @@ questions: - uuid: 1eeccb5b-c6cf-62e4-af74-e35dab4ff615 - question: 'What is the aim of the Design Pattern Factory ?' + question: 'What is the aim of the Design Pattern "Factory" ?' answers: - { value: 'The principle is to have a class which will be responsible for creating the objects we need', correct: true } - { value: 'The principle is to have a class which will be responsible for factoring code into an object', correct: false } diff --git a/data/dependency_injection/service_container.yaml b/data/dependency_injection/service_container.yaml index 74386ed..5a62105 100644 --- a/data/dependency_injection/service_container.yaml +++ b/data/dependency_injection/service_container.yaml @@ -18,7 +18,7 @@ questions: help: 'https://symfony.com/doc/current/components/dependency_injection/compilation.html#controlling-the-pass-ordering' - uuid: 1eebf878-8b98-6344-9f43-99d84c92580c - question: "Let's assume, we have a private service my_private_service. Will this work ?$container->get('my_private_service');" + question: "Let's assume, we have a private service my_private_service. Will this work ? $container->get('my_private_service');" answers: - { value: 'Yes', correct: false } - { value: 'No', correct: true } @@ -129,7 +129,7 @@ questions: help: 'https://symfony.com/doc/current/service_container/injection_types.html' - uuid: 1eebf878-8b9a-6c0c-89ff-99d84c92580c - question: 'What is a Service Configurator in Symfony?' + question: 'What is a "Service Configurator" in Symfony?' answers: - { value: "It's a Symfony built-in service that can be obtained as $container->get('configurator')", correct: false } - { value: "There's no such a thing in Symfony's Dependency Injection component.", correct: false } @@ -328,7 +328,7 @@ questions: help: 'https://symfony.com/doc/current/service_container.html' - uuid: 1ef5c0ac-c210-6358-aea3-8f65d65ecf88 - question: 'How can you make a service available only in the dev environment?' + question: 'How can you make a service available only in the "dev" environment?' answers: - { value: 'By using the autowire: false option.', correct: false } - { value: "By adding the #[When(env: 'dev')] attribute to the service class.", correct: true } @@ -368,7 +368,7 @@ questions: answers: - { value: 'It defers the instantiation of the service until it is actually needed.', correct: true } - { value: 'It prevents the service from being injected into other services.', correct: false } - - { value: 'It makes the service available only in the prod environment.', correct: false } + - { value: 'It makes the service available only in the "prod" environment.', correct: false } help: 'https://symfony.com/doc/current/service_container/lazy_services.html' - uuid: 1ef5c0c1-1ac7-64a6-9cbf-45ad2711c61f diff --git a/data/dependency_injection/services_registration.yaml b/data/dependency_injection/services_registration.yaml index 8ca7441..483227f 100644 --- a/data/dependency_injection/services_registration.yaml +++ b/data/dependency_injection/services_registration.yaml @@ -12,17 +12,17 @@ questions: uuid: 1eebf878-8b9f-663a-9d4f-99d84c92580c question: 'What is the correct syntax to inject a service app.mailer ?' answers: - - { value: 'arguments: [ @app.mailer ]', correct: true } - - { value: 'arguments: [ %app.mailer% ]', correct: false } - - { value: 'arguments: [ app.mailer ]', correct: false } + - { value: 'arguments: ["@app.mailer"]', correct: true } + - { value: 'arguments: ["%app.mailer%"]', correct: false } + - { value: 'arguments: ["app.mailer"]', correct: false } help: 'https://symfony.com/doc/current/service_container.html#service-parameters' - uuid: 1eebf878-8b9f-6680-a3eb-99d84c92580c question: 'What is the correct syntax to inject a parameter mailer.transport ?' answers: - - { value: 'arguments: [ @mailer.transport ]', correct: false } - - { value: 'arguments: [ %mailer.transport% ]', correct: true } - - { value: 'arguments: [ mailer.transport ]', correct: false } + - { value: 'arguments: ["@mailer.transport"]', correct: false } + - { value: 'arguments: ["%mailer.transport%"]', correct: true } + - { value: 'arguments: ["mailer.transport"]', correct: false } help: 'https://symfony.com/doc/current/configuration.html#configuration-parameters' - uuid: 1eebf878-8b9f-66c6-922d-99d84c92580c diff --git a/data/forms/built_in_form_types.yaml b/data/forms/built_in_form_types.yaml index ceb6b09..b99356c 100644 --- a/data/forms/built_in_form_types.yaml +++ b/data/forms/built_in_form_types.yaml @@ -48,7 +48,7 @@ questions: help: 'https://symfony.com/doc/current/reference/forms/types.html' - uuid: 1eebf878-8ba2-6f74-bd21-99d84c92580c - question: 'Which option should you use to have a DateType form rendered in HTML5 input type= date ?' + question: 'Which option should you use to have a DateType form rendered in HTML5 input type="date"?' answers: - { value: datepicker, correct: false } - { value: html5, correct: true } @@ -68,7 +68,7 @@ questions: uuid: 1eec045b-a03a-6704-a20d-5305a622e54a question: 'What are the valid way to Assert Choices in a Validator ?' answers: - - { value: "#[Assert\\Choice( choices: ['fiction', 'non-fiction'])] private string $genre;", correct: true } - - { value: "#[Assert\\Choices(['fiction', 'non-fiction'])] private string $genre;", correct: false } - - { value: "#[Assert\\Choice(['fiction', 'non-fiction'])] private string $genre;", correct: true } + - { value: "#[Assert\\Choice( choices: ['fiction', 'non-fiction'])]\r\n\r\nprivate string $genre;", correct: true } + - { value: "#[Assert\\Choices(['fiction', 'non-fiction'])]\r\n\r\nprivate string $genre;", correct: false } + - { value: "#[Assert\\Choice(['fiction', 'non-fiction'])]\r\n\r\nprivate string $genre;", correct: true } help: 'https://symfony.com/doc/current/validation.html#constraint-configuration' diff --git a/data/forms/csrf_protection.yaml b/data/forms/csrf_protection.yaml index 03ea62d..77a2120 100644 --- a/data/forms/csrf_protection.yaml +++ b/data/forms/csrf_protection.yaml @@ -28,10 +28,10 @@ questions: uuid: 1eebf878-8b9f-6a0e-aed4-99d84c92580c question: 'Using Form component, which option can you use into configureOptions() method to enable CSRF protection?' answers: - - { value: ' csrf_protection => true', correct: true } - - { value: ' csrf_field => true', correct: false } - - { value: ' csrf => enabled ', correct: false } - - { value: ' csrf => true', correct: false } + - { value: '"csrf_protection" => true', correct: true } + - { value: '"csrf_field" => true', correct: false } + - { value: '"csrf" => "enabled"', correct: false } + - { value: '"csrf" => true', correct: false } help: 'https://symfony.com/doc/current/security/csrf.html#csrf-protection-in-symfony-forms' - uuid: 1eebf878-8b9f-6a54-a024-99d84c92580c @@ -51,8 +51,8 @@ questions: uuid: 1eebf878-8ba5-680a-a545-99d84c92580c question: 'how to override the field name of the the csrf token in a form ?' answers: - - { value: 'by renaming the name value in the html input, before using crsf_token() in twig to generate it', correct: true } - - { value: "by adding a CsrfTokenType and setting a name value in it's option", correct: false } + - { value: 'by renaming the "name" value in the html input, before using crsf_token() in twig to generate it', correct: true } + - { value: 'by adding a CsrfTokenType and setting a "name" value in it''s option', correct: false } - { value: "by overriding the 'csrf_field_name' in the function $resolver->setDefault in configureOptions of the targeted form.", correct: true } - { value: 'by setting it in the config.yaml file framework.csrf_token.default_field', correct: false } help: 'https://symfony.com/doc/current/security/csrf.html' diff --git a/data/forms/form_types.yaml b/data/forms/form_types.yaml index 6f1f52d..4471bab 100644 --- a/data/forms/form_types.yaml +++ b/data/forms/form_types.yaml @@ -1,7 +1,7 @@ questions: - uuid: 1eebf878-8b97-62be-936c-99d84c92580c - question: 'When the checkbox field foo is checked and the form is submitted, what will $form[ foo ]->getData() return?' + question: 'When the checkbox field "foo" is checked and the form is submitted, what will $form["foo"]->getData() return?' answers: - { value: 'true', correct: true } - { value: bar, correct: false } @@ -43,7 +43,7 @@ questions: question: 'What is the main difference between the Symfony\Component\Form\Extension\Core\Type\BirthdayType form type and its parent Symfony\Component\Form\Extension\Core\Type\DateType ?' answers: - { value: 'Those form types does not inherit from each other.', correct: false } - - { value: 'It adds a little bithday cake icon right before the widget.', correct: false } + - { value: 'It adds a little "bithday cake" icon right before the widget.', correct: false } - { value: 'It defaults the years option to 120 years ago to the current year.', correct: true } - { value: 'This is only semantical, there is no real difference between them.', correct: false } help: 'https://symfony.com/doc/current/reference/forms/types/birthday.html' @@ -92,7 +92,7 @@ questions: help: 'https://symfony.com/doc/current/reference/forms/types/money.html' - uuid: 1eebf878-8b99-6c30-8ce8-99d84c92580c - question: 'Which option should you use to render a DateType form type as an HTML5 ?' + question: 'Which option should you use to render a DateType form type as an HTML5 ?' answers: - { value: no_javascript, correct: false } - { value: type_date, correct: false } @@ -189,10 +189,10 @@ questions: uuid: 1eebf878-8b9f-6874-968c-99d84c92580c question: 'Inside a form type, how to render a DateType field in an text input field?' answers: - - { value: 'Add an option render => input ', correct: false } - - { value: 'Add an option widget => text ', correct: false } - - { value: 'Add an option widget => single_text ', correct: true } - - { value: 'Add an option widget => input ', correct: false } + - { value: 'Add an option "render" => "input"', correct: false } + - { value: 'Add an option "widget" => "text"', correct: false } + - { value: 'Add an option "widget" => "single_text"', correct: true } + - { value: 'Add an option "widget" => "input"', correct: false } help: 'https://symfony.com/doc/current/reference/forms/types/date.html#widget' - uuid: 1eebf878-8b9f-6ff4-9937-99d84c92580c diff --git a/data/forms/forms_creation.yaml b/data/forms/forms_creation.yaml index 589c01f..867684a 100644 --- a/data/forms/forms_creation.yaml +++ b/data/forms/forms_creation.yaml @@ -55,7 +55,7 @@ questions: help: 'https://symfony.com/doc/current/reference/dic_tags.html#form-type' - uuid: 1eebf878-8ba9-6a4a-8062-99d84c92580c - question: 'Consider the following HTML generated from a Symfony form:
Which HTTP method will be present in the Symfony Request object assuming HTTP methods overriding setting is turned on?' + question: 'Consider the following HTML generated from a Symfony form:
Which HTTP method will be present in the Symfony Request object assuming HTTP methods overriding setting is turned on?' answers: - { value: PATCH, correct: false } - { value: PUT, correct: true } diff --git a/data/forms/forms_handling.yaml b/data/forms/forms_handling.yaml index c7abf44..0f12754 100644 --- a/data/forms/forms_handling.yaml +++ b/data/forms/forms_handling.yaml @@ -43,7 +43,7 @@ questions: help: 'https://symfony.com/doc/current/forms.html#processing-forms' - uuid: 1eebf878-8b9f-6d6a-8927-99d84c92580c - question: 'Using form component, option error_bubbling will include error in current field.' + question: 'Using form component, option "error_bubbling" will include error in current field.' answers: - { value: 'True', correct: false } - { value: 'False', correct: true } diff --git a/data/http/client_server_interaction.yaml b/data/http/client_server_interaction.yaml index 1854b81..f9a7c99 100644 --- a/data/http/client_server_interaction.yaml +++ b/data/http/client_server_interaction.yaml @@ -3,9 +3,9 @@ questions: uuid: 1eebf878-8b98-64b6-97b1-99d84c92580c question: 'What is the format of the Media-Type value inside Content-Type and Accept headers?' answers: - - { value: 'type / subtype *( OWS ; OWS parameter )', correct: true } - - { value: 'type ** subtype *( OWS ; OWS parameter )', correct: false } - - { value: 'type + subtype *( OWS ; OWS parameter )', correct: false } + - { value: 'type "/" subtype *( OWS ";" OWS parameter )', correct: true } + - { value: 'type ** subtype *( OWS ";" OWS parameter )', correct: false } + - { value: 'type + subtype *( OWS ";" OWS parameter )', correct: false } help: 'https://tools.ietf.org/html/rfc7231#section-3.1.1.1' - uuid: 1eebf878-8b98-6812-9467-99d84c92580c diff --git a/data/http/http_methods.yaml b/data/http/http_methods.yaml index 99f3d55..7e14675 100644 --- a/data/http/http_methods.yaml +++ b/data/http/http_methods.yaml @@ -65,7 +65,7 @@ questions: - { value: "A GET request's response is cachable", correct: true } - { value: 'A GET request is safe', correct: true } - { value: 'A GET request requires a body', correct: false } - - { value: 'A GET request needs an User-Agent header', correct: false } + - { value: 'A GET request needs an "User-Agent" header', correct: false } - { value: 'This method is defined by RFC5789', correct: false } help: 'https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Summary_table' - @@ -80,5 +80,5 @@ questions: - { value: 'The server must support it', correct: true } - { value: 'A HEAD request contains a body', correct: false } - { value: "A HEAD request's response contains a body", correct: false } - - { value: 'A HEAD request needs an Http-Version header', correct: false } + - { value: 'A HEAD request needs an "Http-Version" header', correct: false } help: 'https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Summary_table' diff --git a/data/http/language_detection.yaml b/data/http/language_detection.yaml index f65a73f..c039a16 100644 --- a/data/http/language_detection.yaml +++ b/data/http/language_detection.yaml @@ -9,7 +9,7 @@ questions: help: 'https://www.w3.org/International/questions/qa-accept-lang-locales' - uuid: 1eeda399-81f7-63da-882e-c7a97213cca5 - question: 'Quelle est la valeur q de da dans Accept-Language: da, en-gb;q=0.8, en;q=0.7 ?' + question: 'Quelle est la valeur q de "da" dans Accept-Language: da, en-gb;q=0.8, en;q=0.7 ?' answers: - { value: '1', correct: true } - { value: '0.8', correct: false } @@ -18,7 +18,7 @@ questions: help: 'https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4' - uuid: 1eeda3b0-75d6-6efe-8f89-f105bb5b9b6c - question: 'Which Accept-Language value is wrong ?' + question: 'Which "Accept-Language" value is wrong ?' answers: - { value: 'Accept-Language: *', correct: true } - { value: 'Accept-Language: es;q=0', correct: false } diff --git a/data/http_caching/expiration_expires_cache_control.yaml b/data/http_caching/expiration_expires_cache_control.yaml index 6967a78..27b4ba7 100644 --- a/data/http_caching/expiration_expires_cache_control.yaml +++ b/data/http_caching/expiration_expires_cache_control.yaml @@ -1,7 +1,7 @@ questions: - uuid: 1eebf878-8b99-65a0-956f-99d84c92580c - question: 'Given the following header, will the resource be considered as fresh? Expires: 0 ' + question: 'Given the following header, will the resource be considered as fresh? "Expires: 0"' answers: - { value: 'Yes', correct: false } - { value: 'No', correct: true } diff --git a/data/miscellaneous/cache_process_and_serializer_components.yaml b/data/miscellaneous/cache_process_and_serializer_components.yaml index 6440c7f..b01b21f 100644 --- a/data/miscellaneous/cache_process_and_serializer_components.yaml +++ b/data/miscellaneous/cache_process_and_serializer_components.yaml @@ -190,7 +190,7 @@ questions: help: 'https://symfony.com/doc/current/components/process.html#streaming-to-the-standard-input-of-a-process' - uuid: 1eebf878-8ba9-68ce-9102-99d84c92580c - question: "Given $process is a Process object that runs a command asynchronously; calling\_ $process->stop(3) will immediately send a SIGKILL signal to the running command." + question: 'Given $process is a Process object that runs a command asynchronously; calling $process->stop(3) will immediately send a SIGKILL signal to the running command.' answers: - { value: 'False', correct: true } - { value: 'True', correct: false } diff --git a/data/miscellaneous/deployment_best_practices.yaml b/data/miscellaneous/deployment_best_practices.yaml index 8b287f7..45741a2 100644 --- a/data/miscellaneous/deployment_best_practices.yaml +++ b/data/miscellaneous/deployment_best_practices.yaml @@ -29,7 +29,7 @@ questions: help: 'https://symfony.com/doc/current/performance.html#configure-opcache-for-maximum-performance' - uuid: 1eebf878-8ba8-6c9e-a896-99d84c92580c - question: 'In production servers, PHP files should never change, unless a new application version is deployed. However, by default OPcache checks if cached files have changed their contents since they were cached. How it is done to uncheck some overhead that can be avoided ?' + question: "In production servers, PHP files should never change, unless a new application version is deployed. However, by default OPcache checks if cached files have changed their contents since they were cached. How it is done to uncheck some overhead that can be avoided ?" answers: - { value: 'In php.ini: opcache.validate_timestamps=0', correct: true } - { value: 'In php.ini: opcache.invalidate_timestamps=1', correct: false } diff --git a/data/miscellaneous/filesystem_and_finder_components.yaml b/data/miscellaneous/filesystem_and_finder_components.yaml index 0443972..cd14bec 100644 --- a/data/miscellaneous/filesystem_and_finder_components.yaml +++ b/data/miscellaneous/filesystem_and_finder_components.yaml @@ -42,7 +42,7 @@ questions: help: 'https://symfony.com/doc/current/components/filesystem.html#dumpfile' - uuid: 1eebf878-8b9a-67de-9c30-99d84c92580c - question: "Is the following code valid? $fs = (new Filesystem())->mirror('/srv/app', '/srv/bar', null, ['delete' => true]);" + question: "Is the following code valid? $fs = (new Filesystem())->mirror('/srv/app', '/srv/bar', null, ['delete' => true]);" answers: - { value: 'Yes', correct: true } - { value: 'No', correct: false } diff --git a/data/miscellaneous/web_profiler_web_debug_toolbar_and_data_collectors.yaml b/data/miscellaneous/web_profiler_web_debug_toolbar_and_data_collectors.yaml index b48a9c9..f894a9b 100644 --- a/data/miscellaneous/web_profiler_web_debug_toolbar_and_data_collectors.yaml +++ b/data/miscellaneous/web_profiler_web_debug_toolbar_and_data_collectors.yaml @@ -32,7 +32,7 @@ questions: answers: - { value: 'Yes with a profiler link given in the response header', correct: true } - { value: 'No profiler is only available for html response', correct: false } - - { value: 'Yes the json response give a key _profiler with the debug informations', correct: false } + - { value: 'Yes the json response give a key "_profiler" with the debug informations', correct: false } help: 'https://symfony.com/doc/current/profiler.html#installation' - uuid: 1eee69ac-3275-6b5c-9026-4566c29ff6d6 diff --git a/data/php_and_web_security/abstract_classes.yaml b/data/php_and_web_security/abstract_classes.yaml index 82f5d02..b071984 100644 --- a/data/php_and_web_security/abstract_classes.yaml +++ b/data/php_and_web_security/abstract_classes.yaml @@ -24,7 +24,7 @@ questions: help: 'https://www.php.net/manual/en/language.oop5.abstract.php' - uuid: 1eee6cd6-f85e-6ac6-9026-d7a38b0e1aa0 - question: 'When you extends an abstract class which define a function. Does the child class can add optionnal aruguments in the same function definition ? prefixName($name, $separator = . ) instead of prefixName($name)' + question: 'When you extends an abstract class which define a function. Does the child class can add optionnal aruguments in the same function definition ? prefixName($name, $separator = ".") instead of prefixName($name)' answers: - { value: 'Yes', correct: true } - { value: 'No', correct: false } diff --git a/data/php_and_web_security/php_extensions.yaml b/data/php_and_web_security/php_extensions.yaml index b711d9c..83d13f9 100644 --- a/data/php_and_web_security/php_extensions.yaml +++ b/data/php_and_web_security/php_extensions.yaml @@ -11,7 +11,7 @@ questions: help: 'https://www.php.net/manual/en/function.header.php' - uuid: 1eebf878-8ba5-624c-866b-99d84c92580c - question: "What is the output ? $a = '0' ; echo strlen($a); echo empty($a) ? $a : 5; echo $a ?: 5;" + question: "What is the output ? $a = '0'; echo strlen($a); echo empty($a) ? $a : 5; echo $a ?: 5;" answers: - { value: '100', correct: false } - { value: '005', correct: false } @@ -19,25 +19,15 @@ questions: - { value: '050', correct: false } - { value: '105', correct: true } help: 'https://php.net/operators' - - - uuid: 1eebf878-8ba7-63c6-8206-99d84c92580c - question: "What values in $user or $pass will modify the SQL semantics and lead to SQL injection in the code below ?$query = UPDATE users SET password='$pass' WHERE user='$user' ;" - answers: - - { value: '$pass = \ foobar\ WHERE ;$user = \ admin\ ;', correct: false } - - { value: "$user = foobar\\' WHERE user='admin' ;", correct: false } - - { value: "$pass = foobar' WHERE user='admin' -- ;", correct: true } - - { value: "$user = foobar\\' WHERE user='admin' ;", correct: false } - - { value: None, correct: false } - help: 'https://php.net/manual/fr/security.database.sql-injection.php' - uuid: 1eebf878-8ba7-65f6-a5b1-99d84c92580c question: 'Which syntax is not a valid callable syntax ?' answers: - - { value: ' foo ', correct: false } - - { value: ' foo->bar ', correct: true } + - { value: 'foo', correct: false } + - { value: 'foo->bar', correct: true } - { value: "['foo', 'bar']", correct: false } - { value: 'function () { }', correct: false } - - { value: ' Foo::bar ', correct: false } + - { value: 'Foo::bar', correct: false } help: 'https://php.net/manual/en/language.types.callable.php' - uuid: 1eebf878-8ba9-6d4c-a1b5-99d84c92580c @@ -76,14 +66,14 @@ questions: help: 'https://www.php.net/manual/en/array.sorting.php' - uuid: 1eed57a4-1813-65a4-976d-0565a2850c77 - question: 'Could existing variables be overwritten when using extract ?' + question: 'Could existing variables be overwritten when using "extract"?' answers: - { value: 'Yes', correct: true } - { value: 'No', correct: false } help: 'https://www.php.net/manual/en/function.extract.php' - uuid: 1eed57bd-b35c-6862-8439-f15d4b8654c5 - question: 'Is it allowed to make an interface use traits?' + question: 'Is it allowed to make an interface use traits ?' answers: - { value: 'Yes', correct: false } - { value: 'No', correct: true } diff --git a/data/php_and_web_security/phpapi_up_to_php81_version.yaml b/data/php_and_web_security/phpapi_up_to_php81_version.yaml index a198f5d..c83316a 100644 --- a/data/php_and_web_security/phpapi_up_to_php81_version.yaml +++ b/data/php_and_web_security/phpapi_up_to_php81_version.yaml @@ -30,7 +30,7 @@ questions: help: 'https://www.php.net/manual/en/language.oop5.basic.php' - uuid: 1eebf878-8b99-655a-9f19-99d84c92580c - question: "In the following code snippet, what condition should you use to ensure the Location header hasn't already been sent? function redirect($url) { $header = sprintf('Location: %s', $url); if ( ??? ) { header($header); exit; } }" + question: "In the following code snippet, what condition should you use to ensure the Location header hasn't already been sent?\nfunction redirect($url) { $header = sprintf('Location: %s', $url); if ( ??? ) { header($header); exit; } }" answers: - { value: '!in_array($header, headers_list())', correct: true } - { value: "!header_exists('Location', $url)", correct: false } @@ -40,7 +40,7 @@ questions: help: 'https://php.net/manual/en/ref.network.php' - uuid: 1eebf878-8b9a-6054-a6cb-99d84c92580c - question: '$a = (object) [ a => b ]; $b = (object) [ a => c ]; echo $a <=> $b;' + question: '$a = (object) ["a" => "b"]; $b = (object) ["a" => "c"]; echo $a <=> $b;' answers: - { value: '0', correct: false } - { value: '1', correct: false } @@ -89,16 +89,16 @@ questions: help: 'https://www.php.net/manual/en/function.extract.php' - uuid: 1eebf878-8b9c-6656-8085-99d84c92580c - question: 'Which function would best parse the following string by the tab (\t) and newline (\n) characters ? $string = John\tMark\nTed\tLarry ;' + question: 'Which function would best parse the following string by the tab (\t) and newline (\n) characters ? $string = "John\tMark\nTed\tLarry";' answers: - - { value: 'explode($string, \t\n );', correct: false } + - { value: 'explode($string, "\t\n");', correct: false } - { value: strtok($string);, correct: true } - { value: str_split($string);, correct: false } - { value: strstr($string);, correct: false } help: 'https://www.php.net/manual/en/function.strtok.php' - uuid: 1eebf878-8b9c-6a02-9efa-99d84c92580c - question: "By default, which of the following request parameters can be used with built-in providers for a login form?" + question: 'By default, which of the following request parameters can be used with built-in providers for a login form?' answers: - { value: _remember_me, correct: false } - { value: _token, correct: true } @@ -264,7 +264,7 @@ questions: help: 'https://php.net/manual/en/function.error-log.php' - uuid: 1eebf878-8ba3-673a-a520-99d84c92580c - question: "Given the following code, what will be displayed?$a = (object) ['a' => 'a'];\_$b = (object) ['a' => 'a'];\_echo $b <=> $a;" + question: "Given the following code, what will be displayed?$a = (object) ['a' => 'a']; $b = (object) ['a' => 'a']; echo $b <=> $a;" answers: - { value: '0', correct: true } - { value: '1', correct: false } @@ -272,7 +272,7 @@ questions: help: 'https://www.php.net/manual/en/language.operators.comparison.php' - uuid: 1eebf878-8ba3-6dc0-bb50-99d84c92580c - question: "What is the most recommended way to count the number of occurences of each unique value in the following array? $a=[1,1,2,3,4,4,5,6,6,6,3,2,2,2];" + question: 'What is the most recommended way to count the number of occurences of each unique value in the following array? $a=[1,1,2,3,4,4,5,6,6,6,3,2,2,2];' answers: - { value: '$ = array_unique($a);$k = array_fill(0,count($k), 0);$n = array_combine($k, $v);reset($a);for($i =0; $i < count($a); $i++){++$n[current($a)];', correct: false } - { value: '$n = array_count_values($a);', correct: true } diff --git a/data/routing/conditional_request_matching.yaml b/data/routing/conditional_request_matching.yaml index a64bc42..15ea47f 100644 --- a/data/routing/conditional_request_matching.yaml +++ b/data/routing/conditional_request_matching.yaml @@ -12,7 +12,7 @@ questions: help: 'https://symfony.com/doc/current/routing.html#matching-expressions' - uuid: 1eebf878-8ba8-6438-9c57-99d84c92580c - question: "What are the accessible variables you can call to restrict a route ?" + question: 'What are the accessible variables you can call to restrict a route ?' answers: - { value: context, correct: true } - { value: request, correct: true } diff --git a/data/routing/domain_name_matching.yaml b/data/routing/domain_name_matching.yaml index 4a91dee..0c2ce7f 100644 --- a/data/routing/domain_name_matching.yaml +++ b/data/routing/domain_name_matching.yaml @@ -10,10 +10,10 @@ questions: uuid: 1eebf878-8ba0-6f80-ba98-99d84c92580c question: 'Using XML or YAML, how to declare a route for a specific domain/host?' answers: - - { value: 'Add a domain attribute', correct: false } - - { value: 'Add a host attribute', correct: true } - - { value: 'Add a path attribute', correct: false } - - { value: 'Add a subdomain attribute', correct: false } + - { value: 'Add a "domain" attribute', correct: false } + - { value: 'Add a "host" attribute', correct: true } + - { value: 'Add a "path" attribute', correct: false } + - { value: 'Add a "subdomain" attribute', correct: false } help: 'https://symfony.com/doc/current/routing.html#sub-domain-routing' - uuid: 1eebf878-8ba8-6244-a390-99d84c92580c diff --git a/data/routing/http_methods_matching.yaml b/data/routing/http_methods_matching.yaml index 7d9950e..aec0be7 100644 --- a/data/routing/http_methods_matching.yaml +++ b/data/routing/http_methods_matching.yaml @@ -12,10 +12,10 @@ questions: uuid: 1eebf878-8ba1-6016-beaf-99d84c92580c question: 'Using XML, how to ensure that a route is accessed via HTTPS?' answers: - - { value: 'schemes= https ', correct: true } - - { value: 'https= true ', correct: false } - - { value: 'protocol= https ', correct: false } - - { value: 'ensure= https ', correct: false } + - { value: 'schemes="https"', correct: true } + - { value: 'https="true"', correct: false } + - { value: 'protocol="https"', correct: false } + - { value: 'ensure="https"', correct: false } help: 'https://symfony.com/doc/current/routing.html#forcing-https-on-generated-urls' - uuid: 1eebf878-8ba1-6214-83d0-99d84c92580c @@ -30,8 +30,8 @@ questions: uuid: 1eebf878-8ba8-630c-87f9-99d84c92580c question: 'How to force to send a method PUT in a form ?' answers: - - {value: 'by adding: ', correct: true} - - { value: 'with
', correct: false } + - { value: 'by adding: ', correct: true } + - { value: 'with
', correct: false } - { value: "framework.http_method_override option is true and $form = $this->createFormBuilder($task)->setMethod('PUT')", correct: true } - { value: "framework.http_method_override option is true and {{ form_start(form, {'method': 'PUT'}) }}", correct: true } - { value: "framework.http_method_override option is true and $form = $this->createForm(TotoType::class, $toto, ['method' => 'PUT']);", correct: true } diff --git a/data/routing/router_debugging.yaml b/data/routing/router_debugging.yaml index cb64935..9c509a4 100644 --- a/data/routing/router_debugging.yaml +++ b/data/routing/router_debugging.yaml @@ -29,7 +29,7 @@ questions: help: 'https://symfony.com/doc/current/routing.html#debugging-routes' - uuid: 1eebf878-8ba8-63a2-b6e6-99d84c92580c - question: "Does the option --show-aliases on the debug:router show you available aliases for a given route ?" + question: 'Does the option --show-aliases on the debug:router show you available aliases for a given route ?' answers: - { value: 'Yes', correct: true } - { value: 'No', correct: false } diff --git a/data/security/access_control_rules.yaml b/data/security/access_control_rules.yaml index 2b57f23..fd12b1d 100644 --- a/data/security/access_control_rules.yaml +++ b/data/security/access_control_rules.yaml @@ -43,7 +43,7 @@ questions: help: 'https://symfony.com/doc/current/security/access_control.html#2-access-enforcement' - uuid: 1eeda4c7-518c-6fa4-80fb-09b72beaa117 - question: "If i have this access_control configured (roles: 'ROLE_ADMIN' and allow_if: '127.0.0.1' == request.getClientIp() or request.headers.has('X-Secure-Access'). In Which configuration can i go on this page ?" + question: "If i have this access_control configured (roles: 'ROLE_ADMIN' and allow_if: \"'127.0.0.1' == request.getClientIp() or request.headers.has('X-Secure-Access'). In Which configuration can i go on this page ?" answers: - { value: 'if i have ROLE_ADMIN', correct: false } - { value: 'If i have a header caledd X-Secure-Access', correct: false } diff --git a/data/security/authentication.yaml b/data/security/authentication.yaml index 6e9259e..9a69e88 100644 --- a/data/security/authentication.yaml +++ b/data/security/authentication.yaml @@ -109,8 +109,8 @@ questions: question: 'How could you know if a User can switch to another account ?' answers: - { value: $this->getUser()->canSwitchUser(), correct: false } - - { value: '$this->getUser()->hasRole( ROLE_ALLOWED_TO_SWITCH )', correct: false } - - { value: '$this->isGranted( ROLE_ALLOWED_TO_SWITCH )', correct: true } + - { value: '$this->getUser()->hasRole("ROLE_ALLOWED_TO_SWITCH")', correct: false } + - { value: '$this->isGranted("ROLE_ALLOWED_TO_SWITCH")', correct: true } - { value: "twig: is_granted('IS_IMPERSONATOR')", correct: true } help: 'https://symfony.com/doc/current/security/impersonating_user.html#knowing-when-impersonation-is-active' - diff --git a/data/security/authorization.yaml b/data/security/authorization.yaml index 74b1bc9..94c6b2e 100644 --- a/data/security/authorization.yaml +++ b/data/security/authorization.yaml @@ -35,7 +35,7 @@ questions: help: 'https://symfony.com/doc/current/security.html#securing-other-services' - uuid: 1eedb101-2d08-6c3c-bfe5-f9db4bc17b6f - question: 'What is the default lifetime value for the Remember me Cookie ?' + question: 'What is the default lifetime value for the "Remember me" Cookie ?' answers: - { value: '1 year', correct: true } - { value: '1 week', correct: false } diff --git a/data/security/firewalls.yaml b/data/security/firewalls.yaml index af79533..7c33ced 100644 --- a/data/security/firewalls.yaml +++ b/data/security/firewalls.yaml @@ -32,7 +32,7 @@ questions: question: 'How can you deny access to user in your controller ?' answers: - { value: "$this->denyAccessUnlessGranted('ROLE_ADMIN')", correct: true } - - { value: '@Security( is_granted( ROLE_ADMIN ) )', correct: true } + - { value: '@Security("is_granted("ROLE_ADMIN")")', correct: true } - { value: "$this->user->denyAccessUnlessGranted('ROLE_ADMIN')", correct: false } help: 'https://symfony.com/doc/current/security.html' - diff --git a/data/security/roles.yaml b/data/security/roles.yaml index 4b2fe9c..367af90 100644 --- a/data/security/roles.yaml +++ b/data/security/roles.yaml @@ -20,10 +20,10 @@ questions: uuid: 1eebf878-8ba1-6458-b8ae-99d84c92580c question: 'Which annotation is valid to check role ?' answers: - - { value: '@Security( is_granted( ROLE_ADMIN ) )', correct: true } - - { value: '@IsGranted( ROLE_ADMIN )', correct: true } - - { value: '@Security( restrict_for( ROLE_ADMIN ) )', correct: false } - - { value: '@Security( role( ROLE_ADMIN ) )', correct: false } + - { value: '@Security("is_granted("ROLE_ADMIN")")', correct: true } + - { value: '@IsGranted("ROLE_ADMIN")', correct: true } + - { value: '@Security("restrict_for("ROLE_ADMIN")")', correct: false } + - { value: '@Security("role("ROLE_ADMIN")")', correct: false } help: 'https://symfony.com/bundles/SensioFrameworkExtraBundle/current/annotations/security.html' - uuid: 1eebf878-8ba1-64a8-a6c8-99d84c92580c diff --git a/data/symfony_architecture/code_organization.yaml b/data/symfony_architecture/code_organization.yaml index aa08267..9622dec 100644 --- a/data/symfony_architecture/code_organization.yaml +++ b/data/symfony_architecture/code_organization.yaml @@ -13,9 +13,9 @@ questions: uuid: 1eebf878-8ba3-6e9c-9225-99d84c92580c question: 'Which of these are correct ways to create a redirection response in a controller that extends Symfony\Bundle\FrameworkBundle\Controller\AbstractController?' answers: - - { value: '$response = $this->redirect($this->generate( homepage ))', correct: true } - - { value: '$response = $this->redirect( https://myapp.com/ )', correct: true } - - { value: '$response = new RedirectionResponse( / )', correct: false } - - { value: '$response = new RedirectResponse( https://myapp.com/ )', correct: false } - - { value: '$response = $this->redirectToRoute( homepage )', correct: true } + - { value: '$response = $this->redirect($this->generate("homepage"))', correct: true } + - { value: '$response = $this->redirect("https://myapp.com/")', correct: true } + - { value: '$response = new RedirectionResponse("/")', correct: false } + - { value: '$response = new RedirectResponse("https://myapp.com/")', correct: false } + - { value: '$response = $this->redirectToRoute("homepage")', correct: true } help: 'https://symfony.com/doc/current/controller.html#redirecting' diff --git a/data/symfony_architecture/components.yaml b/data/symfony_architecture/components.yaml index 4f52c44..90cf549 100644 --- a/data/symfony_architecture/components.yaml +++ b/data/symfony_architecture/components.yaml @@ -55,7 +55,7 @@ questions: help: 'https://github.com/symfony/dependency-injection/blob/3.4/Loader/Configurator/ContainerConfigurator.php#L125' - uuid: 1eebf878-8ba6-6908-890e-99d84c92580c - question: 'Is the following code valid? $parsed = Yaml::parse( !custom_tag { foo: bar } , Yaml::PARSE_CUSTOM_TAGS);' + question: 'Is the following code valid? $parsed = Yaml::parse("!custom_tag { foo: bar }", Yaml::PARSE_CUSTOM_TAGS);' answers: - { value: 'Yes', correct: true } - { value: 'No', correct: false } @@ -91,7 +91,7 @@ questions: help: 'https://symfony.com/doc/current/components/serializer.html#installation' - uuid: 1eebf878-8ba7-6b64-abc4-99d84c92580c - question: 'Sometimes you may prefer to not save the objects immediately in order to increase the application performance. Which method would you call to mark cache items as ready to be persisted and then call to commit() method when you are ready to persist them all?' + question: 'Sometimes you may prefer to not save the objects immediately in order to increase the application performance. Which method would you call to mark cache items as ready to be persisted and then call to commit() method when you are ready to persist them all?' answers: - { value: save(), correct: false } - { value: defer(), correct: false } diff --git a/data/symfony_architecture/naming_conventions.yaml b/data/symfony_architecture/naming_conventions.yaml index 3e6e1aa..c6596f8 100644 --- a/data/symfony_architecture/naming_conventions.yaml +++ b/data/symfony_architecture/naming_conventions.yaml @@ -1,7 +1,7 @@ questions: - uuid: 1eebf878-8ba8-664a-9334-99d84c92580c - question: 'Is suffix Trait mandatory for traits ?' + question: 'Is suffix "Trait" mandatory for traits ?' answers: - { value: 'Yes', correct: true } - { value: 'No', correct: false } @@ -78,7 +78,7 @@ questions: help: 'https://symfony.com/doc/current/contributing/code/standards.html#naming-conventions' - uuid: 1eeda2d4-2696-6a56-a432-913a625d7cea - question: "Isn't suffix Exception mandatory for exceptions ?" + question: 'Isn"t suffix "Exception" mandatory for exceptions ?' answers: - { value: 'No', correct: true } - { value: 'Yes', correct: false } diff --git a/data/symfony_architecture/official_best_practices.yaml b/data/symfony_architecture/official_best_practices.yaml index c780758..68b45dc 100644 --- a/data/symfony_architecture/official_best_practices.yaml +++ b/data/symfony_architecture/official_best_practices.yaml @@ -106,11 +106,11 @@ questions: uuid: 1eee7676-c5ec-6a8a-9026-1776563d9f7e question: 'According to the official Symfony Best Practices Guide, where do you need to store the translation files?' answers: - - {value: 'in the Resources/translations/ directory of each bundle', correct: false} - - { value: 'in the app/Resources/translations/ directory', correct: false } - - { value: 'in the app/Resources/translations/ directory', correct: false } - - { value: 'in the Resources/translations/ directory of each bundle', correct: false } - - { value: 'in the translations/ directory', correct: true } + - { value: 'in the "Resources/translations/language" directory of each bundle', correct: false } + - { value: 'in the "app/Resources/translations/" directory', correct: false } + - { value: 'in the "app/Resources/translations/" directory', correct: false } + - { value: 'in the "Resources/translations/" directory of each bundle', correct: false } + - { value: 'in the "translations/" directory', correct: true } help: 'https://symfony.com/doc/current/best_practices.html#use-the-default-directory-structure' - uuid: 1eee768b-076d-6ab8-9026-f7fba49cfdf8 diff --git a/data/symfony_architecture/symfony_flex.yaml b/data/symfony_architecture/symfony_flex.yaml index 4df9160..9d1abd8 100644 --- a/data/symfony_architecture/symfony_flex.yaml +++ b/data/symfony_architecture/symfony_flex.yaml @@ -152,14 +152,14 @@ questions: help: 'https://symfony.com/doc/current/setup/flex.html#customizing-flex-paths' - uuid: 1ef562a5-90da-6c8a-8a47-9f1995dbf2d9 - question: 'Some structure folders in symfony can be moved by specifying in the composer.json an extra section and adding src-dir for the src for example.' + question: 'Some structure folders in symfony can be moved by specifying in the composer.json an "extra" section and adding src-dir for the src for example.' answers: - { value: 'True', correct: true } - { value: 'False', correct: false } help: 'https://symfony.com/doc/current/setup/flex.html#customizing-flex-paths' - uuid: 1ef562a7-a056-6676-8e1f-11075f5e94f6 - question: 'Some structure folders in symfony can be moved by specifying in the composer.json an extra section and adding dir-public for the public folder for example.' + question: 'Some structure folders in symfony can be moved by specifying in the composer.json an "extra" section and adding dir-public for the public folder for example.' answers: - { value: 'True', correct: false } - { value: 'False', correct: true } diff --git a/data/templating_with_twig/auto_escaping.yaml b/data/templating_with_twig/auto_escaping.yaml index c9d9e9c..f20fd68 100644 --- a/data/templating_with_twig/auto_escaping.yaml +++ b/data/templating_with_twig/auto_escaping.yaml @@ -17,7 +17,7 @@ questions: help: 'https://twig.symfony.com/doc/3.x/tags/autoescape.html' - uuid: 1eebf878-8ba7-6a74-9215-99d84c92580c - question: 'What does the raw filter do in Twig? {% autoescape %} {{ safe_value|raw }} {% endautoescape %}' + question: 'What does the raw filter do in Twig? {% autoescape %} {{ safe_value|raw }} {% endautoescape %}' answers: - { value: 'It escapes the content of a variable.', correct: false } - { value: 'It marks a value as safe, preventing it from being escaped.', correct: true } diff --git a/data/templating_with_twig/controller_rendering.yaml b/data/templating_with_twig/controller_rendering.yaml index 0259ea7..ee8ff79 100644 --- a/data/templating_with_twig/controller_rendering.yaml +++ b/data/templating_with_twig/controller_rendering.yaml @@ -32,17 +32,6 @@ questions: - { value: 'Yes', correct: false } - { value: 'No', correct: true } help: 'https://symfony.com/doc/current/templates.html#rendering-a-template-in-controllers' - - - uuid: 1eebf878-8ba8-6f3c-bff0-99d84c92580c - question: 'Which method is valid to render a Response ?' - answers: - - { value: 'return $this->render( product/index.html.twig );', correct: true } - - { value: '$contents = $this->renderView( product/index.html.twig ); return new Response($contents);', correct: true } - - { value: '$contents = $this->render( product/index.html.twig ); return new Response($contents);', correct: false } - - { value: '#[Template( product/index.html.twig )] public function index(): array { return [ ]; }', correct: true } - - { value: 'return $this->renderBlock( product/index.html.twig , price_block );', correct: true } - - { value: '$contents = $this->renderBlockView( product/index.html.twig , price_block ); return new Response($contents);', correct: true } - help: 'https://symfony.com/doc/current/templates.html#rendering-a-template-in-controllers' - uuid: 1eebf878-8ba8-6f96-ac3b-99d84c92580c question: 'What are the correct way to render a controller from twig ?' diff --git a/data/templating_with_twig/global_variables.yaml b/data/templating_with_twig/global_variables.yaml index 55ffce3..192a005 100644 --- a/data/templating_with_twig/global_variables.yaml +++ b/data/templating_with_twig/global_variables.yaml @@ -10,7 +10,7 @@ questions: help: 'https://twig.symfony.com/doc/3.x/templates.html#global-variables' - uuid: 1eebf878-8ba5-6a30-ac9b-99d84c92580c - question: 'Will this code permit to get the {{ ga_tracking }} in every twig files ? twig.globals.ga_tracking: "UA-xxxxx-x"' + question: 'Will this code permit to get the {{ ga_tracking }} in every twig files ? twig.globals.ga_tracking: "UA-xxxxx-x"' answers: - { value: 'No', correct: false } - { value: 'Yes', correct: true } @@ -19,10 +19,10 @@ questions: uuid: 1eebf878-8ba5-6a76-b902-99d84c92580c question: "What's the correct way to declare the global variable uuid to get {{ uuid.generate }} in any twig files ?" answers: - - { value: 'twig.globals.uuid: @App\Generator\UuidGenerator ', correct: true } - - { value: 'twig.globals.uuid: App\Generator\UuidGenerator ', correct: false } - - { value: 'twig.globals.uuid: #App\Generator\UuidGenerator ', correct: false } - - { value: 'twig.uuid: App\\Generator\\UuidGenerator ', correct: false } + - { value: 'twig.globals.uuid: "@App\Generator\UuidGenerator"', correct: true } + - { value: 'twig.globals.uuid: "App\Generator\UuidGenerator"', correct: false } + - { value: 'twig.globals.uuid: "#App\Generator\UuidGenerator"', correct: false } + - { value: 'twig.uuid: "App\\Generator\\UuidGenerator"', correct: false } help: 'https://symfony.com/doc/current/templates.html#global-variables' - uuid: 1eebf878-8ba5-6ac6-b2a2-99d84c92580c diff --git a/data/templating_with_twig/string_interpolation.yaml b/data/templating_with_twig/string_interpolation.yaml index a6aade3..9673a57 100644 --- a/data/templating_with_twig/string_interpolation.yaml +++ b/data/templating_with_twig/string_interpolation.yaml @@ -1,11 +1,11 @@ questions: - uuid: 1eebf878-8ba8-6dca-82af-99d84c92580c - question: "{% set numA = 2 %} {% set numB = 3 %} What will render {{ ' #{numA + numB} ' }} ?" + question: "{% set numA = 2 %} {% set numB = 3 %} What will render {{ ' #{numA + numB} ' }} ?" answers: - { value: '2 + 3', correct: false } - { value: '5', correct: true } - - { value: ' 2 + 3 ', correct: false } + - { value: '"2 + 3"', correct: false } help: 'https://twig.symfony.com/doc/3.x/templates.html#templates-string-interpolation' - uuid: 1eebf878-8ba8-6ea6-a497-99d84c92580c @@ -13,5 +13,5 @@ questions: answers: - { value: '1 + 2=3', correct: true } - { value: '3', correct: false } - - { value: ' 1 + 2=3 ', correct: false } + - { value: '"1 + 2=3"', correct: false } help: 'https://twig.symfony.com/doc/3.x/templates.html#string-interpolation' diff --git a/data/templating_with_twig/twig_syntax_up_to33_version.yaml b/data/templating_with_twig/twig_syntax_up_to33_version.yaml index 66b19d2..933021f 100644 --- a/data/templating_with_twig/twig_syntax_up_to33_version.yaml +++ b/data/templating_with_twig/twig_syntax_up_to33_version.yaml @@ -124,7 +124,7 @@ questions: answers: - { value: '{{ Namespace\\Classname::CONSTANT_NAME }}', correct: false } - { value: '{{ Namespace\Classname::CONSTANT_NAME }}', correct: false } - - { value: "{{ constant('Namespace\\Classname::CONSTANT_NAME') }}", correct: true } + - { value: '{{ constant("Namespace\\Classname::CONSTANT_NAME") }}', correct: true } help: 'https://twig.symfony.com/doc/functions/constant.html' - uuid: 1eebf878-8ba4-62de-8eca-99d84c92580c @@ -185,10 +185,10 @@ questions: uuid: 1eebf878-8ba9-6964-bbd3-99d84c92580c question: 'In a Twig template, how can you test that a given constant is defined by PHP? (Example, how can you check if VERSION constant is defined by Symfony\Component\HttpKernel\Kernel class?)' answers: - - {value: '{% if constant("Symfony\\Component\\HttpKernel\\Kernel::VERSION") ?? %} ... {% endif %}', correct: false} - - {value: '{% if constant("Symfony\\Component\\HttpKernel\\Kernel::VERSION") is defined %} ... {% endif %}', correct: true} - - {value: '{% if constant("VERSION", "Symfony\\Component\\HttpKernel\\Kernel") %}...{% endif %}', correct: false} - - {value: '{% if defined("Symfony\\Component\\HttpKernel\\Kernel::VERSION") %}...{% endif %}', correct: false} + - { value: '{% if constant("Symfony\\Component\\HttpKernel\\Kernel::VERSION") ?? %} ... {% endif %}', correct: false } + - { value: '{% if constant("Symfony\\Component\\HttpKernel\\Kernel::VERSION") is defined %} ... {% endif %}', correct: true } + - { value: '{% if constant("VERSION", "Symfony\\Component\\HttpKernel\\Kernel") %}...{% endif %}', correct: false } + - { value: '{% if defined("Symfony\\Component\\HttpKernel\\Kernel::VERSION") %}...{% endif %}', correct: false } help: 'https://twig.symfony.com/doc/functions/constant.html' - uuid: 1eebf878-8ba9-6e82-aa99-99d84c92580c @@ -218,8 +218,8 @@ questions: uuid: 1eee76e3-3511-6002-9026-0376da4929df question: "Consider the following code snippet: {% set foo, bar = 'FOO' %} Foo is {{ foo }} and Bar is {{ bar }}. What will be the outcome of evaluating this Twig code?" answers: - - { value: 'The output will display the string Foo is and Bar is . .', correct: false } - - { value: 'Twig will raise a Twig_Error_Syntax exception.', correct: true } - - { value: 'The output will display the string Foo is FOO and Bar is . .', correct: false } - - { value: 'The output will display the string Foo is FOO and Bar is FOO. .', correct: false } + - { value: 'The output will display the string "Foo is and Bar is .".', correct: false } + - { value: 'Twig will raise a "Twig_Error_Syntax" exception.', correct: true } + - { value: 'The output will display the string "Foo is FOO and Bar is .".', correct: false } + - { value: 'The output will display the string Foo is "FOO and Bar is FOO.".', correct: false } help: 'https://twig.symfony.com/doc/tags/set.html'