• Nulls elements

    Which of the following values are available to define a null element in YAML ?

    Correct

    • ~

    • null

    The choices were

    • false

    • null

    • ~

    • -

    Help

    http://symfony.com/doc/current/components/yaml/yaml_format.html#nulls

    ~ null

  • Twig operator precedence

    In Twig, which of the following operators has the highest precedence?

    Correct

    • | (filters)

    The choices were

    • <=>

    • ==

    • in

    • | (filters)

    • or

    • and

    Help

    https://twig.symfony.com/doc/3.x/templates.html#expressions

    | (filters)

  • Functions usage

    Which expression can be applied to ??? in order to display the name of each people along with his name and age?

    {% set people = [
        {firstname: "Bob", lastname: "Smith", age: 12},
        {firstname: "Alice", lastname: "Dupond", age: 13},
    ] %}
    {{ ??? }} {# Must display "Bob Smith is 12 years old, Alice Dupond is 13 years old" #}
    Twig

    Correct

    • {{ people|map(p => "#{p.firstname} #{p.lastname} is #{p.age} years old")|join(', ') }}
      Twig

    The choices were

    • {{ people|map(p => "#{p.firstname} #{p.lastname} is #{p.age} years old")|join(', ') }}
      Twig
    • {{ people|split(', ') }}
      Twig
    • None of those

    • {{ people|join(', ') }}
      Twig

    Help

    • https://twig.symfony.com/doc/1.x/filters/map.html
    • https://twig.symfony.com/doc/1.x/filters/join.html
    • https://twig.symfony.com/doc/1.x/filters/split.html
    {{ people|map(p => "#{p.firstname} #{p.lastname} is #{p.age} years old")|join(', ') }}Twig

  • Escaping

    Which syntax is valid to avoid escaping ?

    Correct

    • {{ hello|raw }}

    The choices were

    • {{ hello }}

    • {{ hello|raw }}

    • {{ hello|escape('no') }}

    • {{ hello|no_escape }}

    Help

    https://twig.symfony.com/doc/1.x/filters/escape.html

    {{ hello|raw }}

  • Get value

    How to get the value of title set in a form?

    Correct

    • {{ form.title.vars.value }}
      Twig

    The choices were

    • {{ form.vars.title.value }}
      Twig
    • {{ form.title.vars.value }}
      Twig
    • {{ form.vars.title }}
      Twig
    • {{ form.title }}
      Twig

    Help

    • https://symfony.com/doc/3.0/reference/forms/twig_reference.html#form-variables-reference
    {{ form.title.vars.value }}Twig

  • Evaluating Expressions in Twig

    How can you print the value of the name property in a Twig template ?

    class Foo
    {
        private $name = 'bar';
        private array $data = ['name' => 'baz'];
    public function getName(): string { return $this->name; } }

    Correct

    • {{ foo.getName() }}

    • {{ foo.name }}

    The choices were

    • {{ foo.['name'] }}

    • {% foo.['name'] %}

    • {% foo.data.name %}

    • {% foo.name %}

    • {{ foo.data.name }}

    • {{ foo.getName() }}

    • {% foo.getName() %}

    • {{ foo.name }}

    Help

    • https://twig.symfony.com/doc/3.x/templates.html
    {{ foo.getName() }} {{ foo.name }}

  • Get current route

    How to get the current route name from Twig?

    Wrong

    • {{ app.request.route }}

    The choices were

    • {{ app.request.attributes.get('route') }}

    • {{ app.routing.route }}

    • {{ app.request.attributes.get('_route') }}

    • {{ app.request.attributes._routeName }}

    • {{ app.request.attributes._route }}

    • {{ app.request.route }}

    Help

    • http://symfony.com/doc/current/templating/app_variable.html
    • http://symfony.com/doc/current/components/routing.html

  • Twig

    Which of the following statements will display bar ?

    Wrong

    • {{ [] is not empty ? 'foo' : 'bar' }}

    • {{ 0 ? 'foo' : 'bar' }}

    • {{ 0 is not empty ? 'foo' : 'bar' }}

    • {{ '' ? 'foo' : 'bar' }}

    • {{ [] ? 'foo' : 'bar' }}

    • {{ '' is not empty ? 'foo' : 'bar' }}

    The choices were

    • {{ '0' is not empty ? 'foo' : 'bar' }}

    • {{ [] ? 'foo' : 'bar' }}

    • {{ [] is not empty ? 'foo' : 'bar' }}

    • {{ 0 ? 'foo' : 'bar' }}

    • {{ '' ? 'foo' : 'bar' }}

    • {{ 0 is not empty ? 'foo' : 'bar' }}

    • {{ '' is not empty ? 'foo' : 'bar' }}

    • {{ '0' ? 'foo' : 'bar' }}

    Help

    • https://twig.symfony.com/doc/1.x/tags/if.html
    • https://github.com/twigphp/Twig/blob/1.x/src/Extension/CoreExtension.php (twig_test_empty)

  • Twig delimiters

    What is true about twig delimiters ?

    Correct

    • {{ ... }} is used to output the result of an expression

    • {% ... %} is used to execute statements such as for-loops

    The choices were

    • {% ... %} is used to output the result of an expression

    • {% ... %} is used to execute statements such as for-loops

    • {{ ... }} used to execute statements such as for-loops

    • {{ ... }} is used to output the result of an expression

    Help

    • https://twig.symfony.com/doc/1.x/templates.html#synopsis
    • The only exception to these rules is the include() function that can be called using both {{ }} and {% %} syntax.
    {{ ... }} is used to output the result of an expression {% ... %} is used to execute statements such as for-loops

  • String concatenation

    Which is a valid statement to concatenate two strings in Twig ?

    Wrong

    • {% set concatenated = 'foo'.'bar' %}
      Twig

    The choices were

    • {% concatenated = 'foo'.'bar' %}
      Twig
    • {% set concatenated = 'foo' ~ 'bar' %}
      Twig
    • {% concatenated = 'foo' + 'bar' %}
      Twig
    • {% concatenated = 'foo' ~ 'bar' %}
      Twig
    • {% set concatenated = 'foo' + 'bar' %}
      Twig
    • {% set concatenated = 'foo'.'bar' %}
      Twig

    Help

    • https://twig.symfony.com/doc/3.x/templates.html

  • Checking if constants are defined

    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?)

    Correct

    • {% if constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') is defined %}
        ...
      {% endif %}
      Twig

    The choices were

    • {% if constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') ?? %}
        ...
      {% endif %}
      Twig
    • {% if constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') %}
        ...
      {% endif %}
      Twig
    • {% if defined('Symfony\\Component\\HttpKernel\\Kernel::VERSION') %}
        ...
      {% endif %}
      Twig
    • {% if constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') is defined %}
        ...
      {% endif %}
      Twig
    • {% if constant('VERSION', 'Symfony\\Component\\HttpKernel\\Kernel') %}
        ...
      {% endif %}
      Twig

    Help

    The is defined support for the constant() function was added in Twig 1.28 (November 2016). See http://twig.symfony.com/doc/functions/constant.html

    {% if constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') is defined %} ... {% endif %}Twig

  • String concatenation

    Which is a valid statement to concatenate two strings in Twig ?

    Wrong

    • {% concatenated = 'foo'.'bar' %}
      Twig

    The choices were

    • {% concatenated = 'foo' + 'bar' %}
      Twig
    • {% set concatenated = 'foo' ~ 'bar' %}
      Twig
    • {% concatenated = 'foo'.'bar' %}
      Twig
    • {% set concatenated = 'foo'.'bar' %}
      Twig
    • {% concatenated = 'foo' ~ 'bar' %}
      Twig
    • {% set concatenated = 'foo' + 'bar' %}
      Twig

    Help

    • https://twig.symfony.com/doc/3.x/templates.html

  • HttpClient

    By filling the requirement to have libcurl>=7.36, in which cases HTTP/2 will be enabled ?

    Correct

    • you passed the value 2.0 to the option http_version when you created the client (factory HttpClient::create)

    • You haven't passed a specific option to the factory but you're requesting an https url

    The choices were

    • You haven't passed a specific option to the factory but you're requesting an https url

    • you passed the value true to the option http2 when you created the client (factory HttpClient::create)

    • you passed the value 2.0 to the option http_version when you created the client (factory HttpClient::create)

    Help

    • https://symfony.com/doc/5.0/components/http_client.html
    you passed the value 2.0 to the option http_version when you created the client (factory HttpClient::create) You haven't passed a specific option to the factory but you're requesting an https url

  • PHP Iteration

    Consider the following code snippet :

    <?php
    function xrange($len) {
        $i = 0;
        while ($i < $len) {
            /* ??? */
            $i++;
        }
        return;
    }
    foreach (xrange(1000) as $i) { /* Do something ... */ }

    What should replace /* ??? */ to make $i available to the foreach loop?

    Correct

    • yield $i;

    The choices were

    • push $i;
    • new Iterator($i);
    • return $i;
    • yield $i;

    Help

    http://php.net/generators

    yield $i;PHP

  • Date Handling

    What are the correct ways to parse the 1983-07-01 date into an DateTime object?

    Wrong

    • Yaml::parse('1983-07-01', Yaml::DATETIME)
    • Yaml::parse('1983-07-01', 32)

    The choices were

    • Yaml::parse('1983-07-01', true)
    • Yaml::parse('1983-07-01')
    • Yaml::parse('1983-07-01', 32)
    • Yaml::parse('1983-07-01', Yaml::DATETIME)
    • Yaml::parse('1983-07-01', false)
    • Yaml::parse('1983-07-01', Yaml::PARSE_DATETIME)

    Help

    • http://symfony.com/doc/3.1/components/yaml.html#date-handling
    • https://github.com/symfony/symfony/blob/3.1/src/Symfony/Component/Yaml/Yaml.php
    ways to parse the 1983-07-01 date into an DateTime object? Wrong Yaml::parse('1983-07-01', Yaml::DATETIME)PHP Yaml::parse('1983-07-01', 32)PHP

  • Redirect Response

    Lets assume that our application is reachable through https://myapp.comand using a homepage located via a route called homepage.

    Which of these are correct ways to create a redirection response in a controller that extends Symfony\Bundle\FrameworkBundle\Controller\AbstractController?

    Wrong

    • $response = $this->redirectToRoute("homepage")
    • $response = $this->redirect($this->generateUrl("homepage"))
    • $response = $this->redirect("https://myapp.com/")

    The choices were

    • $response = $this->redirect($this->generate("homepage"))
    • $response = new RedirectionResponse("/")
    • $response = new RedirectResponse("https://myapp.com/")
    • $response = $this->redirectToRoute("homepage")
    • $response = $this->redirect("https://myapp.com/")
    • $response = $this->redirect($this->generateUrl("homepage"))

    Help

    • https://symfony.com/doc/current/controller.html#redirecting
    ways to create a redirection response in a controller that extends Symfony\Bundle\FrameworkBundle\Controller\AbstractController? Wrong $response = $this->redirectToRoute("homepage")PHP $response = $this->redirect($this->generateUrl("homepage"))PHP $response = $this->redirect("https://myapp.com/")PHP

  • Security

    Which of these is the correct way to use the Security annotation to secure a Controller with the ROLE_ADMIN?

    Correct

    • @Security("is_granted('ROLE_ADMIN')")

    The choices were

    • @Security("ROLE_ADMIN")

    • @Security("require('ROLE_ADMIN')")

    • @Security("is_granted('ROLE_ADMIN')")

    • @Security("must('ROLE_ADMIN')")

    Help

    • http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html
    way to use the Security annotation to secure a Controller with the ROLE_ADMIN? Correct @Security("is_granted('ROLE_ADMIN')")

  • Ignoring Attributes

    What is the correct way to ignore attributes?

    Correct

    • $serializer->serialize($person, 'json', [
          AbstractNormalizer::IGNORED_ATTRIBUTES => ['age'],
      ]);

    The choices were

    • $serializer->setIgnoredAttributes(['age']);
    • $serializer->ignoreAttributes(['age']);
    • $serializer->serialize($person, 'json', [
          AbstractNormalizer::IGNORED_ATTRIBUTES => ['age'],
      ]);
    • $normalizer->setIgnoredAttributes(['age']);

    Help

    https://symfony.com/doc/4.4/components/serializer.html#ignoring-attributes

    way to ignore attributes? Correct $serializer->serialize($person, 'json', [ AbstractNormalizer::IGNORED_ATTRIBUTES => ['age'], ]);PHP

  • PHP constant

    What is the correct way to display the value of a PHP constant?

    Correct

    • {{ constant('Namespace\\Classname::CONSTANT_NAME') }}
      Twig

    The choices were

    • {{ Namespace\\Classname::CONSTANT_NAME }}
      Twig
    • {{ Namespace\Classname::CONSTANT_NAME }}
      Twig
    • {{ constant('Namespace\Classname::CONSTANT_NAME') }}
      Twig
    • {{ constant('Namespace\\Classname::CONSTANT_NAME') }}
      Twig

    Help

    • http://twig.symfony.com/doc/functions/constant.html
    way to display the value of a PHP constant? Correct {{ constant('Namespace\\Classname::CONSTANT_NAME') }}Twig

  • Handling Arrays

    With the following code:

    use Acme\Person;
    $person1 = new Person(); $person1->setName('foo'); $person1->setAge(99); $person1->setSportsman(false);
    $person2 = new Person(); $person2->setName('bar'); $person2->setAge(33); $person2->setSportsman(true);
    $persons = array($person1, $person2); $data = $serializer->serialize($persons, 'json');

    what is the correct way to deserialize the $data into an $persons array of Acme\Person objects?

    Wrong

    • use Symfony\Component\Serializer\Encoder\JsonEncoder;
      use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
      use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
      use Symfony\Component\Serializer\Serializer;
      $serializer = new Serializer( array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array(new JsonEncoder()) );
      $persons = array(); $persons = $serializer->deserialize($data, 'Acme\Person', 'json', $persons);

    The choices were

    • use Symfony\Component\Serializer\Encoder\JsonEncoder;
      use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
      use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
      use Symfony\Component\Serializer\Serializer;
      $serializer = new Serializer( array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array(new JsonEncoder()) );
      $persons = $serializer->deserialize($data, 'Acme\Person[]', 'json');
    • use Symfony\Component\Serializer\Encoder\JsonEncoder;
      use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
      use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
      use Symfony\Component\Serializer\Serializer;
      $serializer = new Serializer( array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array(new JsonEncoder()) );
      $persons = $serializer->deserialize($data, 'Acme\Person[]', 'json', 'array');
    • use Symfony\Component\Serializer\Encoder\JsonEncoder;
      use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
      use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
      use Symfony\Component\Serializer\Serializer;
      $serializer = new Serializer( array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array(new JsonEncoder()) );
      $persons = array(); $persons = $serializer->deserialize($data, 'Acme\Person', 'json', $persons);
    • use Symfony\Component\Serializer\Encoder\JsonEncoder;
      use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
      use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
      use Symfony\Component\Serializer\Serializer;
      $serializer = new Serializer( array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array(new JsonEncoder()) );
      $persons = $serializer->deserialize($data, 'Acme\Person', 'json', true);

    Help

    • http://symfony.com/doc/3.0/components/serializer.html#handling-arrays
    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/Serializer/Serializer.php#L107
    way to deserialize the $data into an $persons array of Acme\Person objects? Wrong use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; use Symfony\Component\Serializer\Serializer; $serializer = new Serializer( array(new GetSetMethodNormalizer(), new ArrayDenormalizer()), array(new JsonEncoder()) ); $persons = array(); $persons = $serializer->deserialize($data, 'Acme\Person', 'json', $persons);PHP

  • Deserializing in an Existing Object

    Which of the following is the correct way to deserialize $data formatted in xml into an existing Acme\Person object named $person?

    Correct

    • $serializer->deserialize($data, 'Acme\Person', 'xml', array('object_to_populate' => $person));

    The choices were

    • $serializer->deserialize($data, 'Acme\Person', 'xml', $person);
    • $serializer->deserialize($data, 'Acme\Person', 'xml', array('object_to_populate' => $person));
    • $serializer->deserialize($data, $person, 'xml');
    • $serializer->deserialize($data, $person, 'xml', true);
    • $serializer->deserialize($data, 'Acme\Person', 'xml', array('object' => $person));

    Help

    • http://symfony.com/doc/current/components/serializer.html#deserializing-in-an-existing-object
    way to deserialize $data formatted in xml into an existing Acme\Person object named $person? Correct $serializer->deserialize($data, 'Acme\Person', 'xml', array('object_to_populate' => $person));PHP

  • Voters

    What is the signature of the voteOnAttribute() method from Symfony\Component\Security\Core\Authorization\Voter\Voter abstract class?

    Correct

    • voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token)

    The choices were

    • voteOnAttribute(TokenInterface $token, mixed $subject, string $attribute)
    • voteOnAttribute(string $attribute, TokenInterface $token, mixed $subject)
    • voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token)
    • voteOnAttribute(TokenInterface $token, string $attribute, mixed $subject)

    Help

    https://github.com/symfony/symfony/blob/v6.0.0/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php

    voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token)PHP

  • Security Voters

    What methods MUST be implemented in a custom voter extending Voter ?

    Correct

    • voteOnAttribute()

    • supports()

    The choices were

    • supportsAccess()

    • voteOnAttribute()

    • vote()

    • supportsAttribute()

    • supports()

    • supportsSubject()

    • voteOnAccess()

    Help

    • https://symfony.com/doc/5.x/security/voters.html
    voteOnAttribute() supports()

  • Dependency Injection Tags

    What is the tag to register a service that initializes objects before validation?

    Correct

    • validator.initializer

    The choices were

    • validator.initializer

    • validation_initializer

    • validation.initializer

    • validator_initializer

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#validator-initializer
    validator.initializer

  • Dependency Injection Tags

    What is the tag to register a custom validation constraint validator?

    Correct

    • validator.constraint_validator

    The choices were

    • validation.validator

    • validator.constraint

    • validation.constraint_validator

    • validation.constraint

    • validator.constraint_validator

    • constraint_validator

    • validator_constraint

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#validator-constraint-validator
    validator.constraint_validator

  • Security

    Which sentences are true about user checkers ?

    Correct

    • user checker methods throw an exception when requirements are not fulfilled

    • user checkers must implement a checkPreAuth method

    The choices were

    • user checkers must implement a checkPreAuth method

    • user checkers must implement a check method

    • user checker methods throw an exception when requirements are not fulfilled

    • user checker methods return false when requirements are not fulfilled

    • user checkers must implement a preCheck method

    • user checkers must implement a preAuth method

    Help

    • https://symfony.com/doc/2.8/security/user_checkers.html
    user checker methods throw an exception when requirements are not fulfilled user checkers must implement a checkPreAuth method

  • Firewall Configuration

    You can change where the login form redirects after a successful login using the various config options. In case no previous URL was stored in the session, you may wish to try using the HTTP_REFERER instead. Which security.yml parameter allows you to use the Referer HTTP header?

    Correct

    • use_referer: true
      YAML

    The choices were

    • referer: ~
      YAML
    • referer: true
      YAML
    • use_referer: true
      YAML
    • use_referer: ~
      YAML

    Help

    http://symfony.com/doc/current/security/form_login.html#using-the-referring-url

    use_referer: trueYAML

  • Form Extension

    How to add an extension MyForm to the Form component ?

    Correct

    • use Symfony\Component\Form\Forms;
      $formFactory = Forms::createFormFactoryBuilder() ->addExtension(new MyFormExtension()) ->getFormFactory();

    The choices were

    • use Symfony\Component\Form\Forms;
      $formFactory = Forms::createFormFactoryBuilder() ->addExtension('text', new MyFormExtension()) ->getFormFactory();
    • use Symfony\Component\Form\Forms;
      $formFactory = Forms::createFormFactoryBuilder() ->registerExtension(new MyFormExtension()) ->getFormFactory();
    • use Symfony\Component\Form\Forms;
      $formFactory = Forms::createFormFactoryBuilder() ->addExtension(new MyFormExtension()) ->getFormFactory();
    • use Symfony\Component\Form\Forms;
      $formFactory = Forms::createFormFactoryBuilder() ->add(new MyFormExtension()) ->getFormFactory();

    Help

    • https://symfony.com/doc/2.8/components/form.html#request-handling
    use Symfony\Component\Form\Forms; $formFactory = Forms::createFormFactoryBuilder() ->addExtension(new MyFormExtension()) ->getFormFactory();PHP

  • Config per env

    How to register a service in a specific env in php ?

    Wrong

    • use Symfony\Component\DependencyInjection\Attribute\In;
      #[in(env: 'dev')] class SomeClass { // ... }
      // you can apply more than one attribute to the same class:
      #[in(env: 'dev')] #[in(env: 'test')] class AnotherClass { // ... }

    The choices were

    • use Symfony\Component\DependencyInjection\Attribute\When;
      #[When(env: 'dev')] class SomeClass { // ... }
      // you can apply more than one attribute to the same class:
      #[When(env: 'dev')] #[When(env: 'test')] class AnotherClass { // ... }
    • 
      use Symfony\Component\DependencyInjection\Attribute\On;
      #[on(env: 'dev')] class SomeClass { // ... }
      // you can apply more than one attribute to the same class:
      #[on(env: 'dev')] #[on(env: 'test')] class AnotherClass { // ... }```
    • use Symfony\Component\DependencyInjection\Attribute\In;
      #[in(env: 'dev')] class SomeClass { // ... }
      // you can apply more than one attribute to the same class:
      #[in(env: 'dev')] #[in(env: 'test')] class AnotherClass { // ... }
    • it's not possible

    Help

    https://symfony.com/blog/new-in-symfony-5-3-configure-multiple-environments-in-a-single-file


  • Serializing an Object

    Which of the following is the correct usage for serializing the $person object into json?

    Correct

    • $serializer->serialize($person, 'json');

    The choices were

    • $serializer->serialize($person)->toJson();
    • $serializer->serialize($person, 'json');
    • $serializer->toJson($person);
    • $serializer->serialize('json', $person);

    Help

    • http://symfony.com/doc/current/components/serializer.html#serializing-an-object
    usage for serializing the $person object into json? Correct $serializer->serialize($person, 'json');PHP

  • Dispatch

    What is returned by $dispatcher->dispatch($event, OrderPlacedEvent::NAME) in the following code?

    $event = new OrderPlacedEvent($order);
    $dispatcher->dispatch($event, OrderPlacedEvent::NAME);

    Wrong

    • true

    The choices were

    • $event
    • Nothing

    • true
    • $dispatcher

    Help

    https://github.com/symfony/event-dispatcher/blob/5.0/EventDispatcher.php


  • isEmpty

    What is returned by the isEmpty method of Symfony\Component\HttpFoundation\Response?

    Correct

    • true if the response status code are 204 or 304

    The choices were

    • true if the response content is null

    • true if there is a server error

    • true if the response status code are 204 or 304

    • true if the response has no headers

    Help

    • https://github.com/symfony/symfony/blob/0baa58d4e4bb006c4ae68f75833b586bd3cb6e6f/src/Symfony/Component/HttpFoundation/Response.php#L1090
    true if the response status code are 204 or 304

  • isXmlHttpRequest

    What will be the result of invoking the isXmlHttpRequest() method on a Symfony\Component\HttpFoundation\Request object?

    Correct

    • true if the request has the X-Requested-With header set to XMLHttpRequest.

    The choices were

    • true if the request has the X-Requested-With header set to XMLHttpRequest.

    • true if the request must generate an XML response.

    • true if the request contains XML content.

    • true if the request has the Content-Type header set to application/xml.

    Help

    • https://github.com/symfony/http-foundation/blob/5.3/Request.php#L1763
    true if the request has the X-Requested-With header set to XMLHttpRequest.

  • Booleans elements

    Which of the following values are available to define a boolean element in YAML ?

    Correct

    • true

    • false

    The choices were

    • 1

    • false

    • 0

    • true

    Help

    http://symfony.com/doc/current/components/yaml/yaml_format.html#booleans

    true false

  • Boolean Cast

    What will be the value of $bool ?

    $bool = (bool) "false"

    Correct

    • true

    The choices were

    • false

    • true

    • Error : you cannot cast a String as a Boolean

    Help

    http://php.net/manual/en/language.types.boolean.php

    true

  • Command output

    What is the default value when calling Command::setHidden()?

    Correct

    • true

    The choices were

    • true

    • false

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Console/Command/Command.php#L496

    true

  • Customise the dump() global function

    Which method should you call to customize the behavior of the global dump() function?

    Wrong

    • trigger_error($callable);

    The choices were

    • trigger_error($callable);
    • VarDumper::setDumper($callable);
    • VarDumper::setHandler($callable);
    • set_error_handler($callable);

    Help

    • https://symfony.com/doc/2.6/components/var_dumper/advanced.html

  • Dependency Injection Tags

    What is the tag to register a custom service that loads translations?

    Correct

    • translation.loader

    The choices were

    • translation_loader

    • translation.loader

    • translator_loader

    • translator.loader

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#translation-loader
    translation.loader

  • Dependency Injection Tags

    What is the tag to register a custom service that dumps messages to a file?

    Correct

    • translation.dumper

    The choices were

    • translation_dumper

    • translator.dumper

    • translator_dumper

    • translation.dumper

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#translation-dumper
    translation.dumper

  • DataTransformer

    What are the methods of the Symfony\Component\Form\DataTransformerInterface interface?

    Correct

    • transform()

    • reverseTransform()

    The choices were

    • reverseTransform()

    • transformBack()

    • transformReverse()

    • getName()

    • transform()

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/DataTransformerInterface.php
    • http://symfony.com/doc/2.7/cookbook/form/data_transformers.html#creating-the-transformer
    transform() reverseTransform()

  • Usage

    Which of the following are Filesystem methods?

    Correct

    • touch

    • isAbsolutePath

    • chown

    • rename

    • dumpFile

    • tempnam

    The choices were

    • dumpFile

    • touch

    • duplicate

    • isAbsolutePath

    • move

    • rename

    • chown

    • tempnam

    Help

    • https://github.com/symfony/symfony/blob/5478a9d20d181e8d5a0ef532906e67b6d4d7bd79/src/Symfony/Component/Filesystem/Filesystem.php#L488
    • https://symfony.com/doc/4.1/components/filesystem.html#tempnam
    touch isAbsolutePath chown rename dumpFile tempnam

  • Requirement and default options behaviour

    /**
     * @Route("/article/{id}", name="article", requirements={"id":"\d+"}, defaults={"id":"toto"})
     */
    public function articleAction($id)
    {
        return new Response($id);
    }

    With framework.router.strict_requirements parameter set to true what we should see when going on the /article URL?

    Correct

    • toto

    The choices were

    • toto

    • Unable to find the controller for path "article". The route is wrongly configured.

    • Parameter "id" for route "article" must match "\d+" ("toto" given)

    Help

    • http://symfony.com/doc/current/routing/requirements.html
    • http://symfony.com/doc/current/reference/configuration/framework.html#strict-requirements
    toto

  • Escape characters

    Which of this following code is correct to use the percent character % in a translated string ?

    Wrong

    • {% trans %}Percent: %percent%\%{% endtrans %}
      Twig

    The choices were

    • {% trans %}Percent: %percent%%%{% endtrans %}
      Twig
    • {% trans %}Percent: %percent%{%}{% endtrans %}
      Twig
    • {% trans %}Percent: %percent%\%{% endtrans %}
      Twig
    • {% trans %}Percent: %percent%[%]{% endtrans %}
      Twig

    Help

    http://symfony.com/doc/current/translation.html#twig-templates

    to use the percent character % in a translated string ? Wrong {% trans %}Percent: %percent%\%{% endtrans %}Twig

  • Multiple firewalls

    Considering the following code, which one is correct to specify the default authentication mechanism ?

    Wrong

    • # config/packages/security.yaml
      security:
          enable_authenticator_manager: true
      # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~
      # configure the form authentication as the entry point for unauthenticated users default_entry_point: form_login

    The choices were

    • # config/packages/security.yaml
      security:
          enable_authenticator_manager: true
      # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~
      # configure the form authentication as the entry point for unauthenticated users default_entry_point: form_login
    • # config/packages/security.yaml
      security:
          enable_authenticator_manager: true
      # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~
      # configure the form authentication as the entry point for unauthenticated users default_authentication_mechanism: form_login
    • # config/packages/security.yaml
      security:
          enable_authenticator_manager: true
      # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~
      # configure the form authentication as the entry point for unauthenticated users entry_point: form_login
    • # config/packages/security.yaml
      security:
          enable_authenticator_manager: true
      # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~
      # configure the form authentication as the entry point for unauthenticated users default: form_login

    Help

    https://symfony.com/doc/current/security/authenticator_manager.html#configuring-the-authentication-entry-point

    to specify the default authentication mechanism ? Wrong # config/packages/security.yaml security: enable_authenticator_manager: true # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~ # configure the form authentication as the entry point for unauthenticated users default_entry_point: form_loginPHP

  • FrameworkBundle

    When using AbstractController, what is the purpose of the second argument of the file method ?

    Correct

    • to set the name of the file

    The choices were

    • to set the name of the file

    • to set the disposition of the file (inline or attachement)

    • to set the mime type of the file

    • to set the size of the file

    Help

    • https://symfony.com/doc/3.3/controller.html
    to set the name of the file

  • Read the contents

    Which of the following code is correct to read the contents of returned files ?

    Correct

    • use Symfony\Component\Finder\Finder;
      $finder = new Finder(); $finder->files()->in(__DIR__);
      foreach ($finder as $file) { $contents = $file->getContents();
      // ... }

    The choices were

    • use Symfony\Component\Finder\Finder;
      $finder = new Finder(); $finder->files()->in(__DIR__);
      foreach ($finder as $file) { $contents = $file->readContents();
      // ... }
    • use Symfony\Component\Finder\Finder;
      $finder = new Finder(); $finder->files()->in(__DIR__);
      foreach ($finder as $file) { $contents = $file->getContentsFile();
      // ... }
    • use Symfony\Component\Finder\Finder;
      $finder = new Finder(); $finder->files()->in(__DIR__);
      foreach ($finder as $file) { $contents = $file->readFile();
      // ... }
    • use Symfony\Component\Finder\Finder;
      $finder = new Finder(); $finder->files()->in(__DIR__);
      foreach ($finder as $file) { $contents = $file->read()->contents();
      // ... }
    • use Symfony\Component\Finder\Finder;
      $finder = new Finder(); $finder->files()->in(__DIR__);
      foreach ($finder as $file) { $contents = $file->getContents();
      // ... }

    Help

    • https://symfony.com/doc/current/components/finder.html#reading-contents-of-returned-files
    • https://github.com/symfony/finder/blob/master/SplFileInfo.php#L60
    to read the contents of returned files ? Correct use Symfony\Component\Finder\Finder; $finder = new Finder(); $finder->files()->in(__DIR__); foreach ($finder as $file) { $contents = $file->getContents(); // ... }PHP

  • EventSubscriber

    Is the following class correct to be used as an event subscriber?

    namespace Acme\Store\Event;
    use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Acme\Store\Event\OrderPlacedEvent;
    class StoreSubscriber { public static function getSubscribedEvents() { return array( KernelEvents::RESPONSE => array( array('onKernelResponsePre', 10), array('onKernelResponsePost', -10), ), OrderPlacedEvent::NAME => 'onStoreOrder', ); }
    public function onKernelResponsePre(FilterResponseEvent $event) { // ... }
    public function onKernelResponsePost(FilterResponseEvent $event) { // ... }
    public function onStoreOrder(OrderPlacedEvent $event) { // ... } }

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/current/components/event_dispatcher.html#using-event-subscribers
    to be used as an event subscriber? namespace Acme\Store\Event; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Acme\Store\Event\OrderPlacedEvent; class StoreSubscriber { public static function getSubscribedEvents() { return array( KernelEvents::RESPONSE => array( array('onKernelResponsePre', 10), array('onKernelResponsePost', -10), ), OrderPlacedEvent::NAME => 'onStoreOrder', ); } public function onKernelResponsePre(FilterResponseEvent $event) { // ... } public function onKernelResponsePost(FilterResponseEvent $event) { // ... } public function onStoreOrder(OrderPlacedEvent $event) { // ... } }PHP Correct No

  • Usage

    Given the following code, what will be stored in $string?

    <?php
    // ...
    $string = u('template.html.twig')->trimSuffix(['.twig', '.html']);;

    Wrong

    • template

    The choices were

    • template.

    • An error

    • template.html.twig

    • template

    • template.html

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-misc-features-part-1#new-string-functions
    • https://github.com/symfony/symfony/pull/43481
    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/String/AbstractUnicodeString.php#L447

  • Usage

    What is the correct syntax to create a new request?

    Wrong

    • $httpClient = HttpClient::create();
      $response = $httpClient->request('https://api.github.com/repos/symfony/symfony-docs', 'GET');

    The choices were

    • $httpClient = HttpClient::create();
      $response = $httpClient->request('GET', 'https://api.github.com/repos/symfony/symfony-docs');
    • $httpClient = HttpClient::create();
      $response = $httpClient->request('https://api.github.com/repos/symfony/symfony-docs', 'GET');

    Help

    • https://symfony.com/doc/5.0/http_client.html#basic-usage
    • https://github.com/symfony/symfony/blob/5.0/src/Symfony/Contracts/HttpClient/HttpClientInterface.php
    syntax to create a new request? Wrong $httpClient = HttpClient::create(); $response = $httpClient->request('https://api.github.com/repos/symfony/symfony-docs', 'GET');PHP

  • Usage

    Which of the following are Filesystem methods?

    Correct

    • symlink

    • makePathRelative

    • exists

    • remove

    • isAbsolutePath

    The choices were

    • move

    • isAbsolutePath

    • exists

    • makePathRelative

    • symlink

    • remove

    Help

    https://symfony.com/doc/3.0/components/filesystem.html

    symlink makePathRelative exists remove isAbsolutePath

  • Creating the project

    According to the official Symfony Best Practices Guide and using the Symfony installer, which command allow you to create a blog application?

    Correct

    • symfony new --webapp blog

    The choices were

    • symfony create-project blog

    • symfony install blog

    • symfony create blog

    • symfony new --webapp blog

    Help

    https://symfony.com/download

    symfony new --webapp blog

  • Strings

    Which function would best parse the following string by the tab (\t) and newline (\n) characters ?

    $string = "John\tMark\nTed\tLarry";

    Correct

    • strtok($string, "\t\n");

    The choices were

    • strtok($string, "\t\n");

    • strstr($string, "\t\n");

    • explode($string, "\t\n");

    • str_split($string, "\t\n");

    Help

    • http://php.net/manual/en/function.strtok.php
    • http://php.net/manual/en/language.types.string.php
    strtok($string, "\t\n");

  • Simple Validator Instance

    With this following simple code:

    use Symfony\Component\Validator\Validation;
    $validator = Validation::createValidator();

    Which variables types this $validator object can validate ?

    Correct

    • strings

    • numbers

    • arrays

    The choices were

    • arrays

    • objects

    • numbers

    • strings

    Help

    http://symfony.com/doc/current/components/validator.html#retrieving-a-validator-instance

    strings numbers arrays

  • Dumping Multi-line Literal Blocks

    What will be the output of the following code?

    $string = array("string" => "Multiple\nLine\nString");
    $yaml = Yaml::dump($string, 2, 4, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
    echo $yaml;

    Correct

    • string: |
           Multiple
           Line
           String

    The choices were

    • Multiple\nLine\nString
    • string: "Multiple\nLine\nString"
    • string: "Multiple
      Line
      String"
    • string: Multiple\nLine\nString
    • string: |
           Multiple
           Line
           String
    • "Multiple\nLine\nString"

    Help

    • http://symfony.com/doc/current/components/yaml.html#dumping-multi-line-literal-blocks
    string: | Multiple Line String

  • Dumping Multi-line Literal Blocks

    What will be the output of the following code?

    $string = array("string" => "Multiple\nLine\nString");
    $yaml = Yaml::dump($string);
    echo $yaml;

    Wrong

    • string: |
           Multiple
           Line
           String

    The choices were

    • string: |
           Multiple
           Line
           String
    • string: Multiple\nLine\nString
    • Multiple\nLine\nString
    • string: "Multiple
      Line
      String"
    • string: "Multiple\nLine\nString"
    • "Multiple\nLine\nString"

    Help

    • http://symfony.com/doc/current/components/yaml.html#dumping-multi-line-literal-blocks

  • Dumping Multi-line Literal Blocks

    What will be the output of the following code?

    $string = array("string" => "Multiple\nLine\nString");
    $yaml = Yaml::dump($string);
    echo $yaml;

    Wrong

    • string: "Multiple
      Line
      String"

    The choices were

    • string: |
           Multiple
           Line
           String
    • Multiple\nLine\nString
    • string: "Multiple
      Line
      String"
    • string: Multiple\nLine\nString
    • "Multiple\nLine\nString"
    • string: "Multiple\nLine\nString"

    Help

    • http://symfony.com/doc/current/components/yaml.html#dumping-multi-line-literal-blocks

  • Registering Functions

    What are the arguments of the register() method used to register a function?

    Correct

    • string   $name      The function name
      callable $compiler  A callable able to compile the function
      callable $evaluator A callable able to evaluate the function

    The choices were

    • CompilerInterface  $compiler  A compiler able to compile the function
      EvaluatorInterface $evaluator An evaluator able to evaluate the function
    • callable $compiler  A callable able to compile the function
      callable $evaluator A callable able to evaluate the function
    • string   $name      The function name
      callable $compiler  A callable able to compile the function
      callable $evaluator A callable able to evaluate the function
    • string             $name      The function name
      CompilerInterface  $compiler  A compiler able to compile the function
      EvaluatorInterface $evaluator An evaluator able to evaluate the function

    Help

    • http://symfony.com/doc/current/components/expression_language/extending.html#registering-functions
    string $name The function name callable $compiler A callable able to compile the function callable $evaluator A callable able to evaluate the function

  • Twig Extensions

    According to the official Symfony Best Practices Guide, in which directory do you need to define your Twig extensions?

    Correct

    • src/Twig/

    The choices were

    • src/Twig/Extensions/

    • src/Twig/

    • src/Twig/Extension/

    • src/Extensions/Twig/

    • src/Extension/Twig/

    Help

    • https://symfony.com/doc/3.x/templating/twig_extension.html
    • https://symfony.com/doc/4.0/best_practices/templates.html#twig-extensions
    src/Twig/

  • Functions

    Which of the following language structures and functions does not output anything?

    Correct

    • sprintf()

    The choices were

    • print_r()

    • sprintf()

    • print

    • echo

    • var_dump()

    Help

    • http://php.net/manual/en/function.sprintf.php
    • http://php.net/manual/en/function.var-dump.php
    • http://php.net/manual/en/function.print-r.php
    • http://php.net/manual/en/function.print.php
    • http://php.net/manual/en/function.echo.php
    sprintf()

  • Autoload

    Assuming this code is at the root of the project, which function will allow PHP to automatically find the definitions for your classes?

    Correct

    • 
      spl_autoload_register(function ($class) {
          $filepath = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
          include __DIR__ . $filepath;
      });

    The choices were

    • spl_class_find(function ($class) {
          $filepath = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
          include __DIR__ . $filepath;
      });
    • 
      spl_autoload_register(function ($class) {
          $filepath = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
          include __DIR__ . $filepath;
      });
    • spl_autoload(function ($class) {
          $filepath = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
          return __DIR__ . $filepath;
      });
    • spl_autoload_register(function ($class) {
          return __DIR__ . $class;
      });

    Help

    https://www.php.net/manual/en/function.spl-autoload-register.php

    spl_autoload_register(function ($class) { $filepath = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; include __DIR__ . $filepath; });PHP

  • Copy method

    What is the correct signature of the Symfony\Component\Filesystem\Filesystem::copy method?

    Correct

    • public function copy($originFile, $targetFile, $overwriteNewerFiles = false)

    The choices were

    • public function copy($originFile, $targetFile, $overwriteNewerFiles)
    • public function copy($targetFile, $originFile, $overwriteNewerFiles = false)
    • public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
    • public function copy($targetFile, $originFile, $overwriteNewerFiles)

    Help

    • https://symfony.com/doc/2.7/components/filesystem.html#copy
    • https://github.com/symfony/symfony/blob/4d0899c5e3b30b3be591f8349ce92529d79bee93/src/Symfony/Component/Filesystem/Filesystem.php#L40
    signature of the Symfony\Component\Filesystem\Filesystem::copy method? Correct public function copy($originFile, $targetFile, $overwriteNewerFiles = false)PHP

  • Error handling

    Consider the following code snippet:

    trigger_error('This method is deprecated.');

    Which of the following is valid way to catch and process errors that were triggered with the trigger_error() function?

    Correct

    • set_error_handler(function ($level, $message, $file, $line, array $vars = []) {
          error_log($message);
          if ('cli' !== PHP_SAPI) {
              header('HTTP/1.1 500 Internal Server Error');
              echo 'Oops something wrong happened!';
              exit;
          }
      });

    The choices were

    • set_error_handler(function ($level, $message, $file, $line, array $vars = []) {
          error_log($message);
          if ('cli' !== PHP_SAPI) {
              header('HTTP/1.1 500 Internal Server Error');
              echo 'Oops something wrong happened!';
              exit;
          }
      });
    • try {
          trigger_error('This method is deprecated.');
      } catch (\Exception $e) {
          // do something ...
      }
    • try {
          trigger_error('This method is deprecated.');
      } catch (\Error $e) {
          // do something
      }
    • $errors = get_triggered_errors();
      // do something

    Help

    • http://php.net/trigger_error
    • http://php.net/set_error_handler
    • http://php.net/manual/en/function.error-log.php
    set_error_handler(function ($level, $message, $file, $line, array $vars = []) { error_log($message); if ('cli' !== PHP_SAPI) { header('HTTP/1.1 500 Internal Server Error'); echo 'Oops something wrong happened!'; exit; } });PHP

  • Expiration caching

    Which methods can be used for expiration caching ?

    Wrong

    • setEtag

    • setLastModified

    • setMaxAge

    • setExpires

    The choices were

    • setExpires

    • setCache

    • setLastModified

    • setEtag

    • setSharedMaxAge

    • setMaxAge

    Help

    • https://symfony.com/doc/2.x/http_cache/expiration.html
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Response.php

  • Alias

    With the following service definition how is it possible to create an alias of the foo service?

    services:
        foo:
            class: Example\Foo
    YAML

    Wrong

    • services:
          foo:
              class: Example\Foo
          bar:
              alias: foo
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: bar
      YAML

    The choices were

    • services:
          foo:
              class: Example\Foo
          bar: '@foo'
      YAML
    • services:
          foo:
              class: Example\Foo
              alias:
                  - bar
      YAML
    • services:
          foo:
              class: Example\Foo
          bar:
              alias: foo
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: [bar]
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: bar
      YAML

    Help

    https://symfony.com/doc/2.7/service_container/alias_private.html#aliasing


  • Alias

    With the following service definition how is it possible to create an alias of the foo service?

    services:
        foo:
            class: Example\Foo
    YAML

    Wrong

    • services:
          foo:
              class: Example\Foo
              alias: bar
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: [bar]
      YAML

    The choices were

    • services:
          foo:
              class: Example\Foo
              alias:
                  - bar
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: bar
      YAML
    • services:
          foo:
              class: Example\Foo
          bar: '@foo'
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: [bar]
      YAML
    • services:
          foo:
              class: Example\Foo
          bar:
              alias: foo
      YAML

    Help

    https://symfony.com/doc/2.7/service_container/alias_private.html#aliasing


  • Alias

    With the following service definition how is it possible to create an alias of the foo service?

    services:
        foo:
            class: Example\Foo
    YAML

    Wrong

    • services:
          foo:
              class: Example\Foo
              alias: bar
      YAML
    • services:
          foo:
              class: Example\Foo
              alias:
                  - bar
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: [bar]
      YAML

    The choices were

    • services:
          foo:
              class: Example\Foo
              alias: bar
      YAML
    • services:
          foo:
              class: Example\Foo
              alias:
                  - bar
      YAML
    • services:
          foo:
              class: Example\Foo
          bar: '@foo'
      YAML
    • services:
          foo:
              class: Example\Foo
          bar:
              alias: foo
      YAML
    • services:
          foo:
              class: Example\Foo
              alias: [bar]
      YAML

    Help

    https://symfony.com/doc/2.7/service_container/alias_private.html#aliasing


  • Dependency Injection Tags

    What is the tag to register a new normalizer in the serializer service?

    Correct

    • serializer.normalizer

    The choices were

    • serializer_normalizer

    • serializer.object_normalizer

    • serializer.normalizer

    • serializer.normalize

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#serializer-normalizer
    serializer.normalizer

  • Dependency Injection Tags

    What is the tag to register a new encoder in the serializer service?

    Correct

    • serializer.encoder

    The choices were

    • serializer_encoder

    • serializer.encoder

    • serializer.encode

    • serializer.object_encoder

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#serializer-encoder
    serializer.encoder

  • Xml parameters

    What will be the value of the following configuration sample?

    <parameter key="mailer.transport">
        sendmail
    </parameter>
    XML

    Wrong

    • sendmail

    The choices were

    • \n
          sendmail\n
    • \n
       sendmail\n
    • sendmail\n

    • sendmail

    Help

    The values between parameter tags in XML configuration files are not trimmed. https://symfony.com/doc/4.4/configuration.html#configuration-parameters


  • Command usage

    Which command is used to hash a password?

    Correct

    • security:hash-password

    The choices were

    • security:hash-password

    • security:generate-password

    • security:encode-password

    • security:new-password

    Help

    https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/PasswordHasher/Command/UserPasswordHashCommand.php

    security:hash-password

  • Anonymous Users

    Using the new Authenticator-Based Security, how to allow some routes to be accessed by anonymous users?

    Correct

    • security:
          access_control:
              - { path: ^/admin/login, roles: PUBLIC_ACCESS }
      YAML

    The choices were

    • security:
          access_control:
              - { path: ^/admin/login, roles: ANONYMOUS_ACCESS }
      YAML
    • security:
          access_control:
              - { path: ^/admin/login, roles: UNAUTHENTICATED_ACCESS }
      YAML
    • security:
          access_control:
              - { path: ^/admin/login, roles: PUBLIC_ACCESS }
      YAML

    Help

    https://symfony.com/doc/6.0/security.html#allowing-unsecured-access-i-e-anonymous-users

    security: access_control: - { path: ^/admin/login, roles: PUBLIC_ACCESS }YAML

  • Configuring a Voter

    When creating custom voter, which dependency injection tag has to be used?

    Correct

    • security.voter

    The choices were

    • secure.voter

    • secure.vote

    • security.vote

    • security.voter

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#security-voter
    • http://symfony.com/doc/current/security/voters.html#configuring-the-voter
    security.voter

  • Dependency Injection Tags

    What is the tag to add a custom voter to Symfony's authorization logic?

    Correct

    • security.voter

    The choices were

    • security.authorization_voter

    • security.voter

    • security_voter

    • security.auth_voter

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#security-voter
    security.voter

  • Dependency Injection Tags

    What is the tag to register a provider for expression language functions in security?

    Correct

    • security.expression_language_provider

    The choices were

    • security_provider

    • security.provider

    • security.expression_language_provider

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#security-expression-language-provider
    security.expression_language_provider

  • Domain

    When you want to use a translation in another domain than the default domain, you must specify the domain as:

    Wrong

    • second argument of trans()

    The choices were

    • first argument of trans()

    • fourth argument of trans()

    • second argument of trans()

    • third argument of trans()

    Help

    • https://github.com/symfony/symfony/blob/0baa58d4e4bb006c4ae68f75833b586bd3cb6e6f/src/Symfony/Component/Translation/Translator.php#L169

  • NumberType precision

    What is the option you can pass to a Symfony\Component\Form\Extension\Core\Type\NumberType form type to change the number of decimals allowed until the field rounds.

    Correct

    • scale

    The choices were

    • decimals

    • precision

    • scale

    Help

    http://symfony.com/doc/current/reference/forms/types/number.html

    scale

  • Custom Route Loader

    When creating custom loader, which dependency injection tag has to be used?

    Correct

    • routing.loader

    The choices were

    • router.load

    • router.loader

    • routing.load

    • routing.loader

    Help

    • https://symfony.com/doc/2.7/routing/custom_route_loader.html
    • https://symfony.com/doc/2.0/reference/dic_tags.html#routing-loader
    routing.loader

  • Dependency Injection Tags

    What is the tag to register a custom service that loads routes?

    Correct

    • routing.loader

    The choices were

    • router.route_loader

    • router_loader

    • routing_loader

    • routing.loader

    • routing.route_loader

    • router.loader

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#routing-loader
    routing.loader

  • Dependency Injection Tags

    What is the tag to register a provider for expression language functions in routing?

    Correct

    • routing.expression_language_provider

    The choices were

    • router.expression_language_provider

    • router.provider

    • router.route_provider

    • routing.expression_language_provider

    • routing.route_provider

    • routing.provider

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#routing-expression-language-provider
    routing.expression_language_provider

  • Cryptographically secure random integer

    Which native function should you use to generate a cryptographically secure random integer?

    Correct

    • random_int()

    The choices were

    • rand()

    • mt_rand()

    • random_int()

    • lcg_value()

    Help

    • https://www.php.net/manual/en/ref.random.php
    random_int()

  • PHPUnit

    Which is the method that allows to execute some code only after the last test defined by a class?

    Correct

    • public static function tearDownAfterClass()

    The choices were

    • public static function tearDown()

    • public static function tearDownAfterClass()

    • public function tearDownAfterClass()

    • public function tearDown()

    Help

    https://phpunit.de/manual/current/en/fixtures.html#fixtures.more-setup-than-teardown

    public static function tearDownAfterClass()

  • PHPUnit

    Which is the method that allows to execute some code only before the first test defined by a class?

    Correct

    • public static function setUpBeforeClass()

    The choices were

    • public function setUp()

    • public static function setUp()

    • public function setUpBeforeClass()

    • public static function setUpBeforeClass()

    Help

    https://phpunit.de/manual/current/en/fixtures.html#fixtures.more-setup-than-teardown

    public static function setUpBeforeClass()

  • Data providers

    Which of the following methods are valid PHPUnit data providers?

    Correct

    • public static function provideUrls()
      {
          return [
              ['/homepage', 200],
              ['/login', 403],
              ['/blog/archives', 200],
          ];
      }
    • public static function provideUrls()
      {
          yield ['/homepage', 200];
          yield ['/login', 403];
          yield ['/blog/archives', 200];
      }

    The choices were

    • public static function provideUrls()
      {
          return ['/homepage', 200];
          return ['/login', 403];
          return ['/blog/archives', 200];
      }
    • public static function provideUrls($i)
      {
          $data = array(
              0 => ['/homepage', 200];
              1 => ['/login', 403];
              2 => ['/blog/archives', 200];
          );
      return $data[$i]; }
    • public static function provideUrls()
      {
          return iterator_to_array(
              ['/homepage', 200],
              ['/login', 403],
              ['/blog/archives', 200],
          );
      }
    • public static function provideUrls()
      {
          return [
              ['/homepage', 200],
              ['/login', 403],
              ['/blog/archives', 200],
          ];
      }
    • public static function provideUrls()
      {
          yield ['/homepage', 200];
          yield ['/login', 403];
          yield ['/blog/archives', 200];
      }

    Help

    https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers

    public static function provideUrls() { return [ ['/homepage', 200], ['/login', 403], ['/blog/archives', 200], ]; }PHP public static function provideUrls() { yield ['/homepage', 200]; yield ['/login', 403]; yield ['/blog/archives', 200]; }PHP

  • ServiceSubscriberInterface

    Which method is to be implemented from a ServiceSubscriberInterface?

    Correct

    • public static function getSubscribedServices()

    The choices were

    • public static function setSubscribedServices()
    • public static function addSubscribedService()
    • public static function getSubscribedServices()
    • public function setSubscribedServices()

    Help

    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Contracts/Service/ServiceSubscriberInterface.php
    public static function getSubscribedServices()PHP

  • Voters

    What is the signature of the vote() method from VoterInterface?

    Correct

    • public function vote(TokenInterface $token, $subject, array $attributes)

    The choices were

    • public function vote(TokenInterface $token, $object, array $attributes)
    • public function vote(TokenInterface $token, array $attributes, $object)
    • public function vote(TokenInterface $token, $subject, array $attributes)
    • public function vote(TokenInterface $token, array $attributes, $subject)

    Help

    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php
    public function vote(TokenInterface $token, $subject, array $attributes)PHP

  • Data providers

    Which of the following is a valid code to make a data provider working ?

    Correct

    • public function provideFoo(): array
      {
          return [
              'general case' => [1, 2, 5],
              'specific case' => [2, 7, 4],
          ];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • public function provideFoo(): array
      {
          return [
              [1, 2, 5],
          ];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • public function provideFoo(): \Generator
      {
          yield 'generic case' => [1, 2, 5];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }

    The choices were

    • public function provideFoo(): array
      {
          return [1, 2, 5];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • private function provideFoo(): array
      {
          return [
              [1, 2, 5],
          ];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • private function provideFoo(): array
      {
          return [1, 2, 5];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • public function provideFoo(): array
      {
          return [
              [1, 2, 5],
          ];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • public function provideFoo(): \Generator
      {
          yield 'generic case' => [1, 2, 5];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }
    • public function provideFoo(): array
      {
          return [
              'general case' => [1, 2, 5],
              'specific case' => [2, 7, 4],
          ];
      }
      /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }

    Help

    • https://phpunit.de/manual/5.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers data provider method must be public. Since data providers can return an iterator, generators can be used.
    public function provideFoo(): array { return [ 'general case' => [1, 2, 5], 'specific case' => [2, 7, 4], ]; } /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }PHP public function provideFoo(): array { return [ [1, 2, 5], ]; } /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }PHP public function provideFoo(): \Generator { yield 'generic case' => [1, 2, 5]; } /** * @dataprovider provideFoo */ public function testFoo(int $value1, int $value2, int $expectedValue): void { //... }PHP

  • Translator

    Which method must implement a TranslationLoader that implements Symfony\Component\Translation\Loader\LoaderInterface?

    Correct

    • public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue;

    The choices were

    • public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue;
    • public function load(mixed $resource, string $locale, string $domain): MessageCatalogue;
    • public function load(string $resource, $locale = 'en', $domain = 'messages'): MessageCatalogue;
    • public function load(string $resource, string $locale, string $domain = 'messages'): MessageCatalogue;

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Translation/Loader/LoaderInterface.php

    public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue;PHP

  • Translator

    Which methods must be implemented by classes that implements Symfony\Component\Translation\Loader\LoaderInterface?

    Correct

    • public function load($resource, $locale, $domain = 'messages');

    The choices were

    • public function load($resource, $locale, $domain = 'messages');
    • public function load($resource, $locale, $domain);
    • public function load($locale, $domain);
    • public function load($locale = 'en', $domain = 'messages');
    • public function load($resource, $locale = 'en', $domain = 'messages');

    Help

    https://github.com/symfony/translation/blob/2.3/Loader/LoaderInterface.php

    public function load($resource, $locale, $domain = 'messages');PHP

  • `ResponseInterface::getHeaders` signature

    What is the signature of the Symfony\Contracts\HttpClient\ResponseInterface::getHeaders method?

    Correct

    • public function getHeaders(bool $throw = true): array

    The choices were

    • public function getHeaders(): array

    • public function getHeaders(bool $throw = false): array

    • public function getHeaders(bool $throw = true): array

    Help

    https://symfony.com/doc/6.0/http_client.html#handling-exceptions

    public function getHeaders(bool $throw = true): array

  • Converting Property Names when Serializing and Deserializing

    What are the methods of Symfony\Component\Serializer\NameConverter\NameConverterInterface?

    Correct

    • public function denormalize($propertyName);
    • public function normalize($propertyName);

    The choices were

    • public function getName();
    • public function normalize($propertyName);
    • public function denormalize($propertyName);
    • public function reverse($propertyName);

    Help

    • https://symfony.com/doc/2.7/components/serializer.html#converting-property-names-when-serializing-and-deserializing
    • https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php

    public function denormalize($propertyName);PHP public function normalize($propertyName);PHP

  • Options

    What is the method signature to configure the options in a form?

    Correct

    • public function configureOptions(OptionsResolver $resolver)

    The choices were

    • public function configureOptions(OptionsResolverInterface $resolver)
    • public function setDefaultOptions(OptionsResolverInterface $resolver)
    • public function setDefaultOptions(OptionsResolver $resolver)
    • public function configureOptions(OptionsResolver $resolver)

    Help

    • http://symfony.com/doc/current/book/forms.html
    public function configureOptions(OptionsResolver $resolver)PHP

  • PHPUnit

    Which is the method that allows to execute some code before each test defined by a class?

    Correct

    • protected function setUp()

    The choices were

    • protected static function setUpBeforeClass()

    • protected function setUpBeforeClass()

    • protected static function setUp()

    • protected function setUp()

    Help

    https://phpunit.de/manual/current/en/fixtures.html#fixtures.more-setup-than-teardown

    protected function setUp()

  • Dependency injection

    Which injection types are supported by Symfony's Dependency Injection Container?

    Correct

    • property

    • setter

    • constructor

    The choices were

    • setter

    • getter

    • constructor

    • property

    Help

    • https://symfony.com/doc/current/service_container.html
    • https://symfony.com/doc/current/service_container/injection_types.html
    property setter constructor

  • Dependency Injection Tags

    What is the tag to use to create a class that collects custom data for the profiler?

    Wrong

    • profiler.data_collector

    The choices were

    • debug.data_collector

    • data_collector

    • profiler.data_collector

    • kernel.data_collector

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#data-collector

  • Processes

    From the script below, how would you display the error messages thrown by the 'ls' command ?

    $null = fopen('/dev/null', 'r+');
    $descriptorspec = [0 => $null, 1 => $null, 2 => array("pipe", "w")];
    $process = proc_open("ls /foo", $descriptorspec, $pipes); echo __________________

    Wrong

    • proc_errors($process);

    The choices were

    • proc_errors($process);

    • fgets($pipes[2]);

    • fread($null, 128);

    • stream_errors($pipes);

    Help

    • http://php.net/manual/en/function.fgets.php
    • http://php.net/manual/en/function.proc-open.php

  • Streams

    Which of the following is NOT a default PHP input or output stream ?

    Correct

    • php://error

    The choices were

    • php://stdout

    • php://error

    • php://output

    • php://stdin

    • php://input

    Help

    • http://php.net/manual/en/features.commandline.io-streams.php
    • http://php.net/manual/en/wrappers.php.php
    php://error

  • Finder methods

    Which methods belong to Symfony\Component\Finder\Finder class ?

    Correct

    • path

    • name

    • size

    • notPath

    • notName

    The choices were

    • type

    • notSize

    • owner

    • size

    • name

    • notPath

    • path

    • notName

    Help

    • https://symfony.com/doc/2.3/components/finder.html
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Finder/Finder.php
    path name size notPath notName

  • Directories

    What is the correct option to add other directories in the translator configuration?

    Correct

    • # config/packages/translation.yaml
      framework:
          translator:
              paths:
                  - '%kernel.project_dir%/translations'
      YAML

    The choices were

    • # config/packages/translation.yaml
      framework:
          translator:
              paths:
                  - '%kernel.project_dir%/translations'
      YAML
    • # config/packages/translation.yaml
      framework:
          translator:
              directories:
                  - '%kernel.project_dir%/translations'
      YAML
    • # config/packages/translation.yaml
      framework:
          translator:
              custom_directories:
                  - '%kernel.project_dir%/translations'
      YAML
    • # config/packages/translation.yaml
      framework:
          translator:
              add_paths:
                  - '%kernel.project_dir%/translations'
      YAML
    • # config/packages/translation.yaml
      framework:
          translator:
              custom_paths:
                  - '%kernel.project_dir%/translations'
      YAML

    Help

    • https://symfony.com/doc/current/reference/configuration/framework.html#reference-translator-paths
    option to add other directories in the translator configuration? Correct # config/packages/translation.yaml framework: translator: paths: - '%kernel.project_dir%/translations'YAML

  • FormTypeGuesser usage

    Which types are returned by FormTypeGuesserInterface::guessMaxLength()?

    Wrong

    • null

    • GuessedValue

    The choices were

    • null

    • GuessedValue

    • ResolvedValue

    • ValueGuessed

    • ValueGuess

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/FormTypeGuesserInterface.php


  • FlashBag use

    What will be the response's content when calling FooController::action?

    class FooController extends AbstractController
    {
        public function action(): Response
        {
            $this->addFlash('notice', 'First notice');
            $this->addFlash('notice', 'Second notice');
            $this->addFlash('error', 'First error');
            $this->addFlash('error', 'Second error');
    return $this->render('flash.html.twig'); } }
    {# templates/flash.html.twig #}
    {% for message in app.session.flashBag.peek('notice') %} {{ 'notice: ' ~ message }} {% endfor %}
    {% for label, messages in app.session.flashBag.all %} {% for message in messages %} {{ label ~ ': ' ~ message }} {% endfor %} {% endfor %}
    Twig

    Correct

    • notice: First notice
      notice: Second notice
      notice: First notice
      notice: Second notice
      error: First error
      error: Second error

    The choices were

    • notice: First notice
      notice: Second notice
      error: First error
      error: Second error
    • notice: First notice
      notice: Second notice
      notice: First notice
      notice: Second notice
      error: First error
      error: Second error
    • notice: Second notice
      notice: First notice
      error: Second error
      error: First error
      notice: Second notice
      notice: First notice
    • error: Second error
      error: First error
      notice: Second notice
      notice: First notice

    Help

    https://symfony.com/doc/6.0/controller.html#flash-messages

    notice: First notice notice: Second notice notice: First notice notice: Second notice error: First error error: Second error

  • Cache-Control

    Which Cache-Control directive disallows the browser and all intermediate caches from storing any version of the returned response ?

    Correct

    • no-store

    The choices were

    • no-cache

    • public

    • no-store

    • private

    Help

    • https://tools.ietf.org/html/rfc7234#section-5.2.1.5
    • https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching?hl=en#cache-control
    no-store

  • Validator

    Which of the following values doesn't trigger a violation when the Date constraint is applied to it?

    Wrong

    • new \DateTime('2020-01-15')

    • null

    • '2020-01-15'

    The choices were

    • null

    • new \DateTime('2020-01-15')

    • '2020-01-15'

    • '2020-13-15'

    • '15/01/2020'

    • '15/13/2020'

    Help

    • https://symfony.com/doc/6.0/reference/constraints/Date.html
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Validator/Constraints/DateValidator.php
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Validator/Constraints/DateValidator.php#L45

  • Validator

    Which of the following values doesn't trigger a violation when the Date constraint is applied to it?

    Wrong

    • new \DateTime('2020-01-15')

    • '2020-01-15'

    The choices were

    • '15/01/2020'

    • new \DateTime('2020-01-15')

    • '15/13/2020'

    • '2020-01-15'

    • '2020-13-15'

    • null

    Help

    • https://symfony.com/doc/6.0/reference/constraints/Date.html
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Validator/Constraints/DateValidator.php
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Validator/Constraints/DateValidator.php#L45

  • Functions

    Which of the following is not a built-in function anymore as of PHP 7.0?

    Correct

    • mysql_connect()

    The choices were

    • mysql_connect()

    • date()

    • in_array()

    • metaphone()

    Help

    • http://php.net/manual/en/function.in-array.php
    • http://php.net/manual/en/function.mysql-connect.php
    • http://php.net/manual/en/function.metaphone.php
    • http://php.net/manual/en/function.date.php
    mysql_connect()

  • Object Oriented Programming

    What will be the output of the following code (in PHP 5 / 7 / 8.0) ?

    <?php
    interface Foo { const MY_CONST = 'my_value'; }
    class Bar implements Foo { const MY_CONST = 'my_overriden_value'; }
    echo Bar::MY_CONST;

    Wrong

    • my_overriden_value

    The choices were

    • An error

    • my_overriden_value

    • my_value

    Help

    • https://www.php.net/manual/en/language.oop5.interfaces.php
    • https://www.php.net/manual/en/language.oop5.interfaces.php#language.oop5.interfaces.constants

  • DIC configuration

    Which DIC tag is used by MimeType?

    Correct

    • mime_types

    The choices were

    • mime_types

    • mime_type

    • mime.types

    Help

    • https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Mime/DependencyInjection/AddMimeTypeGuesserPass.php#L30
    mime_types

  • Cache expiration

    Which headers/directives will be ignored by a proxy if Expires, s-maxage and max-age are all present in a response ?

    Correct

    • max-age

    • Expires

    The choices were

    • Expires

    • max-age

    • s-maxage

    Help

    • https://tools.ietf.org/html/rfc7234#section-5.2.2.8
    • https://tools.ietf.org/html/rfc7234#section-5.2.2.9
    • https://tools.ietf.org/html/rfc7234#section-5.3
    max-age Expires

  • Dependency Injection

    Given we add the following extension to the container:

    $fooExtension = new FooExtension();
    $container = new ContainerBuilder();
    $container->registerExtension($fooExtension);

    What extra steps are needed in order to trigger the load method of FooExtension ?

    Wrong

    • load a config file via a container loader (YamlFileLoader, XmlFileLoader...) OR call $container->loadFromExtension($fooExtension->getAlias())

    • call $container->loadFromExtension($fooExtension)

    The choices were

    • call container->compile()

    • call $container->loadFromExtension($fooExtension)

    • load a config file via a container loader (YamlFileLoader, XmlFileLoader...) AND call $container->loadFromExtension($fooExtension->getAlias())

    • load a config file via a container loader (YamlFileLoader, XmlFileLoader...) OR call $container->loadFromExtension($fooExtension->getAlias())

    Help

    • https://symfony.com/doc/2.3/components/dependency_injection/compilation.html

  • Basics

    The ___________ language construct is particularly useful to assign your own variable names to values within an array.

    Correct

    • list()

    The choices were

    • array_get_variables()

    • each()

    • import_variables()

    • list()

    • current()

    Help

    • http://php.net/manual/en/language.variables.php
    • http://php.net/list
    list()

  • Command lifecycle

    Which of the following describes the correct lifecycle of a Command?

    Correct

    • initialize -> interact -> execute

    The choices were

    • interact -> initialize -> execute

    • initialize -> interact -> execute

    • initialize -> execute -> interact

    Help

    https://symfony.com/doc/6.0/console.html#command-lifecycle

    lifecycle of a Command? Correct initialize -> interact -> execute

  • Array functions

    What line of code should be substituted with /** line **/ to achieve an output of a?

    <?php
    $fruitAndVeg = [ 'c' => 'Carrot', 'p' => 'Tomato', 'b' => 'Banana', 't' => 'Potato', 'a' => 'Apple' ];
    /** line **/
    $keys = array_keys($fruitAndVeg);
    echo $keys[0];

    Correct

    • ksort($fruitAndVeg);

    The choices were

    • usort($fruitAndVeg);

    • sort($fruitAndVeg);

    • krsort($fruitAndVeg);

    • ksort($fruitAndVeg);

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.sort.php
    • https://php.net/manual/en/function.ksort.php
    • https://php.net/manual/en/function.usort.php
    • https://php.net/manual/en/function.krsort.php
    ksort($fruitAndVeg);

  • HttpKernel Events

    Which of the following kernel events should you listen to in order to modify the HTTP response before it is sent back to the client?

    Wrong

    • kernel.view

    • kernel.response

    The choices were

    • kernel.controller

    • kernel.view

    • kernel.finish_request

    • kernel.terminate

    • kernel.request

    • kernel.response

    Help

    https://symfony.com/doc/current/components/http_kernel.html


  • HttpKernel Events

    In which order does Symfony trigger the following events?

    Correct

      1. kernel.request
      2. kernel.controller
      3. kernel.controller_arguments
      4. kernel.view
      5. kernel.response
      6. kernel.finish_request
      7. kernel.terminate

    The choices were

      1. kernel.request
      2. kernel.controller
      3. kernel.controller_arguments
      4. kernel.response
      5. kernel.view
      6. kernel.terminate
      7. kernel.finish_request
      1. kernel.request
      2. kernel.controller
      3. kernel.controller_arguments
      4. kernel.view
      5. kernel.response
      6. kernel.terminate
      7. kernel.finish_request
      1. kernel.request
      2. kernel.controller
      3. kernel.controller_arguments
      4. kernel.view
      5. kernel.response
      6. kernel.finish_request
      7. kernel.terminate
      1. kernel.request
      2. kernel.controller
      3. kernel.controller_arguments
      4. kernel.response
      5. kernel.view
      6. kernel.finish_request
      7. kernel.terminate

    Help

    https://symfony.com/doc/4.2/components/http_kernel.html#creating-an-event-listener

    kernel.request kernel.controller kernel.controller_arguments kernel.view kernel.response kernel.finish_request kernel.terminate

  • Locale aware services

    Which tag will be applied to the following service once registered?

    <?php
    namespace App\Service;
    use Symfony\Contracts\Translation\LocaleAwareInterface;
    final class LocaleHelper implements LocaleAwareInterface { public function setLocale(string $locale): void { // ... }
    public function getLocale(): string { return 'en'; } }

    Correct

    • kernel.locale_aware

    The choices were

    • locale_aware

    • kernel.locale_entrypoint

    • None

    • locale_listener

    • kernel.locale_aware

    • kernel.locale_listener

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L386

    kernel.locale_aware

  • Dependency Injection Tags

    What is the tag to add a new HTTP content rendering strategy?

    Correct

    • kernel.fragment_renderer

    The choices were

    • kernel.renderer

    • kernel.content_renderer

    • kernel.fragment_renderer

    • fragment_renderer

    • content_renderer

    • renderer

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#kernel-fragment-renderer
    kernel.fragment_renderer

  • SensioFrameworkExtraBundle

    Which event does the ParamConverterListener listen to ?

    Correct

    • kernel.controller

    The choices were

    • kernel.request

    • kernel.controller

    • kernel.controller_arguments

    Help

    https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/2.3/EventListener/ParamConverterListener.php

    kernel.controller

  • FrameworkBundle

    When using RedirectController, which routing param allows to redirect with a 307/308 status code ?

    Correct

    • keepRequestMethod

    The choices were

    • status_code

    • http_status

    • keepRequestMethod

    • statusCode

    Help

    • https://symfony.com/doc/4.1/routing/redirect_in_config.html
    keepRequestMethod

  • FrameworkBundle

    When using Twig in the full stack framework, which of these configuration keys are related to cache busting?

    Correct

    • json_manifest_path

    • version

    • version_strategy

    • version_format

    The choices were

    • hash

    • version_map

    • json_manifest_path

    • version_hash

    • version_strategy

    • version

    • version_format

    Help

    https://symfony.com/doc/3.3/reference/configuration/framework.html#packages

    json_manifest_path version version_strategy version_format

  • Yield and function prototype

    What is missing in the following code snippet in place of ??? ?

    $f = function (): ??? {
        yield null;
    };

    Correct

    • iterable

    The choices were

    • iterable

    • use (Iterable)

    • array

    • void

    Help

    http://php.net/manual/en/language.types.iterable.php

    iterable

  • HttpKernel

    Which sentences about AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER are true ?

    Wrong

    • it's designed to be used as a response header

    • it's related to the no-cache property of cache-control

    • it's related to the no-store property of cache-control

    The choices were

    • it's related to the public/private property of cache-control

    • it's related to the no-cache property of cache-control

    • it's designed to be used as a SessionInterface option

    • it's related to the no-store property of cache-control

    • it's related to session storage strategy

    • it's designed to be used as a request header

    • it's designed to be used as a response header

    Help

    https://github.com/symfony/http-kernel/blob/4.1/EventListener/AbstractSessionListener.php


  • Dependency Injection

    What is true about ContainerConfigurator?

    Wrong

    • it allows to configure a service after its instanciation

    The choices were

    • it allows to work with service definitions

    • it allows to configure a service after its instanciation

    • it's an internal class that you should not use in your application

    • it doesn't exist

    Help

    • https://symfony.com/doc/5.3/service_container.html (See container configuration examples with PHP)
    • https://github.com/symfony/dependency-injection/blob/5.3/Loader/Configurator/ContainerConfigurator.php
    • The ContainerConfigurator (which is capable of configuring the container) should not be confused with a "service configurator" that allows to apply extra configuration logic to a specific service: https://symfony.com/doc/2.x/service_container/configurators.html

  • The FrameworkBundle Base Controller Class

    Which of the following are valid methods of the Symfony base controller class?

    Correct

    • isCsrfTokenValid()

    • redirectToRoute()

    • denyAccessUnlessGranted()

    The choices were

    • denyAccessUnlessGranted()

    • isCsrfTokenValid()

    • createXmlResponse()

    • generatePath()

    • redirectToRoute()

    Help

    Symfony 3 : https://github.com/symfony/symfony/blob/3.0/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

    Symfony 4 and later : https://github.com/symfony/symfony/blob/4.0/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

    isCsrfTokenValid() redirectToRoute() denyAccessUnlessGranted()

  • The Type validation constraint

    Which of the following are valid values for the type option of the Symfony\Component\Validator\Constraints\Type validation constraint ?

    Wrong

    • integer

    • email

    The choices were

    • digit

    • integer

    • alpha

    • graph

    • email

    • xml

    Help

    • https://symfony.com/doc/current/reference/constraints/Type.html

    You can use ctype_ functions from corresponding built-in PHP extension (http://php.net/manual/en/ref.ctype.php)


  • `Command::execute` return type

    What is the return type of the Symfony\Component\Console\Command\Command::execute method?

    Correct

    • int

    The choices were

    • int

    • ?int

    • ?bool

    • void

    • bool

    Help

    https://symfony.com/doc/6.0/console.html#creating-a-command https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Console/Command/Command.php#L293-L295

    int

  • Button types

    Which type does not correspond to a button?

    Correct

    • input

    The choices were

    • submit

    • button

    • input

    • reset

    Help

    https://symfony.com/doc/2.3/reference/forms/types.html#buttons

    input

  • SSI Symfony support

    Which SSI (Server Side Includes) directive is supported by Symfony?

    Correct

    • include (<!--#include virtual="menu.cgi" -->)

    The choices were

    • config (<!--#config timefmt="%y %m %d" -->)

    • include (<!--#include virtual="menu.cgi" -->)

    • echo (<!--#echo var="REMOTE_ADDR" -->)

    • flastmod (<!--#flastmod virtual="index.html" -->)

    • exec (<!--#exec cgi="/cgi-bin/foo.cgi" -->)

    Help

    https://symfony.com/doc/6.0/http_cache/ssi.html

    include (<!--#include virtual="menu.cgi" -->)

  • Security providers

    Which of these are Symfony built-in security providers configuration name?

    Wrong

    • in_memory

    • ldap

    • chain

    The choices were

    • chain

    • ldap

    • doctrine

    • in_memory

    • memory

    Help

    • https://symfony.com/doc/3.0/reference/configuration/security.html
    • https://symfony.com/doc/3.0/security.html#security-user-providers

  • Translation Source File Location

    According to the official Symfony Best Practices Guide, where do you need to store the translation files?

    Wrong

    • in the translations/<language> directory

    The choices were

    • in the src/Resources/translations/ directory of each bundle

    • in the src/Resources/translations/<language> directory of each bundle

    • in the translations/<language> directory

    • in the translations/ directory

    Help

    https://symfony.com/doc/current/best_practices/i18n.html#translation-source-file-location


  • PHP objects general

    When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used ?

    Wrong

    • if ($obj1->equals($obj2)) { }

    The choices were

    • if ($obj1 instanceof $obj2) { }
    • if ($obj1->equals($obj2)) { }
    • if ($obj1 = $obj2) { }
    • if ($obj1 === $obj2) { }
    • if ($obj1 == $obj2) { }
    • if ($obj1 instanceof $obj2 && $obj1->equals($obj2)) { }

    Help

    http://php.net/manual/en/language.oop5.object-comparison.php


  • The "with" tag

    In the following Twig template:

    {% set maxItems = 10 %}
    {% with { maxItems: 5 } %} {% for i in 1..maxItems %} {# ... #} {% endfor %} {% endwith %}
    {% for j in 1..maxItems %} {# ... #} {% endfor %}
    Twig

    Which will be the last values iterated by i and j variables in the for loops?

    Correct

    • i = 5 and j = 10

    The choices were

    • i = 5 and j = 5

    • i = 5 and j = 10

    • i = 10 and j = 5

    • i = 10 and j = 10

    Help

    Twig 1.28 (November 2016) introduced a new with tag that allows to create different scopes in the same template. Variables defined inside a with tag are not available outside of it and don't modify the external variables. See https://twig.symfony.com/doc/tags/with.html

    i = 5 and j = 10

  • Route definition

    Consider the following route definition:

    <!-- config/routes.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <routes ...>
        <route id="forum_thread"
            path="/category/{slug}/thread-{id}.html" 
            methods="GET" 
            host="forum.domain.tld"
            controller="App\Controller\ForumController::thread">
        </route>
    </routes>
    XML

    Which of the following URL patterns will match the forum_thread route?

    Wrong

    • http://www.domain.tld/category/73/thread-hello-world.html

    • http://forum.domain.tld/category/documentary/thread-aircrafts-mega-factory.html

    • http://forum.domain.tld/category/programming/thread-42.html?page=3

    The choices were

    • http://forum.domain.tld/category/documentary/thread-aircrafts-mega-factory.html

    • http://forum.domain.tld/category/18-roles-games/world-of-warcraft.html

    • http://www.domain.tld/category/73/thread-hello-world.html

    • http://forum.domain.tld/category/tv-shows/thread-dexter?page=3

    • http://forum.domain.tld/category/programming/thread-42.html?page=3

    Help

    • https://symfony.com/doc/current/routing.html
    • https://symfony.com/doc/current/components/routing.html

  • Interpretation

    Consider the following code snippet:

    echo print('hello');

    What will be the output when running this script?

    Wrong

    • hello

    The choices were

    • hello5
    • hello
    • hellotrue
    • hello1
    • hello0

    Help

    • http://php.net/echo
    • http://php.net/print

  • Subscribing to Events

    What methods must a class implementing EventSubscriberInterface implement ?

    Correct

    • getSubscribedEvents()

    The choices were

    • getSubscribedEvents()

    • onEvent()

    • handleEvent()

    • listenToEvents()

    • subscribeToEvents()

    Help

    • https://symfony.com/doc/5.x/components/event_dispatcher.html#using-event-subscribers
    getSubscribedEvents()

  • KernelEvent

    What are the methods available in Symfony\Component\HttpKernel\Event\KernelEvent?

    Correct

    • getRequest

    • getRequestType

    • isMainRequest

    • getKernel

    The choices were

    • hasRequest

    • hasResponse

    • getException

    • getResponse

    • hasException

    • getRequest

    • getRequestType

    • isMainRequest

    • getKernel

    Help

    https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpKernel/Event/KernelEvent.php

    getRequest getRequestType isMainRequest getKernel

  • Expression Function Provider

    What are the methods of Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface?

    Correct

    • getFunctions();

    The choices were

    • getFunctions();
      addFunction(ExpressionFunction $function);
    • getFunctions();
      register($name, callable $compiler, callable $evaluator);
    • getFunctions();
    • getFunctions();
      register($name, callable $compiler, callable $evaluator);
      addFunction(ExpressionFunction $function);

    Help

    https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/ExpressionLanguage/ExpressionFunctionProviderInterface.php

    getFunctions();PHP

  • Extension helper in File

    In Symfony\Component\HttpFoundation\File\File: what is the difference between the getExtension() method and the guessExtension() method?

    Correct

    • getExtension returns the file extension extracted from the original file name and guessExtension returns the extension based on the MIME type.

    The choices were

    • getExtension returns the extension based on the MIME type and guessExtension returns the file extension extracted from the original file name.

    • Only the getExtension method exists in this class.

    • getExtension returns the file extension extracted from the original file name and guessExtension returns the extension based on the MIME type.

    Help

    https://symfony.com/doc/current/controller/upload_file.html

    getExtension returns the file extension extracted from the original file name and guessExtension returns the extension based on the MIME type.

  • HttpClient

    Which method call allows to retrieve detailed logs about the requests and the responses of an http transaction ?

    Wrong

    • getDebugInfo()

    The choices were

    • getInfoDebug()

    • getInfo('debug')

    • getDebugInfo()

    • getDebug('info')

    Help

    • https://symfony.com/doc/5.0/components/http_client.html

  • Functions arguments

    Consider the following code snippet:

    function bake()
    {
        $third = ??? ;
        // ...
    }
    bake('flour', 'spinach', 'egg', 'tomato', 'salt');

    Which statement does the ??? placeholder replace in order to store the third passed arguments in the $third variable? What are the ways to get the third argument passed to a function?

    Correct

    • func_get_arg(2)
    • func_get_args()[2]

    The choices were

    • $_ARGS[2]
    • func_get_arg(2)
    • func_get_arg(3)
    • func_get_args()[2]
    • $argv[3]

    Help

    • http://php.net/manual/en/function.func-get-arg.php
    • http://php.net/manual/en/function.func-get-args.php
    func_get_arg(2)PHP func_get_args()[2]PHP

  • PercentType value storage

    What are the valid values of the type option of the Symfony\Component\Form\Extension\Core\Type\PercentType form type.

    Correct

    • fractional

    • integer

    The choices were

    • raw

    • rounded

    • integer

    • decimal

    • fractional

    Help

    https://symfony.com/doc/2.3/reference/forms/types/percent.html#type

    fractional integer

  • Dependency Injection Tags

    What is the tag to use to create a custom form field type?

    Correct

    • form.type

    The choices were

    • form.type_extension

    • form.type

    • form_type

    • form

    Help

    https://symfony.com/doc/2.7/reference/dic_tags.html#form-type

    form.type

  • PHP Config + Symfony

    The default value of the realpath_cache_size PHP configuration option is 16K. Is this setting correct for a typical Symfony application?

    Wrong

    • Yes, because the performance of Symfony applications is independent from that option.

    The choices were

    • No, it's recommended to decrease it to 4K to limit the I/O load in the server.

    • No, it's recommended to increase it at least to 4096K.

    • Yes. There is no need to change the default value.

    • Yes, because the performance of Symfony applications is independent from that option.

    Help

    http://symfony.com/doc/current/performance.html

    for a typical Symfony application? Wrong Yes, because the performance of Symfony applications is independent from that option.

  • Twig

    Which of the following are valid block names ?

    Correct

    • foo_bar

    • foo123

    • _foo

    The choices were

    • foo123

    • _foo

    • -foo

    • foo_bar

    • .foo

    • foo.bar

    • 123foo

    Help

    • https://twig.symfony.com/doc/1.x/tags/block.html
    foo_bar foo123 _foo

  • Form

    Given the following configuration:

    $form = $this
          ->createFormBuilder(['myfield' => 'foo'])
          ->add('myfield', TextType::class, ['data' => 'bar', 'empty_data' => 'none'])
          ->getForm();

    What will be displayed in the myfield field ?

    Wrong

    • foo

    The choices were

    • none

    • Nothing, an exception will be thrown

    • foo

    • bar

    Help

    • https://symfony.com/doc/2.3/reference/forms/types/form.html#data

  • FindDefinition

    What's the difference between findDefinition and getDefinition?

    Correct

    • findDefinition Resolves aliases

    The choices were

    • findDefinition doesn't exist

    • getDefinition Resolves aliases

    • findDefinition Resolves aliases

    • There is no difference

    Help

    • https://symfony.com/doc/current/service_container/definitions.html#getting-and-setting-service-definitions
    • https://github.com/symfony/symfony/blob/6da9c5d35b075795d7b0cdc5f09cd92ef0df2fd1/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L894
    findDefinition Resolves aliases

  • Block class/method overriding

    Which keyword is used to block any overriding of a class/method by a subclass?

    Correct

    • final

    The choices were

    • protected

    • void

    • static

    • final

    • private

    Help

    http://php.net/manual/en/language.oop5.final.php

    final

  • Array functions

    What should you replace /* ??? */ by to get an output of

    a = One; b = Two; c = Three

    <?php
    $a = 'somevalue'; $array = ['a' => 'One', 'b' => 'Two', 'c' => 'Three']; /* ??? */ echo "a = $a; b = $b; c = $c";

    Correct

    • extract($array);

    The choices were

    • asort($array);

    • extract($array);

    • ksort($array);

    • implode($array);

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.extract.php
    extract($array);

  • String

    What is the best way to split a string with the -=- pattern?

    Correct

    • explode("-=-", $string);

    The choices were

    • explode("-=-", $string);
    • preg_split("-=-", $string);
    • str_split($string, strpos($string, "-=-"));

    Help

    • http://php.net/manual/en/function.explode.php
    • http://php.net/manual/en/function.preg-split.php
    • http://php.net/manual/en/function.str-split.php
    explode("-=-", $string);PHP

  • Checking Property Paths

    What is the method to call to check if getValue can safely be called?

    Wrong

    • exists()

    The choices were

    • checkValue()

    • isReadable()

    • exists()

    • canRead()

    Help

    • http://symfony.com/doc/current/components/property_access/introduction.html#checking-property-paths
    • https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L217

  • Increment operator

    Consider the following code snippet:

    $a = 4;
    $b = $a+++$a++;

    Which of the following is the correct evaluated expression for the $b variable value?

    Correct

    • $b = 4 + 5;

    The choices were

    • $b = 4 + 5;
    • $b = 5 + 7;
    • $b = 5 + 6;
    • $b = 5 + 5;
    • $b = 4 + 4;

    Help

    • https://secure.php.net/manual/en/language.operators.increment.php
    evaluated expression for the $b variable value? Correct $b = 4 + 5;PHP

  • Setting cache settings

    Which options are available in the Symfony\Component\HttpFoundation\Response::setCache(array $options) method ?

    Correct

    • etag

    • max_age

    • private

    • public

    • last_modified

    • s_maxage

    The choices were

    • not_modified

    • last_modified

    • public

    • expires

    • s_maxage

    • etag

    • max_age

    • private

    Help

    • http://symfony.com/doc/current/http_cache.html#more-response-methods
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Response.php#L826
    etag max_age private public last_modified s_maxage

  • Control Structures

    Which of the following is not a supported control structure keyword in PHP?

    Correct

    • enddowhile;

    The choices were

    • endwhile;

    • endfor;

    • endif;

    • endforeach;

    • enddowhile;

    Help

    • https://php.net/manual/en/language.control-structures.php
    • https://php.net/manual/en/control-structures.alternative-syntax.php
    enddowhile;

  • Dependency Injection Tags

    What is the tag to use to listen to different events/hooks in Symfony?

    Wrong

    • dispatcher.event_listener

    The choices were

    • kernel.listener

    • kernel.event_listener

    • event_listener

    • event_dispatcher.event_listener

    • dispatcher.event_listener

    • dispatcher.listener

    Help

    • http://symfony.com/doc/current/reference/dic_tags.html#kernel-event-listener

  • Container

    What is the command to display the debug information of the container?

    Correct

    • debug:container

    The choices were

    • container:debug

    • services:debug

    • debug:container

    • container:info

    • debug:services

    Help

    • http://symfony.com/doc/current/book/service_container.html#debugging-services
    debug:container

  • Functions

    Which of the following are built-in Twig functions (not from the Symfony bridge)?

    Wrong

    • date()

    • dump()

    • attribute()

    • path()

    The choices were

    • date()

    • render()

    • path()

    • dump()

    • max()

    • source()

    • url()

    • attribute()

    Help

    https://twig.symfony.com/doc/1.x/functions/index.html#functions


  • Array functions

    What is the output ?

    <?php
    $array1 = ['a', 'b', 'c', 'd', 'e', 'f'];
    $array2 = array_slice($array1, -3);
    foreach ($array2 as $val) { print "$val "; }

    Correct

    • d e f

    The choices were

    • c d e

    • b c d

    • d e f

    • a b c

    Help

    • https://www.php.net/manual/en/language.types.array.php
    • https://www.php.net/manual/en/function.array-slice
    d e f

  • Escaping

    Which escape strategies are valid for HTML documents ?

    Correct

    • css

    • url

    • html_attr

    • js

    • html

    The choices were

    • html

    • asset

    • css

    • html_attr

    • js

    • url

    Help

    https://twig.symfony.com/doc/1.x/filters/escape.html

    css url html_attr js html

  • FrameworkBundle Configuration

    What are the options for configuring the session with cookies in the FrameworkBundle Configuration (framework)?

    Correct

    • cookie_lifetime

    • cookie_httponly

    • cookie_domain

    • cookie_path

    • cookie_secure

    The choices were

    • force_cookie

    • cookie_domain

    • cookie_path

    • use_cookie

    • cookie_secure

    • cookie_lifetime

    • cookie_httponly

    Help

    • http://symfony.com/doc/current/reference/configuration/framework.html#session
    cookie_lifetime cookie_httponly cookie_domain cookie_path cookie_secure

  • Dependency Injection Tags

    What is the tag to use to register a value resolver for controller arguments such as Request?

    Correct

    • controller.argument_value_resolver

    The choices were

    • argument_resolver

    • controller.argument_value_resolver

    • controller.argument_resolver

    • controller.value_resolver

    Help

    https://symfony.com/doc/3.1/reference/dic_tags.html#controller-argument-value-resolver

    controller.argument_value_resolver

  • Parameter bag

    Which of the following parameter bags are not available in the Request object?

    Correct

    • controller

    • response

    The choices were

    • request

    • response

    • server

    • controller

    Help

    https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php

    controller response

  • Access Decision Manager

    Which of the following are built-in voting strategies that can be configured in the AccessDecisionManager object?

    Wrong

    • consensus

    • unanimous

    • affirmative

    The choices were

    • unanimous

    • priority

    • consensus

    • neutral

    • positive

    • affirmative

    • null

    • veto

    Help

    https://symfony.com/doc/5.1/security/voters.html#changing-the-access-decision-strategy


  • Access Decision Manager

    Which of the following is the AccessDecisionManager default strategy?

    Wrong

    • consensus

    The choices were

    • affirmative

    • consensus

    • unanimous

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php#L30


  • Default validation files directory

    What is the default directory to store PHP, YAML or XML validation files (when not using annotations to define constraints)?

    Wrong

    • config/validations/

    The choices were

    • config/validator/constraints/

    • config/validations/

    • constraints/

    • validations/

    • config/constraints/

    • config/packages/validations/

    • validator/

    • config/validator/

    • config/packages/validator/

    Help

    https://symfony.com/doc/4.x/validation.html#the-basics-of-validation


  • Configuration

    According to the official Symfony Best Practices Guide, where do you need to define the application behavior related configuration options?

    Wrong

    • config/parameters.yaml

    The choices were

    • config/parameters.yaml

    • .env

    • config/parameters.yaml.dist

    • .env.dist

    • config/services.yaml

    Help

    • https://symfony.com/doc/4.x/best_practices.html#configuration
    • https://symfony.com/doc/4.x/best_practices/configuration.html#application-related-configuration

  • Expression Language

    Which of these ExpressionLanguage methods allow to cache the parsed expression ?

    Correct

    • compile

    • evaluate

    • parse

    The choices were

    • evaluate

    • compile

    • parse

    Help

    • https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php (parse uses cache, compile and evaluate call parse)
    compile evaluate parse

  • Object inheritance

    How to define a class that inherits from Foo ?

    Correct

    • class Bar extends Foo {}

    The choices were

    • class Bar inherits Foo {}

    • class Bar childof Foo {}

    • class Bar extends Foo {}

    Help

    • https://www.php.net/manual/en/language.oop5.inheritance.php
    class Bar extends Foo {}

  • OptionsResolver usage

    When using the OptionsResolver, what is the correct call to setAllowedTypes to allow the value null for the option named my_option ?

    Wrong

    • $resolver->setAllowedTypes('my_option', [null]);
    • $resolver->setAllowedTypes('my_option', null);

    The choices were

    • $resolver->setAllowedTypes('my_option', ['null']);
    • $resolver->setAllowedTypes('my_option', 'null');
    • $resolver->setAllowedTypes('my_option', [null]);
    • $resolver->setAllowedTypes('my_option', null);

    Help

    • http://symfony.com/doc/2.6/components/options_resolver.html#type-validation
    • https://github.com/symfony/symfony/blob/240e9648af3daa5ed19580fdec74d768e30692a6/src/Symfony/Component/OptionsResolver/OptionsResolver.php#L572
    call to setAllowedTypes to allow the value null for the option named my_option ? Wrong $resolver->setAllowedTypes('my_option', [null]);PHP $resolver->setAllowedTypes('my_option', null);PHP

  • Route debug

    Given the following output, which command could be used to format it?

    <?xml version="1.0" encoding="UTF-8"?>
    <route name="home" class="Symfony\Component\Routing\Route">
        <path regex="{^/(?P&lt;id&gt;[^/]++)?$}sDu">/{id}</path>
        <defaults>
        <default key="id">5</default>
            <default key="_controller">App\Controller\HomeController</default>
        </defaults>
        <options>
          <option key="compiler_class">Symfony\Component\Routing\RouteCompiler</option>
          <option key="utf8">true</option>
        </options>
    </route>
    XML

    Correct

    • bin/console debug:router home --format xml
      Bash

    The choices were

    • bin/console router:debug home --format xml
      Bash
    • bin/console debug:router home --format xml
      Bash
    • bin/console router:match /1 --format xml
      Bash
    • bin/console router:format home --format xml
      Bash

    Help

    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
    • https://symfony.com/doc/6.0/routing.html#debugging-routes
    bin/console debug:router home --format xmlBash

  • Routing

    How to get information on the route foobar of an application?

    Correct

    • bin/console debug:router foobar
      Shell

    The choices were

    • bin/debug.php foobar
      Shell
    • It is not possible to do this.

    • bin/console router:debug foobar
      Shell
    • bin/check.php foobar
      Shell
    • bin/console debug:router foobar
      Shell

    Help

    • https://symfony.com/doc/current/routing.html#debugging-routes
    bin/console debug:router foobarShell

  • Debugging environment variables

    Which built-in console command can you use to debug the values of environment variables ?

    Correct

    • bin/console debug:dotenv

    The choices were

    • bin/console debug:container --parameters

    • bin/console debug:container --env

    • No built-in command exists to debug environment variables.

    • bin/console debug:dotenv

    Help

    • https://symfony.com/doc/current/configuration.html#listing-environment-variables
    • https://symfony.com/blog/new-in-symfony-5-4-misc-features-part-2#new-command-to-debug-environment-variables
    bin/console debug:dotenv

  • Environment variables debug

    Given the following output, which command can be used to trigger it?

    ---------------- ----------------- ---------------------------------------------
    Name             Default value     Real value
    ---------------- ----------------- ---------------------------------------------
    APP_SECRET       n/a               "471a62e2d601a8952deb186e44186cb3"
    FOO              "[1, "2.5", 3]"   n/a
    BAR              null              n/a
    ---------------- ----------------- ---------------------------------------------
    Bash

    Correct

    • bin/console debug:container --env-vars

    The choices were

    • bin/console debug:container --env-vars

    • bin/console debug:env

    • bin/console debug:container-env

    • None

    • bin/console debug:container --env-vars-debug

    • bin/console debug:container --env-display

    Help

    • https://symfony.com/doc/4.4/configuration.html#listing-environment-variables
    • https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php#L63
    bin/console debug:container --env-vars

  • Accessing Request Data

    What will be returned by the following code when the query string is ?foo=bar?

    $request->query->get('bar', 'baz');

    Correct

    • baz

    The choices were

    • false

    • A Symfony\Component\HttpFoundation\Exception\QueryException will be thrown

    • baz

    • null

    Help

    • http://symfony.com/doc/current/components/http_foundation.html#accessing-request-data
    baz

  • Inheritance

    All the pages of a website must have a common.css stylesheet. In addition, the homepage needs to have an extra stylesheet home.css. How to achieve that ?

    Correct

    • base.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="common.css">
      {% endblock %}    
      {# ... #}
      Twig

      home.html.twig

      {% extends 'base.html.twig' %}
      {% block stylesheet %} {{ parent() }} <link rel="stylesheet" href="home.css"> {% endblock %} {# ... #}
      Twig

    The choices were

    • base.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="common.css">
      {% endblock %}    
      {# ... #}
      Twig

      home.html.twig

      {% extends 'base.html.twig' %}
      {% block stylesheet %} {{ parent_block() }} <link rel="stylesheet" href="home.css"> {% endblock %} {# ... #}
      Twig
    • base.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="common.css">
      {% endblock %}    
      {# ... #}
      Twig

      home.html.twig

      {% extends 'base.html.twig' %}
      {% block stylesheet %} {{ parent('stylesheet') }} <link rel="stylesheet" href="home.css"> {% endblock %} {# ... #}
      Twig
    • base.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="common.css">
      {% endblock %}    
      {# ... #}
      Twig

      home.html.twig

      {% extends 'base.html.twig' %}
      {% block stylesheet %} {{ parent_block('stylesheet') }} <link rel="stylesheet" href="home.css"> {% endblock %} {# ... #}
      Twig
    • base.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="common.css">
      {% endblock %}    
      {# ... #}
      Twig

      home.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="home.css">
      {% endblock %}    
      {# ... #}
      Twig
    • base.html.twig

      <html>
      <head>
      {% block stylesheet %}
          <link rel="stylesheet" href="common.css">
      {% endblock %}    
      {# ... #}
      Twig

      home.html.twig

      {% extends 'base.html.twig' %}
      {% block stylesheet %} {{ parent() }} <link rel="stylesheet" href="home.css"> {% endblock %} {# ... #}
      Twig

    Help

    • https://twig.symfony.com/doc/2.x/tags/extends.html
    base.html.twig <html> <head> {% block stylesheet %} <link rel="stylesheet" href="common.css"> {% endblock %} {# ... #}Twig home.html.twig {% extends 'base.html.twig' %} {% block stylesheet %} {{ parent() }} <link rel="stylesheet" href="home.css"> {% endblock %} {# ... #}Twig

  • Form

    Given the following form configuration:

    $form = $this->createFormBuilder()
          ->add('foo', CheckboxType::class, ['value' => 'bar'])
          ->getForm();

    What will be returned by $form['foo']->getData() when the checkbox is checked and the form submitted ?

    Wrong

    • bar

    The choices were

    • bar

    • false

    • true

    • An exception is thrown

    Help

    • https://symfony.com/doc/2.x/reference/forms/types/form.html
    • https://symfony.com/doc/2.x/reference/forms/types/checkbox.html

  • Password Encoder

    According to the official Symfony Best Practices Guide, which encoder do you need to use for encoding your users' passwords?

    Correct

    • auto

    The choices were

    • mcrypt

    • pbkdf2

    • bcrypt

    • auto

    • plaintext

    • sha512

    Help

    https://symfony.com/doc/4.3/best_practices.html#use-the-auto-password-hasher

    auto

  • Configuration

    According to the official Symfony Best Practices Guide, where do you need to define the infrastructure-related configuration options?

    Correct

    • as environment variables

    The choices were

    • as environment variables

    • config/services.yaml

    • config/parameters.yaml

    • .env

    Help

    https://symfony.com/doc/4.0/best_practices/configuration.html#infrastructure-related-configuration

    as environment variables

  • Array functions

    Which function is used to remove and return the first element of an array?

    Correct

    • array_shift

    The choices were

    • array_grab

    • array_pop

    • array_pull

    • array_shift

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-pop.php
    • https://php.net/manual/fr/function.array-shift.php
    array_shift

  • Array functions

    What line should be added to the cleanArray() function below to ensure this script outputs 1525hello?

    <?php
    function cleanArray($arr) { $functions = [];
    /** line **/
    $ret = $arr;
    foreach ($functions as $func) { $ret = $func($ret); }
    return $ret; }
    $values = [15, '', 0, 25, 'hello', 15];
    foreach (cleanArray($values) as $v) { echo $v; }

    Correct

    • array_push($functions, 'array_filter', 'array_unique');

    The choices were

    • array_push($functions, 'array_reduce');

    • array_push($functions, 'array_filter', 'array_unique');

    • array_pop($functions, 'array_clean');

    • $arr = array_clean($arr);

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-push.php
    • https://php.net/manual/en/function.array-filter.php
    • https://php.net/manual/en/function.array-unique.php
    array_push($functions, 'array_filter', 'array_unique');

  • Array functions

    Which of the following functions compares array1 against array2 and returns the difference by checking array keys in addition?

    Wrong

    • array_diff_key

    The choices were

    • array_diff_key

    • array_diff_ukey

    • array_diff_uassoc

    • array_diff_assoc

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-diff-assoc.php

  • Array functions

    What is the output?

    <?php
    $array1 = ['a' => 20, 30, 35]; $array2 = ['b' => 20, 35, 30]; $array = array_intersect_assoc($array1, $array2); var_dump($array);

    Correct

    • array(0) { }

    The choices were

    • array(1) { ["'a'"]=> int(20)}

    • array(0) { }

    • array(3) { ["'a'"]=> int(20) [0]=> int(30) [1]=> int(35) }

    • An error

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-intersect-assoc.php
    array(0) { }

  • Controllers

    According to the official Symfony Best Practices Guide, which format do you need to use to configure routing, caching and security whenever possible?

    Correct

    • annotations/attributes

    The choices were

    • yaml

    • php

    • annotations/attributes

    • xml

    Help

    http://symfony.com/doc/current/best_practices/controllers.html

    annotations/attributes

  • Twig operator precedence

    In Twig, which of the following operators has the lowest precedence?

    Correct

    • and

    The choices were

    • <=

    • !=

    • ==

    • and

    Help

    https://twig.symfony.com/doc/3.x/templates.html#expressions

    and

  • Operators precedence

    In Twig, which of the following operators has the lowest precedence?

    Wrong

    • and

    The choices were

    • | (filters)

    • and

    • ?: (ternary operator)

    • ==

    • or

    Help

    https://twig.symfony.com/doc/1.x/templates.html#operators


  • Form

    What is returned by the getData() method of PreSubmitEvent ?

    Correct

    • an array

    The choices were

    • an array

    • the norm data of the form

    • the view data of the form

    • The model data of the form

    Help

    • https://symfony.com/doc/4.3/form/events.html
    an array

  • Access Decision Strategies

    What is the default Access Decision Strategy?

    Correct

    • affirmative

    The choices were

    • consensus

    • priority

    • unanimous

    • affirmative

    Help

    • https://symfony.com/doc/current/security/voters.html#changing-the-access-decision-strategy
    affirmative

  • Form Events

    Which method should you use to register a new event listener on a FormBuilder instance?

    Correct

    • addEventListener

    The choices were

    • addListener

    • addEventListener

    • createListener

    • registerListener

    Help

    • http://symfony.com/doc/current/components/form/form_events.html
    addEventListener

  • Array functions

    What is the output ?

    <?php
    $array = ['a1' => 'x', 'a2' => 'e', 'a3' => 'z'];
    asort($array);
    foreach ($array as $keys => $values) { print "$keys = $values"; }

    Correct

    • a2 = e a1 = x a3 = z

    The choices were

    • 0 = e 1 =x 2 = z

    • An error

    • a1 = e a2 = x a3 = z

    • a2 = e a1 = x a3 = z

    Help

    https://www.php.net/manual/fr/function.asort.php

    a2 = e a1 = x a3 = z

  • Form

    How is a DateIntervalType form field rendered when the widget option is set to single_text ?

    Correct

    • a single text field

    The choices were

    • a single text field

    • two html5 date fields

    • a single html5 date field

    • two text fields

    Help

    • https://symfony.com/doc/3.2/reference/forms/types/dateinterval.html
    a single text field

  • FrameworkBundle

    Given the following esi call: render_esi(url('myroute')), which sentences are true ?

    Wrong

    • a path must be specified in the framework.fragments option

    • myroute must exist

    The choices were

    • framework.esi must be enabled

    • myroute must exist

    • a path must be specified in the framework.fragments option

    • "url twig function can't be used with render_esi"

    Help

    • https://symfony.com/doc/2.7/http_cache/esi.html

  • DateTimeType options

    $builder  
        ->add('dt', DateTimeType::class, [
            'html5' => false,
            'date_format' => 'yyyy-MM-dd',
            'format' => 'yyyy-MM-dd h:mm:ss',
            'input_format' => 'Ymd H.i.s'
        ])
        // ...  

    Once the form is submitted, What will be the format of the data passed to the underlying object 'dt' property path (i.e. $form['dt']->getData()) ?

    Correct

    • a datetime instance

    The choices were

    • an Ymd H.i.s formatted date string

    • a datetime instance

    • an yyyy-MM-dd 00:00:00 formatted date string

    • an yyyy-MM-dd h:mm:ss formatted date string

    Help

    • https://symfony.com/doc/4.3/reference/forms/types/datetime.html
    a datetime instance

  • HTTP

    When the server can't return an acceptable response according to an If-Match header, it should return:

    Correct

    • a 412 response code

    The choices were

    • a 422 response code

    • a 418 response code

    • a 406 response code

    • a 412 response code

    Help

    https://www.rfc-editor.org/rfc/rfc9110.html#name-preconditions

    a 412 response code

  • HTTP

    When the server can't return an acceptable response according to the Accept headers, it should return:

    Correct

    • a 406 response code

    The choices were

    • a 418 response code

    • a 406 response code

    • a 415 response code

    • a 412 response code

    Help

    • https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2
    a 406 response code

  • Security

    By default, what is the form field containing the CSRF token?

    Correct

    • _token

    The choices were

    • _token

    • ThisTokenIsNotSoSecretChangeIt

    • _secret

    • _csrf

    Help

    • http://symfony.com/doc/current/security/csrf.html
    • http://symfony.com/doc/current/security/csrf.html#csrf-protection-in-symfony-forms
    _token

  • Form login redirection target.

    By default, what parameter can you use inside the login form to specify the target of the redirection?

    Correct

    • _target_path

    The choices were

    • _default_target

    • _target

    • _target_path

    • _path

    • _path_target

    Help

    • http://symfony.com/doc/current/security/form_login.html#control-the-redirect-url-from-inside-the-form
    _target_path

  • Form

    Given the following form type declaration:

    class MyFormType extends AbstractType
    {
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $builder
                ->add('foo', null)
                ->add('bar', null, ['block_prefix' => 'special_field'])
            ;
        }
    }

    Which of these block names allow to customize these form fields ?

    Wrong

    • _special_field_widget

    • special_field_widget

    The choices were

    • special_field_widget

    • special_field_foo_widget

    • _my_form_foo_widget

    • _special_field_foo_widget

    • _special_field_widget

    • my_form_foo_widget

    Help

    • https://symfony.com/doc/4.3/form/form_themes.html
    • https://symfony.com/doc/4.x/form/form_themes.html#custom-fragment-naming-for-individual-fields

  • Guess locale

    What is the attribute in the definition of a route setting the locale of a user?

    Correct

    • _locale

    The choices were

    • _controller

    • _language

    • _i18N

    • _locale

    Help

    http://symfony.com/doc/3.0/book/routing.html#adding-requirements

    _locale

  • Special Routing Parameters

    Which attributes are reserved special routing parameters?

    Correct

    • _controller

    • _format

    • _locale

    The choices were

    • _type

    • _format

    • _locale

    • _controller

    • _response

    Help

    • https://symfony.com/doc/2.8/routing.html
    _controller _format _locale

  • Basic functions

    Consider the following code snippet:

    $a = 1;
    $b = 0;
    ????
    $c = $a / $b;

    Which statement does the ???? placeholder replace in order to make this program execute without any errors?

    Correct

    • __halt_compiler();
    • die();
    • exit();

    The choices were

    • abort();
    • __halt_compiler();
    • die();
    • quit();
    • exit();

    Help

    • http://www.php.net/manual/en/function.exit.php
    • http://www.php.net/manual/en/function.die.php
    • http://www.php.net/manual/en/function.halt-compiler.php
    __halt_compiler();PHP die();PHP exit();PHP

  • Object Oriented Programming

    Which of the following are valid PHP class names ?

    Correct

    • _MyClass

    • myClass

    The choices were

    • -MyClass

    • myClass

    • _MyClass

    • 123MyClass

    Help

    • https://www.php.net/manual/en/language.oop5.basic.php
    _MyClass myClass

  • Twig advanced customization

    When customizing the twig environment, which of the following class should be used to create a new instanceof test ?

    The expected usage is :

    {% if post is instanceof 'App\Entity\Post' %} ... {% endif %}
    Twig

    Correct

    • \Twig\TwigTest

    The choices were

    • \Twig\TwigFilter

    • \Twig\TwigTest

    • \Twig\TwigFunction

    • No need to customize because it is already built-in.

    • \Twig\Token

    Help

    https://twig.symfony.com/doc/1.x/advanced.html#tests

    \Twig\TwigTest

  • Pluralization interval

    Which of the following are not valid interval notations ?

    Wrong

    • [1,+Inf[

    • {0,10,100,1000,Inf}

    The choices were

    • {0,10,100,1000,Inf}

    • ]-Inf,Inf[

    • ]1,Inf[

    • ]Inf, 0]

    • [1,+Inf[

    Help

    • https://symfony.com/doc/3.4/components/translation/usage.html#explicit-interval-pluralization
    • https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals

  • Filter raw data

    Which of the following $options allow a Twig_Filter decide how to escape data by itself?

    Wrong

    • ['is_safe']

    The choices were

    • ['is_safe' => ['html']]
    • ['is_safe' => 'html']
    • ['is_safe']
    • ['is_safe' => true]

    Help

    https://twig.symfony.com/doc/2.x/advanced.html#automatic-escaping


  • Filter raw data

    Which of the following $options allow a Twig_Filter decide how to escape data by itself?

    Wrong

    • ['is_safe' => true]

    The choices were

    • ['is_safe' => 'html']
    • ['is_safe' => ['html']]
    • ['is_safe' => true]
    • ['is_safe']

    Help

    https://twig.symfony.com/doc/2.x/advanced.html#automatic-escaping


  • Array functions

    Given the $info array defined below, what is the best way to assign the first value to a variable called $name and the third value to a variable called $country?

    <?php
    $info = [ 'Paul', 31, 'Australia' ];

    Wrong

    • [$name, $age, $country] = $info;

    The choices were

    • [$name, , $country] = $info;

    • array_list($name, $age, $country) = $info;

    • [$name, $age, $country] = $info;

    • [$name, $country] = $info;

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.list.php

  • Query String

    Regarding this URI : /example?tags.id=2

    What will be the content of $request->query->all() ?

    Wrong

    • [ 
          'tags' => ['id' => 2] 
      ]
      

    The choices were

    • [ 
          'tags' => ['id' => 2] 
      ]
      
    • [ 
          'tags.id' => 2 
      ]
      
    • [ 
          'tags_id' => 2 
      ]
      

    Help

    • http://www.php.net/manual/en/language.variables.basics.php
    • http://www.php.net/manual/en/language.variables.external.php

  • Managing status code of controllers made using the TemplateController

    The Symfony\Bundle\FrameworkBundle\Controller\TemplateController can be used to render a template without the need to create a dedicated controller. How can you specify the HTTP status code of the response issued by those controllers ?

    Correct

    • You can use the statusCode option in the route definition like the following :

      # config/routes.yaml
      upload_started:
          path: /upload_started.html
          controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
          defaults:
              template:  'file_upload/started.html.twig'
              statusCode: 202 # HTTP Status = Accepted
      YAML

    The choices were

    • You can use the special {_code} route parameter like the following :

      # config/routes.yaml
      upload_started:
          path: /{_code}/upload_started.html
          controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
          defaults:
              template:  'file_upload/started.html.twig'
      YAML
    • You can use the statusCode option in the route definition like the following :

      # config/routes.yaml
      upload_started:
          path: /upload_started.html
          controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
          defaults:
              template:  'file_upload/started.html.twig'
              statusCode: 202 # HTTP Status = Accepted
      YAML
    • You can't.

    Help

    https://symfony.com/doc/current/templates.html#rendering-a-template-directly-from-a-route https://symfony.com/blog/new-in-symfony-5-4-misc-features-part-2#configurable-status-code-in-templates-rendered-from-routes

    You can use the statusCode option in the route definition like the following : # config/routes.yaml upload_started: path: /upload_started.html controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController defaults: template: 'file_upload/started.html.twig' statusCode: 202 # HTTP Status = AcceptedYAML

  • PHP Interfaces

    Can a class implement multiple interfaces ?

    Correct

    • Yes.

    The choices were

    • No.

    • Yes.

    Help

    • https://www.php.net/manual/en/language.oop5.interfaces.php
    Yes.

  • Event

    From an Event instance, is it possible to get the EventDispatcher instance that dispatched this event?

    Wrong

    • Yes.

    The choices were

    • No.

    • Yes.

    Help

    Since 3.0 the event dispatcher is passed to the listener call. http://symfony.com/doc/current/components/event_dispatcher.html#event-name-introspection


  • Debug translation

    It is possible to find missing or unused translation messages from templates?

    Correct

    • Yes, with the debug:translation command

    The choices were

    • Yes, with the debug:translate command

    • Yes, with the debug:translator command

    • Yes, with the debug:i18n command

    • Yes, with the debug:translation command

    • No, it is not possible.

    Help

    https://symfony.com/doc/2.7/translation/debug.html

    Yes, with the debug:translation command

  • POSIX Signal

    When you are running a program asynchronously, it is possible to send it POSIX signals ?

    Correct

    • Yes, with the Symfony\Component\Process\Process::signal method

    The choices were

    • Yes, with the Symfony\Component\Process\Process::signal method

    • No, it's not possible.

    • Yes, with the Symfony\Component\Process\Process::sendSignal method

    • Yes, with the Symfony\Component\Process\Process::send method

    Help

    • https://symfony.com/doc/2.3/components/process.html#process-signals
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Process/Process.php#L347
    Yes, with the Symfony\Component\Process\Process::signal method

  • CollectionType usage

    Could empty CollectionType entries be removed?

    Correct

    • Yes, using delete_empty option

    The choices were

    • Yes, using resize_when_empty option

    • The CollectionType automatically resize itself

    • It's not possible

    • Yes, using delete_empty option

    • Yes, using remove_empty option

    Help

    https://symfony.com/doc/2.5/reference/forms/types/collection.html#delete-empty

    Yes, using delete_empty option

  • Autowiring (interfaces)

    Is it possible to autowire the following service?

    Let's assume that HtmlTransformer implements TransformerInterface:

    services:
        transformer_html:
            class:    Acme\HtmlTransformer
        twitter_client:
            class:    Acme\TwitterClient
            autowire: true
    YAML
    class TwitterClient
    {
        private $transformer;
    public function __construct(TransformerInterface $transformer) { $this->transformer = $transformer; }
    public function tweet($user, $key, $status) { $transformedStatus = $this->transformer->transform($status);
    // ... connect to Twitter and send the encoded status } }

    Correct

    • Yes, the autowiring mechanism is smart enough to detect a service definition which implements the TransformerInterface

    The choices were

    • No, the autowiring mechanism doesn't work with interfaces

    • Yes, the autowiring mechanism is smart enough to detect a service definition which implements the TransformerInterface

    Help

    https://symfony.com/doc/current/components/dependency_injection/autowiring.html#working-with-interfaces

    Yes, the autowiring mechanism is smart enough to detect a service definition which implements the TransformerInterface

  • Constants

    Is it possible to use a constant in a parameter?

    Correct

    • Yes, in PHP

    • Yes, in the YAML format (thanks to the expression language component)

    • Yes in XML format

    The choices were

    • Yes in XML format

    • Yes, in PHP

    • No

    • Yes, in the YAML format (thanks to the expression language component)

    Help

    https://symfony.com/doc/2.7/service_container/parameters.html#constants-as-parameters

    Yes, in PHP Yes, in the YAML format (thanks to the expression language component) Yes in XML format

  • Twig template

    Does this syntax perform any check?

    {{ foo['bar'] }}
    Twig

    Wrong

    • Yes, if foo is an object then if it's an array

    The choices were

    • No

    • Yes if foo is an array

    • Yes, if foo is an object then if it's an array

    Help

    https://twig.symfony.com/doc/1.x/templates.html#variables


  • PSR-18 usage

    It is possible to use PSR-18 for your requests?

    Correct

    • Yes, by using Symfony\Component\HttpClient\Psr18Client

    The choices were

    • Yes, by using Symfony\Component\HttpClient\Psr18Client

    • No

    Help

    • https://symfony.com/doc/5.0/http_client.html#psr-18-and-psr-17
    • https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/HttpClient/Psr18Client.php
    Yes, by using Symfony\Component\HttpClient\Psr18Client

  • Testing

    Is it possible to simulate an HTTP request without mocking the HttpClient thanks to createMock() from PHPUnit?

    Correct

    • Yes, by using Symfony\Component\HttpClient\MockHttpClient

    The choices were

    • Yes, by using Symfony\Component\HttpClient\MockHttpClient

    • No

    Help

    • https://symfony.com/doc/current/components/http_client.html#testing-http-clients-and-responses
    • https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpClient/MockHttpClient.php
    Yes, by using Symfony\Component\HttpClient\MockHttpClient

  • Default user provider.

    When using several user providers in your application, is it mandatory to define the provider key on your firewall(s) configuration ?

    Correct

    • Yes, but it is not mandatory when there is only one provider.

    The choices were

    • No, if the value is not set, the first defined provider will be used.

    • Yes, if the value is not set on one of the firewalls, an error will be thrown.

    • Yes, but it is not mandatory when there is only one provider.

    • No, if the value is not set, the last defined provider will be used.

    Help

    • https://symfony.com/doc/4.0/security/multiple_user_providers.html
    • https://github.com/symfony/symfony/blob/v4.0.0/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L246
    Yes, but it is not mandatory when there is only one provider.

  • Autowiring

    Will Autowiring automatically inject dependencies of an autowired service?

    Wrong

    • Yes, autowiring will find and register all dependencies

    The choices were

    • Yes, autowiring will find and register all dependencies

    • Yes, if dependencies are explicitly declared as autowired or manually configured.

    • No

    Help

    https://symfony.com/doc/2.8/service_container/autowiring.html


  • Stubs

    When creating stub is it possible to disable the call to the original class constructor?

    Correct

    • Yes with the disableOriginalConstructor() method.

    The choices were

    • No

    • Yes with the disableOriginalConstruct() method.

    • Yes with the disableOriginalConstructor() method.

    • Yes with the disableConstruct() method.

    • Yes with the disableConstructor() method.

    Help

    https://phpunit.de/manual/5.7/en/test-doubles.html#test-doubles.stubs

    Yes with the disableOriginalConstructor() method.

  • ImmutableEventDispatcher usage

    Could an event be dispatched from the ImmutableEventDispatcher?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    Yes

  • TemplateController usage

    Could a status code be defined when rendering a template using TemplateController?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-misc-features-part-2#configurable-status-code-in-templates-rendered-from-routes
    • https://github.com/symfony/symfony/pull/41414
    Yes

  • Validator cache

    Could the cache service used to store validation metadata be overridden?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.3/reference/configuration/framework.html#validation

    Yes

  • Closure execution

    Could a Closure be executed?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/Runtime/Runner/ClosureRunner.php

    Yes

  • Expressions evaluation

    Could the parsed and/or serialized expressions be evaluated?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.4/components/expression_language/caching.html#using-parsed-and-serialized-expressions

    Yes

  • Moved permanently usage

    Should a Location header be set in a response that use the 301 status code?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301
    Yes

  • Event aliases

    Is the following code valid?

    <?php
    namespace App;
    use App\Event\MyCustomEvent; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass; use Symfony\Component\HttpKernel\Kernel as BaseKernel;
    class Kernel extends BaseKernel { protected function build(ContainerBuilder $container) { $container->addCompilerPass(new AddEventAliasesPass([ MyCustomEvent::class => 'my_custom_event', ])); } }

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/event_dispatcher.html#event-aliases

    Yes

  • ImmutableEventDispatcher usage

    Could the existence of an event listener be checked from within the ImmutableEventDispatcher?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    Yes

  • ExpressionLanguage usage

    Could an Expression be created from within a template?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.4/reference/twig_reference.html#functions

    Yes

  • Event aliases

    Could the alias of an event be changed?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/event_dispatcher.html#event-aliases

    Yes

  • Render the rest of the fields

    Is there a way to make sure that the {{ form_end(form) }} does not render all the fields not rendered?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://symfony.com/doc/current/reference/forms/twig_reference.html#form-end-view-variables
    Yes

  • Number constraint

    Is it possible to check that a number is positive?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.3/reference/constraints/Positive.html

    Yes

  • Middleware usage

    Could the default middleware list be disabled?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.1/messenger.html#disabling-default-middleware

    Yes

  • Variables

    Is it possible to pass PHP objects to a Twig template?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://twig.symfony.com/doc/templates.html#variables
    Yes

  • Translation

    Is it possible to activate an option to log missing translations?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://symfony.com/doc/current/reference/configuration/framework.html#logging
    Yes

  • Worker informations

    Could information like the transport name and so on can be retrieved from the worker?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-messenger-improvements#worker-metadata
    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Messenger/WorkerMetadata.php
    Yes

  • Groups sequence

    Is the following code valid?

    <?php
    namespace App\Entity;
    use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Validator\Constraints as Assert;
    #[Assert\GroupSequence(['User', 'Strict'])] class User implements UserInterface { #[Assert\NotBlank] private $username;
    #[Assert\NotBlank] private $password;
    #[Assert\IsTrue( message: 'The password cannot match your username', groups: ['Strict'], )] public function isPasswordSafe(): bool { return ($this->username !== $this->password); }
    // ... }

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/5.2/validation/sequence_provider.html
    • https://github.com/symfony/symfony/tree/5.2/src/Symfony/Component/Validator/Constraints
    Yes

  • Multiple buses

    Can you have multiple buses in a single application?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/messenger/multiple_buses.html

    Yes

  • Attributes usage

    Should attributes be used to define entities mapping?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.4/best_practices.html#use-attributes-to-define-the-doctrine-entity-mapping

    Yes

  • Container dump

    Could the container be dumped into a single file?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/4.4/performance.html#dump-the-service-container-into-a-single-file
    • https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L117
    Yes

  • Writing to Arrays

    Is it possible to set values of an array with a PropertyAccessor?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://symfony.com/doc/current/components/property_access/introduction.html#writing-to-arrays
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L142
    Yes

  • Immutable response

    Given the context where a file (called react.0.0.0.js and incremented each time the file is updated) is available via https://example.com/react.0.0.0.js, could an immutable cache-control header be applied to it without encountering any cache issues?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://datatracker.ietf.org/doc/html/rfc8246
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
    Yes

  • ParameterBag usage

    Could a ParameterBag be frozen?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php

    Yes

  • Configuration files import

    Is the following code valid?

    # config/services.yaml
    imports:
      - { resource: 'my_config_file.xml', ignore_errors: not_found }
    # ...
    YAML

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php#L48
    • https://symfony.com/doc/4.4/configuration.html#importing-configuration-files
    Yes

  • Secrets usage

    Should secrets be used to store sensitive configuration values (like an API key)?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/best_practices.html#use-secret-for-sensitive-information

    Yes

  • Interoperability

    Can I use Twig without using Symfony?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://twig.symfony.com/
    • https://github.com/twigphp/Twig
    Yes

  • Enumerations usage

    Could enumerations be used with !php/const?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/pull/40857

    Yes

  • Loading routes

    Is it possible to load routes from a file?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    http://symfony.com/doc/3.0/components/routing/introduction.html#load-routes-from-a-file

    Yes

  • Synthetic services

    Could synthetic services be injected into other services?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.7/service_container/synthetic_services.html

    Yes

  • Stateless route

    Could the usage of the session be deactivated per route?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.1/routing.html#stateless-routes

    Yes

  • FlashBag usage

    Could a FlashBag be cleared?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php

    Yes

  • LanguageType

    Could the choices of LanguageType be overridden?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.0/reference/forms/types/language.html#choices

    Yes

  • Safe usage

    Is the following code valid when using the safe directive?

    GET /foo.html HTTP/1.1
    Host: www.example.org
    User-Agent: ExampleBrowser/1.0
    Prefer: safe
    Plain text

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://datatracker.ietf.org/doc/html/rfc8674#section-2

    Yes

  • Parsing

    Is the following code valid?

    <?php
    use Symfony\Component\Yaml\Yaml;
    $value = Yaml::parse(file_get_contents('/path/to/file.yml'));

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://symfony.com/doc/current/components/yaml/introduction.html#reading-yaml-files
    Yes

  • EventListener registration

    Could an event listener be registered while using the __invoke() method to listen to an event?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.1/event_dispatcher.html#creating-an-event-listener

    Yes

  • PHP - Create an instance

    Does the following code valid ?

    <?php
    class ClassA extends \stdClass {} class ClassB extends \stdClass {} class ClassC extends ClassB {} class ClassD extends ClassA {}
    function getSomeClass(): string { return 'ClassA'; }
    var_dump(new (getSomeClass())); var_dump(new ('Class' . 'B')); var_dump(new ('Class' . 'C')); var_dump(new (ClassD::class));

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://www.php.net/manual/en/language.oop5.basic.php
    • https://3v4l.org/pILGT#v8.0.0
    Yes

  • Twig

    Is the following extends tag valid ?

    {% extends ['layout1.html.twig', 'layout2.html.twig'] %}

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://twig.symfony.com/doc/1.x/tags/extends.html#dynamic-inheritance

    Yes

  • Mirror usage

    When using mirror(...), could files that are not present in the source directory be deleted?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.2/components/filesystem.html#mirror
    • https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/Filesystem/Filesystem.php#L338
    Yes

  • Auto_alias usage

    Is the following code valid?

    <?php
    use AppBundle\Lock\MysqlLock; use AppBundle\Lock\PostgresqlLock; use AppBundle\Lock\SqliteLock;
    // Given $container is an instance of ContainerBuilder
    $container->register('app.mysql_lock', MysqlLock::class)->setPublic(false); $container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false); $container->register('app.sqlite_lock', SqliteLock::class)->setPublic(false);
    $container->register('app.lock')->addTag('auto_alias', [ 'format' => 'app.%database_type%_lock', ]);

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.7/reference/dic_tags.html#auto-alias
    • https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/DependencyInjection/Compiler/AutoAliasServicePass.php
    Yes

  • Safe method

    Could a cache performance optimization (such as pre-fetching) be used with a safe method?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://tools.ietf.org/html/rfc7231#section-4.2.1

    Yes

  • Route lifecycle

    Could a route be aliased?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-route-aliasing
    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Routing/Alias.php
    Yes

  • Color constraint

    Could a RGB color be validated?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-new-validation-constraints#csscolor-validator
    • https://symfony.com/doc/5.4/reference/constraints/CssColor.html
    • https://github.com/symfony/symfony/pull/40168
    Yes

  • Customization

    Could the destination of the dump be customized?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.1/components/var_dumper.html#the-dump-server

    Yes

  • Number constraint

    Is it possible to check that a number is positive or equal to zero?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.3/reference/constraints/PositiveOrZero.html

    Yes

  • ContainerBuilder usage

    Could the number of time each environment variables has been resolved be obtained when using ContainerBuilder?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L1077

    Yes

  • Services preload

    Could a class be added into the list of preloaded classes by PHP?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.1/reference/dic_tags.html#container-preload

    Yes

  • Immutable response

    Could an immutable cache-control header be used with max-age?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://datatracker.ietf.org/doc/html/rfc8246
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
    Yes

  • Customization

    Could the theme used by HtmlDumper be changed?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/4.2/components/var_dumper/advanced.html#dumpers
    • https://github.com/symfony/symfony/blob/4.2/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L97
    Yes

  • Location header

    Does a response using the 308 status code should contain a Location header?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://tools.ietf.org/html/rfc7538#section-3

    Yes

  • Session usage

    Could the session be migrated?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/HttpFoundation/Session/Session.php#L171

    Yes

  • RequestMatcher usage

    Could a custom request matcher be created?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/HttpFoundation/RequestMatcherInterface.php

    Yes

  • RequestStack usage

    Could the parent request be retrieved from the request stack?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/HttpFoundation/RequestStack.php

    Yes

  • Events debug

    Is the following code valid?

    php bin/console debug:event-dispatcher Security
    Bash

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.3/event_dispatcher.html#debugging-event-listeners

    Yes

  • Validation Groups

    If a User class extends a BaseUser class, and the applied validation group is User. Will the constraints present in the BaseUser class be applied ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/current/validation/sequence_provider.html
    • https://symfony.com/doc/current/validation/groups.html
    Yes

  • Fragment renderer

    Could a custom fragment renderer strategy be created?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.2/reference/dic_tags.html#kernel-fragment-renderer
    • https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php
    Yes

  • Server-sent events

    Could you consume server-sent events?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.2/http_client.html#consuming-server-sent-events

    Yes

  • Custom tags parsing

    Is the following code valid?

    <?php
    // ...
    $parsed = Yaml::parse("!custom_tag { foo: bar }", Yaml::PARSE_CUSTOM_TAGS);

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/3.4/components/yaml.html#parsing-and-dumping-custom-tags
    • https://github.com/symfony/symfony/blob/3.3/src/Symfony/Component/Yaml/Yaml.php#L32
    Yes

  • Events debug

    Is the following code valid?

    php bin/console debug:event-dispatcher kernel
    Bash

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.3/event_dispatcher.html#debugging-event-listeners

    Yes

  • Environment variables override

    Is it possible to define environment variables only for the test environment?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-options

    Yes

  • Stale response

    Could a stale response be marked as reusable when an origin server responds with and error (500, 502, 503 or 504)?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://datatracker.ietf.org/doc/html/rfc5861#section-4
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
    Yes

  • Environment variables usage

    Is the following code valid?

    # config/packages/framework.yaml
    framework:
      router:
        http_port: '%env(int:HTTP_PORT)%'
    YAML

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.2/configuration/env_var_processors.html

    Yes

  • Locale

    Is it possible to change directly the locale of a Request from an URL?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://symfony.com/doc/current/book/routing.html#adding-requirements
    Yes

  • Escaping

    Can we create a custom escaper for Twig ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://twig.symfony.com/doc/1.x/filters/escape.html#custom-escapers

    Yes

  • Symfony Vault

    Should the Symfony secret vault be used in a critical production environment?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.4/configuration/secrets.html

    Yes

  • Cache usage in templates

    Is the following code valid?

    {% cache '_foo_template' %}
        Cached forever (depending on the cache implementation)
    {% endcache %}
    Twig

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://twig.symfony.com/doc/3.x/tags/cache.html

    Yes

  • ImmutableEventDispatcher usage

    Could the event listeners related to an event be retrieved from the ImmutableEventDispatcher?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    Yes

  • Custom request matcher usage

    Is the following code valid?

    # config/packages/security.yaml
    security:
    # ...
    firewalls: secured_area: request_matcher: app.firewall.secured_area.request_matcher
    # ...
    YAML

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.2/security/firewall_restriction.html#restricting-by-service

    Yes

  • Container preloading

    Could the container be preloaded using Opcache preloading?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/performance.html#use-the-opcache-class-preloading

    Yes

  • Definition visibility

    When creating a service definition using PHP, could the visibility of the service be changed using Symfony\Component\DependencyInjection\Definition::setPublic($boolean) ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/DependencyInjection/Definition.php#L527

    Yes

  • Configuration

    Is it possible to set the path used to load the .env files?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-options

    Yes

  • Method forwards

    Could the number of forwards be limited in a TRACE or OPTIONS request?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://tools.ietf.org/html/rfc7231#section-5.1.2

    Yes

  • Signals

    Could a command listen to signals?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.3/components/console/events.html#the-consoleevents-signal-event

    Yes

  • Extract usage

    Could existing variables be overwritten when using extract?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://www.php.net/manual/en/function.extract.php

    Yes

  • Controller

    Is it possible to pass a Response instance to the Symfony\Bundle\FrameworkBundle\Controller\Controller::render() method?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://github.com/symfony/symfony/blob/3.1/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php#L209
    Yes

  • Symfony internal events

    Could the FQCN of a Symfony built-in event be used to subscribe / listen to it?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.4/event_dispatcher.html#event-aliases

    Yes

  • Fields priority

    Could fields be sorted using a priority?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • Since 5.3, the priority option can be used to sort fields.
    • https://symfony.com/blog/new-in-symfony-5-3-form-field-sorting
    • https://github.com/symfony/symfony/pull/40690
    Yes

  • Signals handling

    Is it possible to listen signals and stop command according to them?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/blog/new-in-symfony-5-2-console-signals

    Yes

  • RequestContext configuration

    Could the scheme used by the RequestContext be overridden via a parameter?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/2.2/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml#L27
    • https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/Routing/RequestContext.php#L76
    Yes

  • Serializer customization

    Could the default serializer be changed?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-serializer-improvements#custom-serializer-for-symfony-messenger
    • https://github.com/symfony/symfony/pull/42257
    Yes

  • Extract usage

    Could variables be extracted as references when using extract?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://www.php.net/manual/en/function.extract.php

    Yes

  • JSONP usage

    Could a JSONP callback be set?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://en.wikipedia.org/wiki/JSONP
    • https://symfony.com/doc/2.1/components/http_foundation/introduction.html#jsonp-callback
    • https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/HttpFoundation/JsonResponse.php
    Yes

  • Environment variables usage

    Is the following code valid?

    # config/packages/framework.yaml
    parameters:
      env(AUTH_FILE): '../config/auth.json'
    google: auth: '%env(file:AUTH_FILE)%'
    YAML

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.2/configuration/env_var_processors.html#built-in-environment-variable-processors

    Yes

  • Compiler Passes

    Could a priority be set when adding a new compiler pass?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/4.1/components/dependency_injection/compilation.html#controlling-the-pass-ordering
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php#L113
    Yes

  • CIDR validation

    Could a CIDR notation be validated?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-new-validation-constraints#cidr-validator
    • https://symfony.com/doc/5.4/reference/constraints/Cidr.html
    • https://github.com/symfony/symfony/pull/43593
    Yes

  • Must-understand fallback

    Should the must-understand directive be coupled with no-store for fallback behavior?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives

    Yes

  • Moved permanently usage

    Could a response that use the 301 status code be cached?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301
    Yes

  • Functional Tests

    According to the official Symfony Best Practices Guide, is it useful to spend time and effort writing tests that check if your application pages are successfully loading?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/current/best_practices.html#tests
    Yes

  • HTTP headers value

    Are the "HTTP-date" directives considered as case-sensitive?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.1

    Yes

  • Question usage

    Could a response to a question be hidden?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.5/components/console/helpers/questionhelper.html#hiding-the-user-s-response

    Yes

  • Expires usage

    Is the following header value valid?

    Expires: Sun, 06 Nov 1994 08:49:37 GMT
    Plain text

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc7234#section-5.3
    • https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.1
    • https://developer.mozilla.org/en/docs/Web/HTTP/Headers/Expires
    Yes

  • Command usage

    Could Command be used as a concrete class without defining the execute method?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Command/Command.php#L145
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Command/Command.php#L194
    Yes

  • Asset package

    Could an custom asset package be added?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/reference/dic_tags.html#assets-package

    Yes

  • Interfaces

    Can interfaces define constants in PHP?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://php.net/interfaces
    Yes

  • Options deprecation by-pass

    Is it possible to bypass a deprecation message triggered by the use of a deprecated option?

    Correct

    • Yes

    The choices were

    • Only when running tests

    • Yes

    • No

    Help

    https://symfony.com/doc/current/components/options_resolver.html#deprecating-the-option

    Yes

  • Extract usage

    Could extracted variables be prefixed when using extract?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://www.php.net/manual/en/function.extract.php

    Yes

  • ContainerConfigurator usage

    Could a closure be defined as a service reference using ContainerConfigurator?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/dependency-injection/blob/5.4/Loader/Configurator/ContainerConfigurator.php#L206

    Yes

  • Configuration

    Is it possible to define environment variables only for the prod environment?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-options

    Yes

  • 511 authentication

    Should a response using the 511 status code contains a link to a resource that allows the client to authenticate itself?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://datatracker.ietf.org/doc/html/rfc6585#section-6
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511
    Yes

  • Security events debug

    Is the following code valid?

    php bin/console debug:event-dispatcher --dispatcher=security.event_dispatcher.main
    Bash

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/event_dispatcher.html#debugging-event-listeners

    Yes

  • Process timeout

    Is it possible to limit the amount of time a process takes to complete?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://symfony.com/doc/current/components/process.html#process-timeout
    Yes

  • FlashBag usage

    Could the FlashBag messages be retrieving while being removed from the bag?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/fc0a09a2052e9275c16b5ab7af426935fe432f39/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php#L162

    Yes

  • Abstract services

    Should a parent service be declared as abstract if no class is set in its service definition?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.7/service_container/parent_services.html

    Yes

  • Response

    Could you emulate chunked responses and/or timeouts in mocked responses?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.2/http_client.html#testing-http-clients-and-responses

    Yes

  • Immutable directive

    Should a resource marked as immutable be validated again when considered stale?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc8246
    • https://datatracker.ietf.org/doc/html/rfc8246#section-2
    Yes

  • HttpFoundation integration

    Is the following code valid?

    use Symfony\Component\HttpFoundation\Response;
    require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
    return function (): Response { return new Response('Hello world'); };

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-the-runtime

    Yes

  • Assets usage

    Could an exception be thrown in case of a missing asset?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-misc-features-part-1#strict-mode-for-missing-assets
    • https://github.com/symfony/symfony/pull/38495
    Yes

  • TraceableEventDispatcher usage

    Could the non-called listeners be retrieved per event when using the TraceableEventDispatcher?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.5/components/event_dispatcher/traceable_dispatcher.html
    • https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
    Yes

  • Finder usage

    Is there any way to check if the Finder contains any results?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Finder/Finder.php#L618

    Yes

  • Autowiring

    Will the following autowiring declaration work?

    services:
        rot13:
            class:    Acme\Transformer\Rot13Transformer
            arguments: [true]
    rot13_2: class: Acme\Transformer\Rot13Transformer arguments: [false]
    twitter_client: class: Acme\TwitterClient autowire: true
    YAML
    namespace Acme;
    use Acme\Transformer\Rot13Transformer;
    class TwitterClient { private $transformer;
    public function __construct(Rot13Transformer $transformer) { $this->transformer = $transformer; }
    public function tweet($user, $key, $status) { $transformedStatus = $this->transformer->transform($status);
    // ... connect to Twitter and send the encoded status } }

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/components/dependency_injection/autowiring.html


  • Constraints debug

    Could the constraints of a class be listed?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.2/validation.html#debugging-the-constraints

    Yes

  • Synthetic services

    Is the following code valid when registering a synthetic service?

    // config/services.php
    namespace Symfony\Component\DependencyInjection\Loader\Configurator;
    return function(ContainerConfigurator $configurator) { $services = $configurator->services();
    $services->set('app.synthetic_service') ->synthetic(); };

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.0/service_container/synthetic_services.html

    Yes

  • new Authenticator-Based Security

    In the Authenticator-Based Security, Is it possible to create a custom entry_point ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.1/security/experimental_authenticators.html#configuring-the-authentication-entry-point

    Yes

  • PSR-7 usage

    Is the following code valid?

    <?php
    // ...
    use Psr\Http\Message\RequestInterface;
    class HomeController { #[Route('/', name: 'home')] public function __invoke(RequestInterface $session): Response { // ... } }

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/3.0/Request/ParamConverter/PsrServerRequestParamConverter.php

    Yes

  • Mirror usage

    Is the following code valid?

    <?php
    # ...
    $fs = new Filesystem(); $fs->mirror('/srv/app', '/srv/bar', null, ['copy_on_windows' => true]);

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.1/components/filesystem.html#mirror
    • https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/Filesystem/Filesystem.php#L338
    Yes

  • Cursor usage

    Could the Cursor be hidden?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.2/components/console/helpers/cursor.html#using-the-cursor

    Yes

  • AbstractSessionListener usage

    Could the AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER header directive be used on sub-requests?

    Wrong

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/4.1/http_cache.html#http-caching-and-user-sessions
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php#L68

  • FlashBag service usage

    Could the session.flash_bag service be used?

    Wrong

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/5.4/UPGRADE-6.0.md#frameworkbundle


  • Security events debug

    Could the listeners be debugged per firewall?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/event_dispatcher.html#debugging-event-listeners

    Yes

  • Check_path

    When configuring the main firewall of an application, could its check_path route be covered by another firewall ?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    http://symfony.com/doc/current/reference/configuration/security.html#check-path


  • Form Handling

    Can this form (with default configuration) be submitted ?

    class FooController extends AbstractController
    {
        #[Route('/foo', name: 'foo', methods: ['GET'])]
        public function foo(Request $request)
        {
            $form = $this->createForm(FooType::class);
            $form->handleRequest($request);
    if ($form->isSubmitted() && $form->isValid()) { // ... } } }

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/current/forms.html#rendering-forms

  • Decorating services

    Could the priority of a decorating service be defined?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.8/service_container/service_decoration.html#decoration-priority

    Yes

  • Handlers

    Could HttpKernelRunner handle terminable kernel?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/Runtime/Runner/Symfony/HttpKernelRunner.php
    Yes

  • Usage

    Can an Email instance be serialized?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/4.3/components/mime.html#serializing-email-messages
    Yes

  • Serialization Context

    Is it possible to specify the serialization context in an attribute/annotation?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/blog/new-in-symfony-5-3-inlined-serialization-context

    Yes

  • Configuration

    Could the ConsoleApplicationRunner be executed without setting an environment?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/Runtime/Runner/Symfony/ConsoleApplicationRunner.php

    Yes

  • ContainerConfigurator usage

    Could an Expression be configured using ContainerConfigurator?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/dependency-injection/blob/3.4/Loader/Configurator/ContainerConfigurator.php#L125

    Yes

  • Fields mapping

    Could values be mapped to fields using callbacks?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.2/form/data_mappers.html#mapping-form-fields-using-callbacks

    Yes

  • Container configuration

    Given the context where the container build time must be configured, is the following code valid?

    # app/config/services.yml
    parameters:
        # ...
        kernel.container_build_time: '1645176920'
    # ...
    YAML

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/3.4/reference/configuration/kernel.html#container-build-time

    Yes

  • Parser configuration

    Could the parser cache be changed?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.4/components/expression_language/caching.html#the-workflow

    Yes

  • Firewall

    Is it possible to have more than one firewall in your application?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.3/reference/configuration/security.html

    Yes

  • If-Match usage

    Could the If-Match etag be transformed to a weak one?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match#syntax
    Yes

  • Environment configuration

    Could templates be configured to exclusively use yield instead of echo?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/twigphp/Twig/blob/v3.9.0/src/Environment.php#L104

    Yes

  • Security usage

    Could the current token be retrieved from Symfony\Component\Security\Core\Security?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/3.4/security.html#securing-other-services
    • https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Security/Core/Security.php
    Yes

  • Performances improvement

    Could normalizers / denormalizers be cached to improve performances?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/4.1/components/serializer.html#performance
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/Serializer/Normalizer/CacheableSupportsMethodInterface.php
    Yes

  • Environment variables usage

    Is the following code valid?

    # config/services.yaml
    parameters:
      env(SECRETS_FILE): '/opt/application/.secrets.json'
      database_password: '%env(key:database_password:json:file:SECRETS_FILE)%'
    YAML

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.2/configuration/env_var_processors.html#built-in-environment-variable-processors

    Yes

  • Session

    Can PHP sessions work without cookies?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://www.php.net/manual/en/session.idpassing.php
    Yes

  • AST usage

    Could the AST be dumped?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/3.2/components/expression_language/ast.html#dumping-the-ast

    Yes

  • new Authenticator-based Security

    is the following code valid :

    # config/packages/security.yaml
    security:
        enable_authenticator_manager: true
    # ... firewalls: main: # allow authentication using a form or HTTP basic form_login: ~ http_basic: ~
    # App\Security\CustomEntryPoint is a custom entry point implementing Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface entry_point: App\Security\CustomEntryPoint
    YAML

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/current/security/authenticator_manager.html#configuring-the-authentication-entry-point

    Yes

  • format_datetime usage

    When using format_datetime(), could the calendar be changed?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://twig.symfony.com/doc/2.x/filters/format_datetime.html
    • https://twig.symfony.com/doc/2.x/filters/format_datetime.html#arguments
    Yes

  • Default value

    Is it possible to define default values that depend on another option?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://symfony.com/doc/current/components/options_resolver.html#default-values-that-depend-on-another-option
    Yes

  • Public service

    Is it possible to create a service that is not publicly accessible?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.8/service_container/alias_private.html#marking-services-as-public-private

    Yes

  • Cache requirements

    Could a resource be stored only if the cache understand the requirements to store the response?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives

    Yes

  • Multiple transports

    Can you configure multiple transports to ensure that emails are sent even if one mailer server fails?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/6.0/mailer#high-availability

    Yes

  • TraceableEventDispatcher usage

    Could the called listeners be retrieved per event when using the TraceableEventDispatcher?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.5/components/event_dispatcher/traceable_dispatcher.html
    • https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
    Yes

  • LanguageType

    Is setting the choice_loader to null required when overriding the choices of LanguageType?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/3.3/reference/forms/types/language.html#choices

    Yes

  • ParameterBag usage

    Is the following code valid?

    <?php
    use Symfony\Component\DependencyInjection\ParameterBag;
    $bag = new ParameterBag(); $bag->append('foo', 'bar');

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php


  • RequestStack usage

    Given the context where a single request is stored in the RequestStack, could the current request be removed from the request stack?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/HttpFoundation/RequestStack.php

    Yes

  • Route attributes

    It is possible to specify a default value for an attribute in a route?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://symfony.com/doc/current/create_framework/routing.html
    • http://symfony.com/doc/current/routing.html#giving-placeholders-a-default-value
    Yes

  • Use usage

    Could multiple use be used in a single template?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://twig.symfony.com/doc/1.x/tags/use.html

    Yes

  • Cursor usage

    Could the output be cleaned using the Cursor?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/5.2/components/console/helpers/cursor.html#clearing-output

    Yes

  • Locked command

    Could you prevent a command from running multiple times on a single server?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/3.2/console/lockable_trait.html

    Yes

  • PHP constant

    Is it possible to display the value of a constant of a PHP class in a Twig template ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://twig.symfony.com/doc/functions/constant.html
    Yes

  • API

    Is Message considered as a high-level API?

    Wrong

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.3/components/mime.html#introduction


  • IP address

    Could an IP address be anonymized?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/4.4/components/http_foundation.html#anonymizing-ip-addresses
    • https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpFoundation/IpUtils.php
    Yes

  • Configuration per env

    Is it possible to configure multiple environments in a single file?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/blog/new-in-symfony-5-3-configure-multiple-environments-in-a-single-file

    Yes

  • Services preload

    Could a class be removed from the list of preloaded classes by PHP?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.1/reference/dic_tags.html#container-no-preload

    Yes

  • Monolog

    Does Monolog implement the PSR-3 interface?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://github.com/Seldaek/monolog
    • https://www.php-fig.org/psr/psr-3/
    Yes

  • Argument resolvers

    Given the context where FooService is defined as a service, is the following code valid?

    <?php
    // ...
    class HomeController { #[Route('/', name: 'home')] public function __invoke(FooService $fooService): Response { // ... } }

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/3.3/controller/argument_value_resolver.html#functionality-shipped-with-the-httpkernel
    • https://github.com/symfony/symfony/tree/3.3/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver
    Yes

  • The IsNull validation constraint

    Will the following snippet throw an InvalidArgumentException ?

    use Symfony\Component\Validator\Validation;
    use Symfony\Component\Validator\Constraints\IsNull;
    $expectedNull = '';
    $validator = Validation::createValidator(); $violations = $validator->validate($expectedNull, [new IsNull()]);
    if (0 !== count($violations)) { throw new InvalidArgumentException('The value is not null !'); }

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.x/reference/constraints/IsNull.html
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Validator/Constraints/IsNullValidator.php
    Yes

  • Abstract services

    Could a service be defined as parent even if the children service does not extends the parent class?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.7/service_container/parent_services.html

    Yes

  • Runtime usage

    Is the following code valid?

    <?php
    require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
    return function (): Closure { $app = function(): int { echo 'Hello World';
    return 0; };
    return $app; };

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-the-runtime

    Yes

  • Mirror usage

    When using mirror(...), could files instead of links be mirrored on Windows?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.2/components/filesystem.html#mirror
    • https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/Filesystem/Filesystem.php#L338
    Yes

  • Generator usage

    Could a generator contains a return statement?

    Correct

    • Yes

    The choices were

    • Yes, but empty only

    • Yes

    • No

    Help

    https://www.php.net/manual/en/language.generators.syntax.php

    Yes

  • Required services

    Could services be tagged as always required when bootstrapping the container?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/3.4/reference/dic_tags.html#container-hot-path

    Yes

  • FlashBag usage

    Could the FlashBag messages be retrieved without being removed from the bag?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php

    Yes

  • Config definition

    Is the following configuration valid with this definition ?

    $rootNode
        ->children()
            ->arrayNode('connections')
                ->prototype('array')
                    ->children()
                        ->scalarNode('driver')->end()
                        ->scalarNode('host')->end()
                        ->scalarNode('username')->end()
                        ->scalarNode('password')->end()
                    ->end()
                ->end()
            ->end()
        ->end()
    ;
    connections:
        driver: pdo_mysql
        host: mysql
        username: admin
        password: mySecuredPassword
    YAML

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    http://symfony.com/doc/current/components/config/definition.html#array-nodes


  • Mirror usage

    When using mirror(...), could existing files be overridden?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.2/components/filesystem.html#mirror
    • https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/Filesystem/Filesystem.php#L338
    Yes

  • Configuration

    Is it possible to override the error handler used?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-options

    Yes

  • Enumerations usage

    Could enumerations be used to display a list of choices?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-php-enumerations-support#php-enums-support-in-symfony-forms
    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/Extension/Core/Type/EnumType.php
    Yes

  • Console events

    Are console events dispatched when testing commands using CommandTester?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.7/console.html#testing-commands
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Tester/CommandTester.php

  • BC promise

    Is the BC promise guaranteed when adding a new property to a custom class that extends a Symfony class ?

    Wrong

    • Yes

    The choices were

    • Yes

    • No

    Help

    http://symfony.com/doc/current/contributing/code/bc.html#using-our-classes


  • Location header usage

    Given a response using the 308 status code and containing a Location header, must the client use the header URI for automatic redirection?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://tools.ietf.org/html/rfc7538#section-3
    • As explained, the user agent MAY use the Location field value for automatic redirection, using it is not a requirement.

  • Doctrine bridge

    Given the context where the doctrine transport is used, could all the handlers be wrapped in a single transaction?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.4/messenger.html#middleware-for-doctrine

    Yes

  • Email usage

    Could an email be encrypted?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.4/mailer.html#encrypting-messages

    Yes

  • array_map usage

    Could array_map be applied to multiple arrays at the same time?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://www.php.net/manual/en/function.array-map

    Yes

  • Service dependency

    Can you inject a dependency to a service without passing it to the constructor?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/current/components/dependency_injection.html
    • https://symfony.com/doc/current/service_container/injection_types.html
    Yes

  • MockHttpClient usage

    Could the amount of requests proceed by MockHttpClient be accessed?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/5.1/http_client.html#testing-http-clients-and-responses
    • https://github.com/symfony/symfony/blob/5.1/src/Symfony/Component/HttpClient/MockHttpClient.php
    Yes

  • Fields priority

    Can fields be sorted using a priority?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • Since 5.3, the priority option can be used to sort fields.
    • https://symfony.com/blog/new-in-symfony-5-3-form-field-sorting
    • https://github.com/symfony/symfony/pull/40690
    Yes

  • DataTransformer

    Does a Symfony\Component\Form\Exception\TransformationFailedException thrown in a DataTransformer::reverseTransform cause a validation error ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.7/form/data_transformers.html
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Exception/TransformationFailedException.php
    Yes

  • Interfaces

    Can interfaces inherit from other interfaces in PHP?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • http://php.net/interfaces
    Yes

  • Configuration files import

    Is the following code valid?

    # app/config/config.yaml
    imports:
        - { resource: '@Acme/config.yml', ignore_errors: true }
    # ...
    YAML

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php#L81
    • https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/Config/Loader/FileLoader.php
    Yes

  • Console events

    Are console events dispatched when testing commands using ApplicationTester?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.7/console.html#testing-commands
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Tester/ApplicationTester.php
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Tester/CommandTester.php
    Yes

  • Environment variables configuration

    Is it possible to toggle the debug of Symfony applications when using SymfonyRuntime or GenericRuntime?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-options

    Yes

  • Path usage

    Could the longest common base path between multiple files be found?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-filesystem-path-class
    • https://github.com/symfony/filesystem/blob/5.4/Path.php#L580
    Yes

  • Cache usage

    Given the case where the opcache/APC cache for template need to be invalidated, is the following code valid?

    <?php
    // ...
    $twig = new Environment($loader, [ 'cache' => new FilesystemCache('/some/cache/path', 1), // ... ]);

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://twig.symfony.com/doc/1.x/recipes.html#refreshing-modified-templates-when-opcache-or-apc-is-enabled

    Yes

  • Services alias

    Could aliases of services be defined via a value of container parameter?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.7/reference/dic_tags.html#auto-alias
    • https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/DependencyInjection/Compiler/AutoAliasServicePass.php
    Yes

  • OOP

    Can an interface extend another interface?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    http://php.net/manual/en/language.oop5.interfaces.php

    Yes

  • Console status code

    Is the following code valid?

    <?php
    // ...
    class FooCommand extends Command { protected function execute(InputInterface $input, OutputInterface $output): int { // ...
    return Command::INVALID; } }

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/console.html#creating-a-command

    Yes

  • Route priority

    Could a priority be set when adding a new Route via RouteCollection::add()?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Routing/RouteCollection.php#L85

    Yes

  • Sequentially usage

    Is the following code valid?

    <?php
    namespace App\Localization;
    use App\Validator\Constraints as AcmeAssert; use Symfony\Component\Validator\Constraints as Assert;
    class Place { private const ADDRESS_REGEX = # ...
    #[Assert\Sequentially([ new Assert\NotNull, new Assert\Type('string'), new Assert\Length(min: 10), new Assert\Regex(Place::ADDRESS_REGEX), new AcmeAssert\Geolocalizable, ])] public $address; }

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • The Sequentially attribute has been introduced in 5.4, keep in mind that nested attributes requires PHP 8.1 or higher
    • https://symfony.com/doc/5.4/validation/sequence_provider.html#how-to-sequentially-apply-constraints-on-a-single-property
    • https://symfony.com/doc/5.4/reference/constraints/Sequentially.html
    Yes

  • If-Match usage

    Could the If-Match header be used with a PUT request?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match
    Yes

  • PHP Basics

    Is the following exception class valid ?

    class MyException implements Throwable
    {
      private $message;
      private $code;
      private $file;
      private $line;
      private $trace;
      private $previous;
    public function __construct($message, $code, $file, $line, array $trace, Throwable $previous) { $this->message = $message; $this->code = $code; $this->file = $file; $this->line = $line; $this->trace = $trace; $this->throwable = $throwable; }
    public function getMessage() { return $this->message; }
    public function getCode() { return $this->code; }
    public function getFile() { return $this->file; }
    public function getLine() { return $this->line; }
    public function getTrace() { return $this->trace; }
    public function getTraceAsString() { return serialize($this->trace); }
    public function getPrevious() { return $this->previous; }
    public function __toString() { return sprintf('%d: %s', $this->code, $this->message); } }

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://www.php.net/manual/en/class.throwable.php

  • Magic methods usage

    Could the usage of __set() method be disabled?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.2/components/property_access.html#enable-other-features

    Yes

  • Enumeration - Transformation from null

    Is the following code valid?

    <?php
    enum Suit: string { case Hearts = 'H'; case Diamonds = 'D'; case Clubs = 'C'; case Spades = 'S'; }
    $h = Suit::tryFrom('E') ?? Suit::from('H');

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://www.php.net/manual/en/backedenum.tryfrom.php
    • https://www.php.net/manual/en/backedenum.from.php
    Yes

  • FrameworkBundle

    Is the following routing configuration valid ?

    redirect:
      path: /old-path
      controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController'
      defaults:
        path: /new-path
    YAML

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/4.4/routing.html
    Yes

  • VCS files

    Could the files that match .gitignore patterns be ignored?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/4.3/components/finder.html#version-control-files
    • https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Finder/Finder.php
    Yes

  • Request method

    Does the 308 status code allow to change the request method?

    Wrong

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://tools.ietf.org/html/rfc7538#section-3


  • Validation

    Is Symfony\Component\Form\Form::isValid() the method responsible for validating its data?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    ValidationListener actually do the job

    • https://github.com/symfony/symfony/blob/0baa58d4e4bb006c4ae68f75833b586bd3cb6e6f/src/Symfony/Component/Form/Form.php#L744
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php

  • Usage

    Can a custom type guesser be created?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/4.3/components/mime.html#adding-a-mime-type-guesser
    Yes

  • Service

    It is possible to change the class of a service using the ContainerBuilder?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/current/components/dependency_injection/definitions.html
    Yes

  • Serialization Context

    Is the following code valid ?

    
    #[Serializer\Context(
        normalizationContext: [DateTimeNormalizer::FORMAT_KEY => \DateTime::RFC3339],
        groups: ['extended']
    )]
    public \DateTime $date;

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/blog/new-in-symfony-5-3-inlined-serialization-context

    Yes

  • The IsTrue validation constraint

    Will the following snippet throw an InvalidArgumentException ?

    use Symfony\Component\Validator\Validation;
    use Symfony\Component\Validator\Constraints\IsTrue;
    $expectedTrue = 123;
    $validator = Validation::createValidator(); $violations = $validator->validate($expectedTrue, [new IsTrue()]);
    if (0 !== count($violations)) { throw new InvalidArgumentException('The value is not true !'); }

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/reference/constraints/IsTrue.html

    Yes

  • Usage

    Given the context where an application runs under the prod environment and an external library that use getenv() to access environment variables, is it possible to force DotEnv to use putenv() instead of defining environment variables at the machine level?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#using-options

    Yes

  • Execution

    Could an application be executing without return something (aka void)?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/current/components/runtime.html#resolvable-applications

    Yes

  • ContainerBuilder usage

    Could the fact that a class is available and will remain available in the --no-dev mode of Composer be obtained when using ContainerBuilder?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L1454

    Yes

  • SplFileInfo usage

    Is the following code valid?

    <?php
    use Symfony\Component\Finder\Finder;
    $finder = new Finder(); $finder->files()->in(__DIR__);
    foreach ($finder as $file) { echo $file->getMTime(); }

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/current/components/finder.html#usage
    • https://www.php.net/manual/en/class.splfileinfo.php
    Yes

  • Request Handling

    Can the Request object be modified during its handling ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/current/components/http_foundation.html
    Yes

  • Connecting Listeners

    Is it possible to make the same listener object listen to multiple events?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://symfony.com/doc/current/components/event_dispatcher/introduction.html#connecting-listeners
    Yes

  • ContainerBag usage

    Could a new parameter be set into a ContainerBag?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php#L53

  • Generators

    In PHP 7, can a generator contain a return statement ?

    Correct

    • Yes

    The choices were

    • No

    • Yes, but empty only

    • Yes

    Help

    http://php.net/manual/en/language.generators.syntax.php

    Yes

  • Firewall Definitions

    Is this firewall valid ?

    security:
        firewalls:
            main:
                provider: app_user_provider
    YAML

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/current/security.html#the-firewall
    Yes

  • File locking

    Is it possible to write in a file while locking it?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://www.php.net/manual/en/function.flock.php
    • https://symfony.com/doc/5.4/components/filesystem.html#appendtofile
    Yes

  • Safe response

    Could a response be marked as safe?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/5.1/src/Symfony/Component/HttpFoundation/Response.php#L1242

    Yes

  • Headers

    Is there any required header in a request to an origin server or gateway for almost every request ?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://datatracker.ietf.org/doc/html/rfc7230#section-5.4

    Yes

  • ConstraintViolationList creation

    Could a ConstraintViolationList be created from a single violation message?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Validator/ConstraintViolationList.php#L40
    • https://github.com/symfony/symfony/pull/41154
    Yes

  • Service id

    Are service ids considered as case-sensitive?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/blog/new-in-symfony-3-3-dependency-injection-deprecations#deprecated-the-case-insensitivity-of-service-identifiers

    Yes

  • Usage

    Could enumerations be dumped?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/pull/41072

    Yes

  • Kernel configuration

    Could the build directory be overridden?

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/5.2/reference/configuration/kernel.html#build-directory
    • https://github.com/symfony/symfony/blob/5.2/src/Symfony/Component/HttpKernel/Kernel.php#L337
    Yes

  • Null values

    Could null values be skipped?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/4.2/components/serializer.html#skipping-null-values

    Yes

  • Event dispatching

    Could an event be dispatched without creating a custom event class?

    Correct

    • Yes

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/2.1/components/event_dispatcher/generic_event.html
    • https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/GenericEvent.php
    Yes

  • Translation

    Is the translation activated by default?

    Wrong

    • Yes

    The choices were

    • Yes

    • No

    Help

    • http://symfony.com/doc/current/book/translation.html#configuration

  • DataTransformer

    Are Data Transformers applied on a form field which has the inherit_data option set ?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    http://symfony.com/doc/current/form/data_transformers.html


  • Private services

    Let's assume, we have a private service my_private_service.

    $container->get('my_private_service');

    Will it work?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/service_container/alias_private.html


  • ImmutableEventDispatcher usage

    Could listeners be removed from an ImmutableEventDispatcher?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php


  • Calls

    Regarding the following code, will the calls directive of service_parent be overridden by the one from service_child ?

        logger_A:
            class: Acme\Logger\TextLogger
        logger_B:
            class: Acme\Logger\EchoLogger
    service_parent: abstract: true calls: - ['addLogger', ['@logger_A']]
    service_child: parent: @service_parent class: Acme\Transformer\TextTransformer calls: - ['addLogger', ['@logger_B']]
    YAML

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/3.1/service_container/parent_services.html


  • Arguments resolution

    Could arguments be resolved in a controller not tagged with the controller.service_arguments tag?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/NotTaggedControllerValueResolver.php


  • Zip

    Does PHP provide an extension to work with Zip files by default?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    http://php.net/manual/en/book.zip.php


  • Address usage

    Could a new Address be created using Address::fromString()?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Mime/Address.php


  • Attributes Groups

    Which of the following is a correct YAML group definition?

    Wrong

    • Acme\MyObj:
          groups:
              group1:
                  attributes: ['foo']
              group2:
                  attributes: ['foo']
              group3:
                  attributes: ['bar']
      YAML

    The choices were

    • Acme\MyObj:
          group1:
              attributes: ['foo']
          group2:
              attributes: ['foo']
          group3:
              attributes: ['bar']
      YAML
    • Acme\MyObj:
          groups:
              group1:
                  attributes: ['foo']
              group2:
                  attributes: ['foo']
              group3:
                  attributes: ['bar']
      YAML
    • Acme\MyObj:
          attributes:
              foo:
                  groups: ['group1', 'group2']
              bar:
                  groups: ['group3']
      YAML
    • Acme\MyObj:
          foo:
              groups: ['group1', 'group2']
          bar:
              groups: ['group3']
      YAML

    Help

    • http://symfony.com/doc/current/components/serializer.html#attributes-groups
    YAML group definition? Wrong Acme\MyObj: groups: group1: attributes: ['foo'] group2: attributes: ['foo'] group3: attributes: ['bar']YAML

  • Translation Source File Format

    According to the official Symfony Best Practices Guide, which format do you need to use for your translation files?

    Correct

    • XLIFF

    The choices were

    • CSV

    • YAML

    • XLIFF

    • JSON

    Help

    https://symfony.com/doc/current/best_practices.html#use-the-xliff-format-for-your-translation-files

    XLIFF

  • Reading from Objects

    What will be the value of $firstName?

    <?php
    use Symfony\Component\PropertyAccess\PropertyAccess;
    $accessor = PropertyAccess::createPropertyAccessor();
    class Person { public $firstName;
    public function getFirstName() { return 'Ryan'; } } $person = new Person(); $person->firstName = 'Wouter';
    $firstName = $accessor->getValue($person, 'firstName');

    Wrong

    • Wouter

    The choices were

    • Wouter

    • Ryan

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L125
    • http://symfony.com/doc/current/components/property_access/introduction.html#accessing-public-properties

  • Validation

    How can you disable the validation in a form?

    Correct

    • With the validation_groups option set to false

    The choices were

    • By not calling isValid()

    • With the validation_groups option set to false

    • By calling isValid(false)

    • With the no_validation option set to true

    Help

    • http://symfony.com/doc/current/form/disabling_validation.html
    With the validation_groups option set to false

  • Configuration

    How can you get the value of the current configuration directives (php.ini) of a PHP extension?

    Correct

    • With the reflection API

    • With ini_get_all()

    The choices were

    • With get_loaded_extensions()

    • With php://config stream

    • With the reflection API

    • With ini_get_all()

    • With the $GLOBALS array

    Help

    • http://php.net/manual/en/function.ini-get-all.php
    • http://php.net/manual/en/reflectionextension.getinientries.php
    • http://php.net/manual/en/function.get-loaded-extensions.php
    With the reflection API With ini_get_all()

  • Messenger

    How can you retrieve a result generated by a handler ?

    Correct

    • With a stamp

    The choices were

    • With a stamp

    • With the handler.registry service

    • It's not possible due to the asyncronous behavior of the messenger component

    Help

    • https://symfony.com/doc/4.2/messenger/handler_results.html
    With a stamp

  • Processing Forms

    What triggers the form processing in controllers ?

    Wrong

    • With $form->process().

    The choices were

    • With $form->isSubmitted().

    • With $form->process().

    • With $form->isValid().

    • With $form->handleRequest().

    Help

    • https://symfony.com/doc/current/components/form.html

  • HttpKernelInterface

    What is the third argument of the handle method of Symfony\Component\HttpKernel\HttpKernelInterface?

    Correct

    • Whether to catch exceptions or not.

    The choices were

    • The name of the environment

    • A Request instance

    • Whether to catch exceptions or not.

    • The type of the request

    • Whether to activate the debug or not

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpKernel/HttpKernelInterface.php#L42
    Whether to catch exceptions or not.

  • Dependency Injection

    Which sentences are true about compiler pass registration ?

    Wrong

    • When a compiler pass is registered, you can chose the step where it will be executed. 5 steps are available

    • Compiler pass can be registered in the build method of the Kernel

    • Compiler pass are automatically registered if they implement CompilerPassInterface and autoconfigure is set to true

    The choices were

    • Compiler pass can be registered in the build method of the Kernel

    • When a compiler pass is registered, you can chose the step where it will be executed. 6 steps are available

    • Compiler pass are automatically registered if they implement CompilerPassInterface and autoconfigure is set to true

    • When a compiler pass is registered, you can chose the step where it will be executed. 4 steps are available

    • When a compiler pass is registered, you can chose the step where it will be executed. 5 steps are available

    Help

    • https://symfony.com/doc/3.3/service_container/compiler_passes.html
    • https://symfony.com/doc/3.3/components/dependency_injection/compilation.html

  • Vary header usage

    Which of the followings are valid usage of the Vary header?

    Wrong

    • Vary: User-Agent

    • Vary: *

    The choices were

    • Vary: Accept-Encoding

    • Vary: Cookie

    • Vary: User-Agent

    • Vary: *

    • Vary: Referer

    Help

    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary
    • https://www.fastly.com/blog/best-practices-using-vary-header

  • Luhn Constraint

    What does the Luhn constraint do?

    Correct

    • Validates a card number

    The choices were

    • Validates a card number

    • Validates an ISBN number

    • It doesn't exist

    • Validates an IBAN number

    Help

    https://symfony.com/doc/2.3/reference/constraints/Luhn.html

    Validates a card number

  • Security

    How would you use the SHA-512 hash algorithm in PHP?

    Wrong

    • Using the sha512() function

    • Using the hash() function

    The choices were

    • Using the crypt() function

    • Using the sha512() function

    • Using the hash() function

    Help

    • http://php.net/manual/en/function.crypt.php
    • http://php.net/manual/en/function.hash.php

  • Validate an object

    How can you validate an object but only against a subset of the constraints ?

    Wrong

    • Using the method validate partial() instead of validate(), as it accepts a list of constraints.

    The choices were

    • Using the method validate partial() instead of validate(), as it accepts a list of constraints.

    • Using roles.

    • Using validation groups.

    • It is not possible to partially validate an object.

    Help

    http://symfony.com/doc/current/validation/groups.html


  • Controller

    Given the full Symfony framework is installed, how to create a new controller ?

    Correct

    • Using the make:controller command

    • Manually creating a class in the Controller folder

    The choices were

    • Using the make-controller command

    • Using the make:controller command

    • Manually creating a class in the Controller folder

    • Using the create:controller command

    • Using the create-controller command

    Help

    • https://symfony.com/doc/current/the-fast-track/en/6-controller.html
    • https://symfony.com/doc/6.3/page_creation.html
    Using the make:controller command Manually creating a class in the Controller folder

  • Console autocompletion

    How could be defined the autocompletion suggestions of a command?

    Correct

    • Using the complete method

    The choices were

    • Using the complete method

    • Using the autocomplete method

    • It's not possible

    • Using the suggest method

    Help

    • https://symfony.com/blog/new-in-symfony-5-4-console-autocompletion
    • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Command/Command.php#L308
    Using the complete method

  • Detect click on a SubmitType

    How one can detect that a given Symfony\Component\Form\Extension\Core\Type\SubmitType form type has been clicked ?

    Wrong

    • Using the clicked method of the given submit button.

    The choices were

    • Using the isClicked method of the given submit button.

    • Using the clicked method of the given parent form.

    • Using the clicked method of the given submit button.

    • Using the isClicked method of the parent form.

    Help

    https://symfony.com/doc/current/reference/forms/types/submit.html


  • PHP strings

    Identify the best approach to compare two variables in a binary-safe fashion

    Correct

    • Using strcmp()

    • Using === operator

    The choices were

    • Using === operator

    • Using == operator

    • Using strstr()

    • Using strcmp()

    • Using str_sompare()

    Help

    • http://www.php.net/strings
    • http://php.net/manual/fr/function.strcmp.php
    • http://php.net/manual/en/language.operators.comparison.php
    • http://php.net/manual/fr/function.strstr.php
    Using strcmp() Using === operator

  • Usage

    How can we define the status code of MockResponse?

    Wrong

    • Using status_code option

    The choices were

    • It's not possible

    • Using status_code option

    • Using http_code option

    Help

    https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpClient/Response/MockResponse.php#L45


  • Response headers

    Which of these headers don't belong to the Response ?

    Correct

    • User-Agent

    • Referer

    The choices were

    • User-Agent

    • Proxy-Authenticate

    • Referer

    • WWW-Authenticate

    Help

    https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.2

    User-Agent Referer

  • Headers

    How does the browser communicate to the server what is the preferred language of the user?

    Correct

    • User language preferences are sent using the Accept-Language header

    The choices were

    • User language preferences are sent using the Accept-Language header

    • The main language is sent using the Locale header, while secondary languages are usually included in the X-Locale-Alternate header.

    • The browser doesn’t communicate the language of the user, it’s inferred from the user IP.

    • The main language is included in the User-Agent header

    Help

    https://www.w3.org/International/questions/qa-lang-priorities

    User language preferences are sent using the Accept-Language header

  • MIME message part: `multipart/related`

    What is the purpose of the multipart/related MIME message part?

    Correct

    • Used to indicate that each message part is a component of an aggregate whole. The most common usage is to display images embedded in the message contents

    The choices were

    • Used to send different content types in the same message, such as when attaching files

    • Used when two or more parts are alternatives of the same (or very similar) content. The preferred format must be added last

    • Used to indicate that each message part is a component of an aggregate whole. The most common usage is to display images embedded in the message contents

    Help

    https://symfony.com/doc/current/components/mime#creating-raw-email-messages

    Used to indicate that each message part is a component of an aggregate whole. The most common usage is to display images embedded in the message contents

  • MIME message part: `multipart/alternative`

    What is the purpose of the multipart/alternative MIME message part?

    Wrong

    • Used to indicate that each message part is a component of an aggregate whole. The most common usage is to display images embedded in the message contents

    The choices were

    • Used to indicate that each message part is a component of an aggregate whole. The most common usage is to display images embedded in the message contents

    • Used when two or more parts are alternatives of the same (or very similar) content. The preferred format must be added last

    • Used to send different content types in the same message, such as when attaching files

    Help

    https://symfony.com/doc/current/components/mime#creating-raw-email-messages


  • URLs in a Functional Test

    According to the official Symfony Best Practices Guide, what is the recommended way to use URLs in a functional test?

    Wrong

    • Use the URL generator

    The choices were

    • Hardcode the URLs

    • Do not use URLs in a functional test

    • Use the URL generator

    Help

    https://symfony.com/doc/current/best_practices/tests.html#hardcode-urls-in-a-functional-test


  • Password confirmation

    What solution can you use to ask the user to type his password twice in a form ?

    Correct

    • Use the RepeatedType form type.

    The choices were

    • Use the ask_confirmation option on the PasswordType form type.

    • Use the Validation plugin of jQuery.

    • Call the render_widget twig function twice on the password form type.

    • Use the RepeatedType form type.

    Help

    https://symfony.com/doc/current/reference/forms/types/repeated.html

    Use the RepeatedType form type.

  • Authorization

    According to the official Symfony Best Practices Guide, which method do you need to use in order to protect broad URL patterns?

    Wrong

    • Use the @Security annotation

    The choices were

    • Use access_control in the security configuration

    • Use the security.authorization_checker service

    • Use the @Security annotation

    Help

    • https://symfony.com/doc/4.0/best_practices/security.html#authorization-i-e-denying-access
    • https://symfony.com/doc/current/security/access_control.html

  • SecurityBundle

    If you're using an API and after being authenticated you don't want the session to be kept for the next requests; you have to:

    Correct

    • Use stateless: true at firewall level

    The choices were

    • Use session: false at firewall level

    • Use session: false at authentication provider level

    • Use stateless: true at firewall level

    • Use stateless: true at authentication provider level

    • Simply use json_login authentication provider

    Help

    • https://symfony.com/doc/2.8/security/guard_authentication.html
    Use stateless: true at firewall level

  • Accessing standard i/o streams

    When writing CLI scripts, how can you access the standard input/output/error streams?

    Correct

    • Use STDIN, STDOUT and STDERR constants

    The choices were

    • Use stdin(), stdout() and stderr() functions

    • Use php::STDIN, php::STDOUT, php::STDERR class constants

    • Use STDIN, STDOUT and STDERR constants

    • use FD_0, FD_1 and FD_2 constants

    Help

    http://php.net/manual/en/features.commandline.php

    Use STDIN, STDOUT and STDERR constants

  • `HttpClient`: cookies support

    How to configure the HTTP Client provided by the Symfony HttpClient component to save a Cookie between requests?

    Wrong

    • Use $client->setCookie(new Cookie(...))

    The choices were

    • Use $client->setCookie(new Cookie(...))

    • The HTTP Client provided by the Symfony HttpClient component does not handle cookies.

    • Use $client->getCookieJar()->set(new Cookie(...))

    • Use $client->cookies->set(new Cookie(...))

    Help

    https://symfony.com/doc/6.0/http_client.html#cookies


  • Variables

    Consider the following code snippet:

    {% set foo, bar = 'FOO' %}
    <p> Foo is {{ foo }} and Bar is {{ bar }}. </p>
    Twig

    What will be the outcome of evaluating this Twig code?

    Correct

    • Twig will raise a Twig_Error_Syntax exception.

    The choices were

    • The output will display the string Foo is FOO and Bar is ..

    • The output will display the string Foo is and Bar is ..

    • The output will display the string Foo is FOO and Bar is FOO..

    • Twig will raise a Twig_Error_Syntax exception.

    Help

    • https://twig.symfony.com/doc/tags/set.html
    Twig will raise a Twig_Error_Syntax exception.

  • Template Inheritance

    Consider the following Twig code snippet:

    {% extends 'layout.html.twig' %}
    {% block title 'Hello World!' %}
    My name is Amanda.
    Twig

    What will be the result of evaluating this Twig template?

    Correct

    • Twig will raise a Twig_Error_Syntax exception preventing the template from being evaluated.

    The choices were

    • The template is successfully evaluated and the string My name is Amanda will be displayed in the web browser.

    • Twig will raise a Twig_Error_Syntax exception preventing the template from being evaluated.

    Help

    http://twig.symfony.com/doc/tags/extends.html

    Twig will raise a Twig_Error_Syntax exception preventing the template from being evaluated.

  • Strict Variables Mode

    Consider the following Twig code snippet:

    The {{ color }} car!
    Twig

    What will be the result of evaluating this template without passing it a color variable when the strict_variables global setting is on?

    Correct

    • Twig will raise a Twig_Error_Runtime exception preventing the template from being evaluated.

    The choices were

    • The template will be partially evaluated and the string The will be displayed in the web browser.

    • The template will be succesfully evaluated and the string The car! will be displayed in the web browser.

    • Twig will raise a Twig_Error_Runtime exception preventing the template from being evaluated.

    • The template will be succesfully evaluated and the string The empty car! will be displayed in the web browser.

    Help

    • https://twig.symfony.com/doc/1.x/templates.html#variables
    • https://twig.symfony.com/doc/2.x/templates.html#variables
    • https://twig.symfony.com/doc/2.x/api.html#environment-options
    • https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Extension/Core.php#L1447-L1479
    Twig will raise a Twig_Error_Runtime exception preventing the template from being evaluated.

  • Public or Private

    By default, registered services are private?

    Correct

    • True

    The choices were

    • False

    • True

    Help

    https://github.com/symfony/symfony/blob/4.0/src/Symfony/Component/DependencyInjection/Definition.php

    True

  • Bundle Best Practices

    To strictly follow the best practices for reusable bundles, the file that contains the basic description of the bundle should be named README.md.

    Correct

    • True

    The choices were

    • False

    • True

    Help

    https://symfony.com/doc/6.0/bundles/best_practices.html#directory-structure

    True

  • Best Practices

    To follow the best practices for reusable bundles, the file that contains the basic description of the bundle must be named README.md:

    Correct

    • True

    The choices were

    • False

    • True

    Help

    • https://symfony.com/doc/5.0/bundles/best_practices.html
    True

  • Authentication

    Authentication is the process that makes sure that a user is who he claims to be?

    Correct

    • True

    The choices were

    • False

    • True

    Help

    • https://symfony.com/doc/current/components/security/authentication.html
    True

  • HttpClient

    HttpClient provide a MockResponse class because you can't create your own mock of ResponseInterface to test it

    Wrong

    • True

    The choices were

    • True

    • False

    Help

    • https://symfony.com/doc/5.0/components/http_client.html

  • HTTP

    HTTP PURGE method was added to http/1.1 to allow to mark pages cached by proxies as stales.

    Wrong

    • True

    The choices were

    • False

    • True

    Help

    • https://symfony.com/doc/2.7/http_cache/cache_invalidation.html
    • https://tools.ietf.org/html/rfc2616

  • Streaming to the Standard Input of a Process

    Which types of argument accepts the Symfony\Component\Process\InputStream\write() method?

    Wrong

    • Traversable objects

    • Boolean

    • Scalars

    The choices were

    • Boolean

    • Stream resources

    • Scalars

    • Traversable objects

    • Arrays

    Help

    • https://symfony.com/doc/3.x/components/process.html#streaming-to-the-standard-input-of-a-process
    • https://github.com/symfony/symfony/blob/3.1/src/Symfony/Component/Process/InputStream.php#L35

  • Twig internals

    Which token is used by the Lexer to find the end of a template?

    Correct

    • Token::EOF_TYPE

    The choices were

    • Token::END_OF_FILE

    • Token::EOF

    • Token::END_OF_FILE_TYPE

    • Token::EOF_TYPE

    Help

    https://twig.symfony.com/doc/1.x/internals.html#the-lexer

    Token::EOF_TYPE

  • Processes to wait until...

    What does the waitUntil method allow you to do?

    Wrong

    • To wait for a condition to be verified before killing the running async process

    The choices were

    • To wait for a certain amount of time before killing the running async process

    • To wait for a condition to be verified before continuing the main script execution

    • To wait for a condition to be verified before killing the running async process

    Help

    https://symfony.com/doc/current/components/process.html#running-processes-asynchronously


  • disallowMockingUnknownTypes

    What is the goal of calling disallowMockingUnknownTypes() when creating a stub or mock?

    Correct

    • To throw an Exception if the class or the interface does not exist.

    The choices were

    • To throw an Exception if the interface does not exist.

    • To throw an Exception if the class does not exist.

    • To throw an Exception if the class or the interface does not exist.

    • To throw an Exception if the class is not a native PHP class.

    Help

    • https://github.com/sebastianbergmann/phpunit-mock-objects/blob/4.0.4/src/Generator.php#L103-L128
    • https://github.com/sebastianbergmann/phpunit-mock-objects/blob/6.1.2/src/Generator.php#L114-L139
    To throw an Exception if the class or the interface does not exist.

  • Sending the Response

    What is the aim of the prepare() method in Symfony\Component\HttpFoundation\Response?

    Wrong

    • To send the Response to the client.

    The choices were

    • To tweak the Response to ensure that it is compliant with RFC 2616.

    • To convert the Response to a string that is compatible with the HTTP response message format.

    • To send the Response to the client.

    Help

    • https://symfony.com/doc/2.8/components/http_foundation.html#sending-the-response
    • https://github.com/symfony/symfony/blob/0baa58d4e4bb006c4ae68f75833b586bd3cb6e6f/src/Symfony/Component/HttpFoundation/Response.php#L204

  • UrlType value prepending

    What is the use of the default_protocol option of the Symfony\Component\Form\Extension\Core\Type\UrlType form type ?

    Wrong

    • To force the submitted value to begin with a given URI scheme (eg. http://).

    The choices were

    • To prepend the submitted value with an URI scheme (eg. http://) if it does not begin with one.

    • To render the input with the placeholder property containing the value of the option.

    • To force the submitted value to begin with a given URI scheme (eg. http://).

    Help

    http://symfony.com/doc/current/reference/forms/types/url.html


  • Service Autoconfiguration

    What is the purpose of Autoconfiguration in Symfony ?

    Correct

    • To automatically configure services based on their class, attributes or interface.

    The choices were

    • To automatically configure services based on their class, attributes or interface.

    • To automatically decorate services based on their class, attributes or interface.

    • To automatically register services based on their class, attributes or interface.

    Help

    • https://symfony.com/doc/current/service_container.html#services-autoconfigure
    To automatically configure services based on their class, attributes or interface.

  • Traits

    Consider the following PHP code snippet:

    trait HelloTrait
    {
        private function hello()
        {
            return 'Hello';
        }
    }
    class PoliteGreeter { use HelloTrait;
    public function greet($someone) { return $this->hello() . ' '. $someone .'!'; } }
    class YoGreeter extends PoliteGreeter { private function hello() { return 'Yo'; } }
    $greeter = new YoGreeter(); echo $greeter->greet('World');

    What will be the outcome of running this code with PHP 5.4 or greater?

    Wrong

    • This snippet displays the string Yo World! on the standard output.

    The choices were

    • PHP will raise a Fatal Error preventing the private hello() method from being overriden in the YoGreater class.

    • This snippet displays the string Yo World! on the standard output.

    • This snippet displays the string Hello World! on the standard output.

    Help

    http://php.net/manual/fr/language.oop5.traits.php


  • Streams

    Which of the following are not true about streams ?

    Wrong

    • They are always seekable.

    • They can be applied to any data source.

    • They are always bi-directional.

    The choices were

    • They can be filtered.

    • They can be applied to any data source.

    • They are always bi-directional.

    • They are always seekable.

    • When used properly, they significantly reduce memory consumption.

    Help

    http://php.net/manual/en/book.stream.php


  • Compiler Passes

    Which of the following statements are true about the so-called compiler passes?

    Wrong

    • They allow to add, alter or remove any services definitions of a ContainerBuilder object.

    • They prevent the ContainerBuilder object from being compiled if they detect any circular references in services definitions.

    • They perform some optimization operations on a ContainerBuilder instance in order to generate the most efficient PHP code possible.

    • They check that all registered services definitions are valid and some required global parameters are not missing.

    • They are always triggered on every HTTP requests made to the Symfony application.

    The choices were

    • They allow to add, alter or remove any services definitions of a ContainerBuilder object.

    • They prevent the ContainerBuilder object from being compiled if they detect any circular references in services definitions.

    • They are always triggered on every HTTP requests made to the Symfony application.

    • They perform some optimization operations on a ContainerBuilder instance in order to generate the most efficient PHP code possible.

    • They check that all registered services definitions are valid and some required global parameters are not missing.

    Help

    • https://symfony.com/doc/current/service_container/compiler_passes.html#main
    • https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

  • Compiler Passes

    Which of the following statements are true about the so-called compiler passes?

    Wrong

    • They allow to add, alter or remove any services definitions of a ContainerBuilder object.

    • They prevent the ContainerBuilder object from being compiled if they detect any circular references in services definitions.

    • They perform some optimization operations on a ContainerBuilder instance in order to generate the most efficient PHP code possible.

    The choices were

    • They prevent the ContainerBuilder object from being compiled if they detect any circular references in services definitions.

    • They check that all registered services definitions are valid and some required global parameters are not missing.

    • They perform some optimization operations on a ContainerBuilder instance in order to generate the most efficient PHP code possible.

    • They allow to add, alter or remove any services definitions of a ContainerBuilder object.

    • They are always triggered on every HTTP requests made to the Symfony application.

    Help

    • https://symfony.com/doc/current/service_container/compiler_passes.html#main
    • https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

  • Compiler Passes

    Which of the following statements are true about the so-called compiler passes?

    Wrong

    • They allow to add, alter or remove any services definitions of a ContainerBuilder object.

    • They perform some optimization operations on a ContainerBuilder instance in order to generate the most efficient PHP code possible.

    • They check that all registered services definitions are valid and some required global parameters are not missing.

    The choices were

    • They perform some optimization operations on a ContainerBuilder instance in order to generate the most efficient PHP code possible.

    • They are always triggered on every HTTP requests made to the Symfony application.

    • They prevent the ContainerBuilder object from being compiled if they detect any circular references in services definitions.

    • They allow to add, alter or remove any services definitions of a ContainerBuilder object.

    • They check that all registered services definitions are valid and some required global parameters are not missing.

    Help

    • https://symfony.com/doc/current/service_container/compiler_passes.html#main
    • https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

  • Property access

    Consider the following code snippet:

    class Book
    {
        protected $title;
    }
    $book = new Book;

    How to retrieve the book title from $book?

    Correct

    • There's no way yet.

    The choices were

    • $book->title

    • There's no way yet.

    • $book.title

    • $book=>title

    Help

    http://php.net/manual/en/language.oop5.visibility.php

    There's no way yet.

  • MySQLi

    Consider the following code snippet:

    $query = "SELECT `first`, `last`, `phone` FROM `contacts` WHERE `first` LIKE 'John%'";
    $statement = mysqli_prepare($query);
    mysqli_stmt_execute($statement);
    ????
    while ($result = mysqli_stmt_fetch($statement)) { echo sprintf("Name: %s %s\n", $first, $last); echo sprintf("Phone: %s\n\n", $phone); }

    Which of the following statements is a valid replacement for the ???? in the above code snippet to execute successfully?

    Wrong

    • There is nothing to do! The $first, $last and $phone variables will become automatically defined if the SQL query execution was succesful.

    The choices were

    • mysqli_stmt_bind_result($statement, $first, $last, $phone);
    • A while loop fetching the row and assigning $first, $last and $phone their proper values.

    • mysqli_fetch_columns($statement, $first, $last, $phone);
    • There is nothing to do! The $first, $last and $phone variables will become automatically defined if the SQL query execution was succesful.

    Help

    • http://php.net/manual/en/book.mysqli.php
    • http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
    • http://php.net/manual/en/mysqli-stmt.bind-result.php

  • Reading from Arrays

    What will be the result of the following code?

    <?php
    use Symfony\Component\PropertyAccess\PropertyAccess;
    $accessor = PropertyAccess::createPropertyAccessor();
    $person = array( 'first_name' => 'Wouter', );
    $age = $accessor->getValue($person, 'age');

    Wrong

    • The value of $age will be null.

    The choices were

    • The value of $age will be null.

    • The value of $age will be 0.

    • A Symfony\Component\PropertyAccess\Exception\NoSuchIndexException will be thrown.

    • A Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException will be thrown.

    Help

    • https://symfony.com/doc/2.7/components/property_access.html#reading-from-arrays
    • https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php
    • https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L206

  • Provider

    What are the particularities of the InMemoryUserProvider security provider?

    Wrong

    • The users are not stored in database.

    • The users must have a plaintext password.

    The choices were

    • The users must have a plaintext password.

    • The users are not stored in database.

    • You need to add new user in the config.

    • The users have the same password.

    Help

    https://symfony.com/doc/2.x/security.html#b-configuring-how-users-are-loaded


  • Strict Variables Mode

    Consider the following Twig code snippet:

    The {{ color }} car!
    Twig

    What will be the result of evaluating this template when passing it the blue value for the color variable and when the strict_variables global setting is off?

    Correct

    • The template will be succesfully evaluated and the string The blue car! will be displayed in the web browser.

    The choices were

    • Twig will raise a Twig_Error_Runtime exception preventing the template from being evaluated.

    • The template will be succesfully evaluated and the string The blue car! will be displayed in the web browser.

    Help

    • https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Extension/Core.php#L1447-L1479
    • https://twig.symfony.com/doc/1.x/templates.html#variables
    • https://twig.symfony.com/doc/2.x/templates.html#variables
    The template will be succesfully evaluated and the string The blue car! will be displayed in the web browser.

  • Strict Variables Mode

    Consider the following Twig code snippet:

    The {{ color }} car!
    Twig

    What will be the result of evaluating this template without passing it a color variable when the strict_variables global setting is off?

    Correct

    • The template will be succesfully evaluated and the string The car! will be displayed in the web browser.

    The choices were

    • The template will be succesfully evaluated and the string The empty car! will be displayed in the web browser.

    • The template will be succesfully evaluated and the string The car! will be displayed in the web browser.

    • Twig will raise a Twig_Error_Runtime exception preventing the template from being evaluated.

    • The template will be partially evaluated and the string The will be displayed in the web browser.

    Help

    • https://twig.symfony.com/doc/1.x/templates.html#variables
    • https://twig.symfony.com/doc/2.x/templates.html#variables
    • https://twig.symfony.com/doc/2.x/api.html#environment-options
    • https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Extension/Core.php#L1447-L1479
    The template will be succesfully evaluated and the string The car! will be displayed in the web browser.

  • Console

    Given the following console table creation:

    <?php
    use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table;
    class MyCommand extends Command { // ... protected function execute(InputInterface $input, OutputInterface $output): int { $table = new Table($output); $table->setRows([['foo1', 'foo2']]); $table->render(); $table->appendRow(['bar1', 'bar2']);
    return 0; } }

    What will happen ?

    Wrong

    • The table will have two rows with two values each

    The choices were

    • An exception will be thrown

    • The table will have only one row with two values

    • The table will have two rows with two values each

    Help

    • https://symfony.com/doc/4.1/components/console/helpers/table.html
    • https://github.com/symfony/symfony/blob/0578fdf038f225524929373bf1b0d33129f1be13/src/Symfony/Component/Console/Helper/Table.php#L269

  • Console

    Given the following console table creation:

    <?php
    use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table;
    class MyCommand extends Command { // ... protected function execute(InputInterface $input, OutputInterface $output): int { $table = new Table($output); $table->setRows([['foo1', 'foo2']]); $table->render(); $table->appendRow(['bar1', 'bar2']);
    return 0; } }

    What will happen ?

    Wrong

    • The table will have only one row with two values

    The choices were

    • The table will have only one row with two values

    • The table will have two rows with two values each

    • An exception will be thrown

    Help

    • https://symfony.com/doc/4.1/components/console/helpers/table.html
    • https://github.com/symfony/symfony/blob/0578fdf038f225524929373bf1b0d33129f1be13/src/Symfony/Component/Console/Helper/Table.php#L269

  • Must-understand usage

    Which information is used to store a response that uses the must-understand directive?

    Correct

    • The status code

    The choices were

    • The status code

    • The value of the Etag directive

    • The value of the Expires directive

    • The value of the Last-Modified directive

    Help

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#must-understand

    The status code

  • Service Priority

    When configuring tags with priority, what service will come first when getting tagged items ?

    Correct

    • The service with the highest priority.

    The choices were

    • The service with the highest priority.

    • The service with the priority closest to 0.

    • The service with the lowest priority.

    Help

    • https://symfony.com/doc/5.x/service_container/tags.html#tagged-services-with-priority
    The service with the highest priority.

  • The Serialization Process

    What is normalization in the context of the Serializer Components ?

    Wrong

    • The process of converting an object into a string.

    The choices were

    • The process of converting an object into a string.

    • The process of converting a string into an object.

    • The process of converting an array of scalars into an object.

    • The process of converting an object into an array of scalars.

    Help

    • https://symfony.com/doc/5.x/components/serializer.html

  • Construct a route in PHP

    When declaring a route in PHP, what is the 1st argument of the constructor of the Route class?

    Correct

    • The path pattern to match.

    The choices were

    • The path pattern to match.

    • An array of options.

    • A condition that should evaluate to true for the route to match.

    • A required URI scheme or an array of restricted schemes.

    • The host pattern to match.

    • The required HTTP methods.

    • An array of requirements for parameters (regexes).

    • An array of default parameter values.

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Routing/Route.php#L62

    The path pattern to match.

  • FileLocator

    What is the first argument of the Symfony\Component\Config\FileLocator::locate method?

    Correct

    • The name of the file to look for.

    The choices were

    • The type of file to look for.

    • The name of the directory to look for.

    • The name of the configuration value to look for.

    • The name of the file to look for.

    Help

    https://symfony.com/doc/2.0/components/config/resources.html#locating-resources

    The name of the file to look for.

  • Translator

    What is the first argument of the constructor of Symfony\Component\Translation\Translator

    Correct

    • The locale

    The choices were

    • A translator provider

    • The translation directory

    • A translator loader

    • The locale

    Help

    • https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Translation/Translator.php#L72
    The locale

  • Node class property

    When writing a Twig_Test, what is a node_class for?

    Correct

    • The given test will be compiled into PHP primitives.

    The choices were

    • The given test will rely on a custom Twig_NodeVisitorInterface.

    • The given test will use a semantic validation in addition to the basic evaluation.

    • The node_class is a mandatory option to get defined in a Twig_Environment.

    • The given test will be compiled into PHP primitives.

    Help

    https://twig.symfony.com/doc/2.x/advanced.html#tests

    The given test will be compiled into PHP primitives.

  • PSR-0

    What is true about the PSR-0: Autoloading Standard?

    Wrong

    • The fully qualified class name MUST have one or more sub-namespace names.

    • PSR-0 is compatible with PEAR-style classnames.

    • The autoloader is registered with the spl_autoload_register() function.

    The choices were

    • PSR-0 is deprecated.

    • PSR-0 is compatible with PEAR-style classnames.

    • The autoloader is registered with the spl_autoload_register() function.

    • The fully qualified class name MUST have one or more sub-namespace names.

    Help

    The fully qualified class name MAY have one or more sub-namespace names.

    https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md


  • Run

    What is returned by the run() method of Symfony\Component\Process\Process?

    Correct

    • The exit status code

    The choices were

    • The exit status code

    • Nothing

    • 1

    • true or false

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Process/Process.php#L168

    The exit status code

  • Kernel class

    What are the arguments of the Symfony\Component\HttpKernel\Kernel constructor?

    Correct

    • The environment name of the application.

    • Whether to enable debugging or not.

    The choices were

    • Whether to enable caching or not.

    • The environment name of the application.

    • Whether to enable debugging or not.

    • The name of the application.

    • Whether to enable logging or not.

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpKernel/Kernel.php

    The environment name of the application. Whether to enable debugging or not.

  • Console

    Given the context where a command define three questions to ask and the following command test case is created to test it:

    use Symfony\Component\Console\Tester\CommandTester;
    class CommandTest { public function testExecute(): void { // ... $commandTester = new CommandTester($command); $commandTester->setInputs(['foo', 'bar']); $commandTester->setInputs(['one']); // ... $commandTester->execute(['command' => $command->getName()]); // ... } }

    Which values will be received as answers to the command interactive questions ?

    Correct

    • The command will receive foo as answer to its first question and bar as answer to its second question

    The choices were

    • The command will receive one as answer to its first question and bar as answer to its second question

    • An exception will be thrown

    • The command will receive foo as answer to its first question and bar as answer to its second question

    Help

    https://symfony.com/doc/3.2/components/console/helpers/questionhelper.html

    The command will receive foo as answer to its first question and bar as answer to its second question

  • Console

    Given the following console event subscriber:

    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    use Symfony\Component\Console\ConsoleEvents;
    class ConsoleListener implements EventSubscriberInterface { private AppChecker $appChecker;
    public function __construct(AppChecker $appChecker) { $this->appChecker = $appChecker; }
    public function onTerminate(ConsoleEvent $event): void { if (!$this->appChecker->isOk()) { $event->getCommand()->setCode(232); } }
    public static function getSubscribedEvents(): array { return [ ConsoleEvents::TERMINATE => 'onTerminate' ]; } }

    What can be said about the setCode command method ?

    Correct

    • The code above will result to an error

    The choices were

    • This method doesn't exist

    • The code above will result to an error

    • The code above will change the command exit status code to 232

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Command/Command.php#L252

    The code above will result to an error

  • Dynamic filters

    We assume using a filter in a template with:

    {{ 'foo'|a_path_b }}
    Twig

    with the filter definition:

    $filter = new TwigFilter('*_path_*', function (???) {
        // ...
    });

    How the arguments will be passed to the callable ?

    Correct

    • The callable function will be called with the given parameters respectively:

      ('a', 'b', 'foo')

    The choices were

    • The callable function will be called with the given parameters respectively:

      ('foo', ['a', 'b'])

    • The callable function will be called with the given parameters respectively:

      ('foo', ['patterns' => ['a', 'b']])

    • The callable function will be called with the given parameters respectively:

      ('foo', 'a', 'b')

    • The callable function will be called with the given parameters respectively:

      ('a', 'b', 'foo')

    Help

    https://twig.symfony.com/doc/2.x/advanced.html#dynamic-filters

    The callable function will be called with the given parameters respectively: ('a', 'b', 'foo')

  • Twig Internals

    Which of the following Twig internal objects is responsible for converting a tokens stream into a meaningful tree of nodes (aka AST or Abstract Syntax Tree)?

    Correct

    • The Parser

    The choices were

    • The Compiler

    • The Parser

    • The Lexer

    • The Environment

    Help

    https://twig.symfony.com/doc/1.x/internals.html

    The Parser

  • Twig Internals

    Which of the following Twig internal objects is responsible for transforming an AST (Abstract Syntax Tree) into PHP code?

    Wrong

    • The Parser

    The choices were

    • The Environment

    • The Lexer

    • The Parser

    • The Compiler

    Help

    http://twig.symfony.com/doc/internals.html


  • Node compilation

    The Compiler is used to transform a Node into a valid PHP class, but which class actually call the compiler?

    Correct

    • The Node

    The choices were

    • The Node

    • The Lexer

    • The Compiler

    • The Environment

    Help

    • https://github.com/twigphp/Twig/blob/1.x/src/Node/Node.php#L115
    • https://github.com/twigphp/Twig/blob/1.x/src/Node/BlockNode.php#L29
    • https://twig.symfony.com/doc/1.x/internals.html#the-compiler
    The Node

  • Node compilation

    The Compiler is used to transform a Node into a valid PHP class, but which class actually calls the compiler?

    Correct

    • The Node

    The choices were

    • The Compiler

    • The Node

    • The Environment

    • The Lexer

    Help

    • https://github.com/twigphp/Twig/blob/1.x/src/Node/Node.php#L115
    • https://github.com/twigphp/Twig/blob/1.x/src/Node/BlockNode.php#L29
    • https://twig.symfony.com/doc/1.x/internals.html#the-compiler
    The Node

  • Twig Internals

    Which of the following Twig internal objects is responsible for tokenizing the template source code into smaller pieces for easier processing?

    Correct

    • The Lexer

    The choices were

    • The Environment

    • The Lexer

    • The Compiler

    • The Parser

    Help

    http://twig.symfony.com/doc/internals.html

    The Lexer

  • Twig Internals

    Which of the following Twig internal objects is responsible for transforming an AST (Abstract Syntax Tree) into PHP code?

    Wrong

    • The Lexer

    The choices were

    • The Parser

    • The Environment

    • The Lexer

    • The Compiler

    Help

    http://twig.symfony.com/doc/internals.html


  • Core Symfony

    In a Symfony application, what is the element that links the core components together ?

    Correct

    • The FrameworkBundle.

    The choices were

    • The FrameworkBundle.

    • The Container.

    • The Kernel.

    Help

    • https://symfony.com/components/Framework%20Bundle
    The FrameworkBundle.

  • FlashBag usage

    Which statement is true about FlashBag::add() and FlashBag::set()?

    Correct

    • The FlashBag::add() method allow to add a single message while FlashBag::set() allow to add a set of messages while overriding the existing ones

    The choices were

    • The FlashBag::add() method allow to add a set of messages while FlashBag::set() allow to add a single message

    • They behave the same way

    • The FlashBag::add() method allow to add a single message while FlashBag::set() allow to add a set of messages while overriding the existing ones

    • The FlashBag::add() method allow to add a single message while FlashBag::set() allow to add a set of message using a callback

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php

    The FlashBag::add() method allow to add a single message while FlashBag::set() allow to add a set of messages while overriding the existing ones

  • Validator API

    Consider the following code snippet:

    $result = $validator->validate($someObject);

    What will be the expected outcome when running this piece of code?

    Correct

    • The $result variable will contain a valid implementation of the Symfony\Component\Validator\ConstraintViolationListInterface interface.

    The choices were

    • The $result variable will contain a simple boolean value (true  or false).

    • The validate method will throw a Symfony\Component\Validator\Exception\ValidatorException exception if the given object's state doesn't match its mapped validation constraint rules.

    • The $result variable will contain a valid implementation of the Symfony\Component\Validator\ConstraintViolationListInterface interface.

    • The $result variable will contain an array of Symfony\Component\Validator\ConstraintViolation instances.

    • The $result variable will contain null because the validate method must always return void.

    Help

    https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/ConstraintViolationList.php https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Validator/ValidatorInterface.php

    The $result variable will contain a valid implementation of the Symfony\Component\Validator\ConstraintViolationListInterface interface.

  • Service

    Which mechanism allows to aggregate services by domain in the service container?

    Correct

    • Tag

    The choices were

    • Scope

    • Abstraction

    • Tag

    • Listener

    Help

    • https://symfony.com/doc/current/reference/dic_tags.html
    • https://symfony.com/doc/current/components/dependency_injection/tags.html
    Tag

  • Services subscription

    Which interface must be implemented to configure a service locator?

    Correct

    • Symfony\Contracts\Service\ServiceSubscriberInterface

    The choices were

    • Symfony\Components\DependencyInjection\ServiceSubscriberInterface

    • Symfony\Contracts\DependencyInjection\ServiceLocatorSubscriberInterface

    • Symfony\Contracts\Service\ServiceSubscriberInterface

    • Symfony\Contracts\DependencyInjection\ServiceSubscriberInterface

    Help

    • https://symfony.com/doc/5.0/service_container/service_subscribers_locators.html#defining-a-service-subscriber
    • https://github.com/symfony/symfony/blob/5.0/src/Symfony/Contracts/Service/ServiceSubscriberInterface.php
    Symfony\Contracts\Service\ServiceSubscriberInterface

  • Write

    What is the method to transform a PHP array into a YAML representation?

    Wrong

    • Symfony\Component\Yaml\Yaml::write

    The choices were

    • Symfony\Component\Yaml\Yaml::write

    • Symfony\Component\Yaml\Yaml::dump

    • Symfony\Component\Yaml\Yaml::yaml

    • Symfony\Component\Yaml\Yaml::toYaml

    Help

    https://symfony.com/doc/2.3/components/yaml/introduction.html#writing-yaml-files


  • Exception

    What is the exception class used when an error occurs during parsing with Symfony\Component\Yaml\Yaml::parse method?

    Correct

    • Symfony\Component\Yaml\Exception\ParseException

    The choices were

    • Symfony\Component\Yaml\Exception\ParsingException

    • Symfony\Component\Yaml\ParsingException

    • Symfony\Component\Yaml\Exception\ParseException

    • Symfony\Component\Yaml\ParseException

    Help

    • http://symfony.com/doc/current/components/yaml/introduction.html#reading-yaml-files
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Yaml/Exception/ParseException.php
    Symfony\Component\Yaml\Exception\ParseException

  • ValidatorInterface::validate return

    What is the return type of the Symfony\Component\Validator\Validator\ValidatorInterface::validate method?

    Correct

    • Symfony\Component\Validator\ConstraintViolationListInterface

    The choices were

    • array<string>

    • array<Symfony\Component\Validator\ConstraintViolationInterface>

    • Doctrine\Common\Collections\Collection<Symfony\Component\Validator\ConstraintViolationInterface>

    • Symfony\Component\Validator\ConstraintViolationListInterface

    Help

    https://github.com/symfony/symfony/blob/de9b7e53148d5ba4242f24bdd47f184bbfe10691/src/Symfony/Component/Validator/Validator/ValidatorInterface.php#L36

    Symfony\Component\Validator\ConstraintViolationListInterface

  • Listener

    What is the listener that handles security exceptions and when appropriate, helps the user to authenticate?

    Correct

    • Symfony\Component\Security\Http\Firewall\ExceptionListener

    The choices were

    • Symfony\Component\Security\Http\Firewall\SecurityListener

    • Symfony\Component\Security\Http\Firewall\AuthenticationListener

    • Symfony\Component\Security\Http\Firewall\AuthListener

    • Symfony\Component\Security\Http\Firewall\ExceptionListener

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

    Symfony\Component\Security\Http\Firewall\ExceptionListener

  • LanguageType choices

    By default, which function provides the choices of the Symfony\Component\Form\Extension\Core\Type\LanguageType form type?

    Correct

    • Symfony\Component\Intl\Languages::getNames()

    The choices were

    • Symfony\Component\Intl\Languages::getNames()

    • Symfony\Component\Intl\Intl::getLanguageBundle()->getLanguageNames()

    • Symfony\Component\Form\Extension\Core\Type\LanguageType::getChoices()

    • Intl::getLanguages()

    Help

    https://symfony.com/doc/4.3/reference/forms/types/language.html#choices

    Symfony\Component\Intl\Languages::getNames()

  • Kernel Version

    How to get the kernel version?

    Wrong

    • Symfony\Component\HttpKernel\Kernel::getVersion()

    The choices were

    • Symfony\Component\HttpKernel\Kernel::getVersion()
    • Symfony\Component\HttpKernel\Kernel::VERSION
    • $kernel->getVersion();
    • It's not possible

    • Symfony\Component\HttpKernel\Kernel::VERSION_ID

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpKernel/Kernel.php#L61


  • Event

    What is the base class for events thrown in the HttpKernel component.

    Correct

    • Symfony\Component\HttpKernel\Event\KernelEvent

    The choices were

    • Symfony\Component\HttpKernel\Event\HttpKernelEvent

    • Symfony\Component\HttpKernel\HttpKernelEvent

    • Symfony\Component\HttpKernel\BaseKernelEvent

    • Symfony\Component\HttpKernel\KernelEvent

    • Symfony\Component\HttpKernel\Event\BaseKernelEvent

    • Symfony\Component\HttpKernel\Event\KernelEvent

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpKernel/Event/KernelEvent.php
    Symfony\Component\HttpKernel\Event\KernelEvent

  • Mocking the session

    Which classes exist to help you test some code that is using a Symfony\Component\HttpFoundation\Session\Session object?

    Wrong

    • Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage

    • Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage

    • Symfony\Component\HttpFoundation\Session\Storage\MockSessionStorage

    The choices were

    • Symfony\Component\HttpFoundation\Session\Storage\MockMemorySessionStorage

    • Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage

    • Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage

    • Symfony\Component\HttpFoundation\Session\Storage\MockDatabaseSessionStorage

    • Symfony\Component\HttpFoundation\Session\Storage\MockSessionStorage

    Help

    https://symfony.com/doc/2.3/components/http_foundation/session_testing.html


  • Symfony Requests

    In which namespace does the Request object live ?

    Correct

    • Symfony\Component\HttpFoundation

    The choices were

    • Symfony\Component\HttpClient

    • Symfony\Component\HttpFoundation

    • \ (built in class)

    • Symfony\Component\HttpKernel

    Help

    • https://symfony.com/doc/current/components/http_foundation.html
    Symfony\Component\HttpFoundation

  • TextType children

    Which of these form types does not inherit from the Symfony\Component\Form\Extension\Core\Type\TextType type ?

    Wrong

    • Symfony\Component\Form\Extension\Core\Type\PasswordType

    • Symfony\Component\Form\Extension\Core\Type\LocaleType

    • Symfony\Component\Form\Extension\Core\Type\HiddenType

    • Symfony\Component\Form\Extension\Core\Type\RangeType

    • Symfony\Component\Form\Extension\Core\Type\SearchType

    The choices were

    • Symfony\Component\Form\Extension\Core\Type\HiddenType

    • Symfony\Component\Form\Extension\Core\Type\PasswordType

    • Symfony\Component\Form\Extension\Core\Type\RangeType

    • Symfony\Component\Form\Extension\Core\Type\LocaleType

    • Symfony\Component\Form\Extension\Core\Type\SearchType

    Help

    https://symfony.com/doc/current/reference/forms/types.html


  • BirthdayType parent.

    Which of the following form types is the parent of the Symfony\Component\Form\Extension\Core\Type\BirthdayType form type ?

    Correct

    • Symfony\Component\Form\Extension\Core\Type\DateType

    The choices were

    • Symfony\Component\Form\Extension\Core\Type\DateTimeType

    • Symfony\Component\Form\Extension\Core\Type\TimeType

    • Symfony\Component\Form\Extension\Core\Type\DateType

    Help

    http://symfony.com/doc/current/reference/forms/types/birthday.html

    Symfony\Component\Form\Extension\Core\Type\DateType

  • ChoiceType choice_loader option

    Which interface should be implemented when you want to set the choice_loader option of the Symfony\Component\Form\Extension\Core\Type\ChoiceType form type ?

    Wrong

    • Symfony\Component\Form\Extension\Core\ChoiceLoaderInterface

    The choices were

    • Symfony\Component\Form\ChoiceLoaderInterface

    • Symfony\Component\Form\Extension\Core\ChoiceLoaderInterface

    • Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface

    Help

    http://symfony.com/doc/current/reference/forms/types/choice.html#choice-loader


  • "Tester" command class

    Which Tester class should you use to test a console event (e.g. the ConsoleEvents::TERMINATE event)?

    Wrong

    • Symfony\Component\Console\Tester\CommandTester

    The choices were

    • Symfony\Component\Console\Tester\ApplicationTester

    • Symfony\Component\Console\Tester\CommandTester

    • Symfony\Component\Console\Tester\CommandCompletionTester

    Help

    https://symfony.com/doc/current/console.html#testing-commands


  • Default option's mode

    Given the following definition:

    new InputOption('foo', 'f')

    What is the foo option's mode?

    Wrong

    • Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL

    The choices were

    • Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY

    • Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL

    • Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED

    • Symfony\Component\Console\Input\InputOption::VALUE_NEGATABLE

    • Symfony\Component\Console\Input\InputOption::VALUE_NONE

    Help

    https://github.com/symfony/console/blob/2.3/Input/InputOption.php#L32


  • InputOption constants

    Which of the following constants exist?

    Correct

    • Symfony\Component\Console\Input\InputOption::VALUE_NONE

    • Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL

    • Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED

    • Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY

    • Symfony\Component\Console\Input\InputOption::VALUE_NEGATABLE

    The choices were

    • Symfony\Component\Console\Input\InputOption::VALUE_NONE

    • Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY

    • Symfony\Component\Console\Input\InputOption::VALUE_NEGATABLE

    • Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL

    • Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED

    Help

    https://github.com/symfony/console/blob/6.0/Input/InputOption.php https://symfony.com/doc/6.0/console/input.html#using-command-options

    Symfony\Component\Console\Input\InputOption::VALUE_NONE Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY Symfony\Component\Console\Input\InputOption::VALUE_NEGATABLE

  • InputArgument constants

    Which of the following constants do not exist?

    Wrong

    • Symfony\Component\Console\Input\InputArgument::IS_ARRAY

    • Symfony\Component\Console\Input\InputArgument::REQUIRED

    • Symfony\Component\Console\Input\InputArgument::OPTIONAL

    The choices were

    • Symfony\Component\Console\Input\InputArgument::REQUIRED

    • Symfony\Component\Console\Input\InputArgument::NEGATABLE

    • Symfony\Component\Console\Input\InputArgument::IS_ARRAY

    • Symfony\Component\Console\Input\InputArgument::NONE

    • Symfony\Component\Console\Input\InputArgument::OPTIONAL

    Help

    https://github.com/symfony/console/blob/6.0/Input/InputArgument.php#L24-L26 https://symfony.com/doc/6.0/console/input.html#using-command-arguments


  • Console events

    Which of these events are not built-in?

    Wrong

    • Symfony\Component\Console\ConsoleEvents::TERMINATE

    • Symfony\Component\Console\ConsoleEvents::COMMAND

    • Symfony\Component\Console\ConsoleEvents::ERROR

    The choices were

    • Symfony\Component\Console\ConsoleEvents::HANDLE_COMMAND

    • Symfony\Component\Console\ConsoleEvents::TERMINATE

    • Symfony\Component\Console\ConsoleEvents::COMMAND

    • Symfony\Component\Console\ConsoleEvents::VIEW

    • Symfony\Component\Console\ConsoleEvents::ERROR

    Help

    • https://symfony.com/doc/4.0/components/console/events.html

  • Console events

    Which of these events are not built-in?

    Wrong

    • Symfony\Component\Console\ConsoleEvents::ERROR

    • Symfony\Component\Console\ConsoleEvents::VIEW

    • Symfony\Component\Console\ConsoleEvents::HANDLE_COMMAND

    The choices were

    • Symfony\Component\Console\ConsoleEvents::HANDLE_COMMAND

    • Symfony\Component\Console\ConsoleEvents::TERMINATE

    • Symfony\Component\Console\ConsoleEvents::VIEW

    • Symfony\Component\Console\ConsoleEvents::COMMAND

    • Symfony\Component\Console\ConsoleEvents::ERROR

    Help

    • https://symfony.com/doc/4.0/components/console/events.html

  • HttpClient

    Which abstraction HTTPClient is interoperable with?

    Correct

    • Symfony contracts

    • HTTPlug v2

    • HTTPlug v1

    • PSR-18

    The choices were

    • HTTPlug v1

    • HTTPlug v2

    • PSR-18

    • Symfony contracts

    Help

    • https://symfony.com/doc/5.0/components/http_client.html
    Symfony contracts HTTPlug v2 HTTPlug v1 PSR-18

  • Available Response Classes.

    Which of the following are valid Symfony response classes extending the base Symfony\Component\HttpFoundation\Response class?

    Correct

    • StreamedResponse

    • BinaryFileResponse

    • RedirectResponse

    • JsonResponse

    The choices were

    • ImageFileResponse

    • StreamedResponse

    • BinaryResponse

    • ImageResponse

    • RedirectedResponse

    • FileResponse

    • StreamResponse

    • JsonResponse

    • BinaryFileResponse

    • NotFoundResponse

    • RedirectResponse

    Help

    • http://symfony.com/doc/current/components/http_foundation/introduction.html#redirecting-the-user
    • http://symfony.com/doc/current/components/http_foundation/introduction.html#streaming-a-response
    • http://symfony.com/doc/current/components/http_foundation/introduction.html#serving-files
    • http://symfony.com/doc/current/components/http_foundation/introduction.html#creating-a-json-response
    StreamedResponse BinaryFileResponse RedirectResponse JsonResponse

  • Response Structure

    What is the Response structure ?

    Correct

    • Status-Line CRLF
      Headers CRLF
      CRLF
      Message-body

    The choices were

    • Status-Line
      Headers CRLF
      Message-body
    • Status-Line CRLF
      Headers CRLF
      CRLF
      Message-body
    • Status-Line
      Headers
      Message-body
    • Status-Line
      CRLF
      Headers
      CRLF
      Message-body

    Help

    https://datatracker.ietf.org/doc/html/rfc2616#section-6

    Status-Line CRLF Headers CRLF CRLF Message-body

  • Output buffering

    Which of the following operations must occur prior to any output being sent to the client (assuming output buffering is disabled)

    Wrong

    • Starting a session

    The choices were

    • Modifying session data

    • Starting a session

    • Sending HTTP Headers

    • Processing GET and POST data

    • Manipulating Cookie data

    Help

    https://www.php.net/manual/en/function.header.php


  • Service

    What is the way to always get a new instance of a service?

    Correct

    • Setting the option shared to false.

    The choices were

    • Setting the option scope to prototype.

    • Setting the option shared to false.

    • Setting the option singleton to false.

    • Setting the option scope to request.

    • By passing an instance of the CompilerPass to the pushCompilerPass of a ContainerBuilder.

    Help

    • https://symfony.com/doc/current/cookbook/service_container/shared.html
    Setting the option shared to false.

  • Injection Types

    What are the recommended types of injections when injecting a service dependency into another?

    Wrong

    • Setter injection

    • Constructor injection

    • Property injection

    • Immutable-setter Injection

    The choices were

    • Setter injection

    • Immutable-setter Injection

    • Property injection

    • Constructor injection

    • Getter injection

    Help

    • https://symfony.com/doc/7.0/service_container/injection_types.html
    • Immutable-setter Injection was introduced in 4.3
    • using property injection is not recommanded

  • Built-In Value Resolvers

    Which of the following value resolvers are shipped with the HttpKernel component?

    Wrong

    • SessionValueResolver

    • RequestValueResolver

    • UserValueResolver

    The choices were

    • RequestValueResolver

    • VariadicValueResolver

    • DefaultValueResolver

    • SessionValueResolver

    • ServiceValueResolver

    • RequestAttributeValueResolver

    • UserValueResolver

    Help

    https://symfony.com/doc/current/controller/argument_value_resolver.html#built-in-value-resolvers


  • Service access

    Which exception is thrown when a service is not defined while using ContainerInterface::get()?

    Wrong

    • ServiceUndefinedException

    The choices were

    • ServiceGetException

    • UndefinedServiceException

    • ServiceUnavailableException

    • ServiceUndefinedException

    • ServiceNotFoundException

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/DependencyInjection/Container.php#L221


  • PHP streams

    What does this script do ?

    $opts = [ 'http' =>
                   [ 'method' => 'POST',
                     'header' => 'Content-Type: application/x-www-form-urlencoded',
                     'content' => 'a=foo&b=bar'
                   ]
             ];
    $ctx = stream_context_create($opts);
    file_get_contents('http://myserver/page.php', false, $ctx);

    Correct

    • Sends a form to a server

    The choices were

    • A classical Web request to a server

    • Display a webpage into an other

    • Sends a form to a server

    • Reads the content of a webpage and store in into a file

    Help

    • http://php.net/manual/en/context.http.php
    • http://php.net/manual/en/function.stream-context-create.php
    Sends a form to a server

  • Validation constraints

    Which of the followings are not validation constraints?

    Wrong

    • Search

    • File

    The choices were

    • All

    • File

    • Search

    • Password

    Help

    • http://symfony.com/doc/current/reference/constraints.html

  • Process status

    What are the availables process status constants in the Symfony\Component\Process\Process class ?

    Correct

    • STATUS_STARTED

    • STATUS_READY

    • STATUS_TERMINATED

    The choices were

    • STATUS_STARTED

    • STATUS_READY

    • STATUS_FAILED

    • STATUS_TERMINATED

    • STATUS_SENT

    • STATUS_STOPPED

    • STATUS_INITIALIZED

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/Process/Process.php#L29

    STATUS_STARTED STATUS_READY STATUS_TERMINATED

  • Security

    Which protocols secure HTTP?

    Correct

    • SSL

    • TLS

    The choices were

    • SSL

    • SMTP

    • TLS

    • SSH

    Help

    • https://tools.ietf.org/html/rfc2818
    • https://tools.ietf.org/html/rfc6101
    SSL TLS

  • Route compilation

    Which exception is thrown when a Route defined with /page/{foo}/{foo} cannot be compiled?

    Wrong

    • RouteCompilationException

    The choices were

    • LogicException

    • RouteCompilationException

    • RuntimeException

    • InvalidRouteCompilationContextException

    • InvalidArgumentException

    Help

    https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Routing/RouteCompiler.php#L39


  • FormRegistry usage

    Which type is returned by FormRegistry::getType()?

    Correct

    • ResolvedFormTypeInterface

    The choices were

    • ResolvedFormTypeInterface

    • FormInterface

    • ResolvedForm

    • GuessedType

    Help

    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Form/FormRegistry.php#L60
    ResolvedFormTypeInterface

  • Request Structure

    What is the request structure ?

    Correct

    • Request-Line CRLF Headers CRLF CRLF Body

    The choices were

    • Request-Line Headers CRLF Body

    • Request-Line CRLF Headers CRLF CRLF Body

    • Request-Line Headers CRLF CRLF Body

    • Request-Line

      Headers

      Body

    Help

    https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

    Request-Line CRLF Headers CRLF CRLF Body

  • Template controller

    What is the main purpose of the built-in Symfony\Bundle\FrameworkBundle\Controller:TemplateController controller?

    Correct

    • Render templates that do not require a controller, such as static pages.

    The choices were

    • Render templates that do not require a controller, such as static pages.

    • Render custom error templates.

    • Extract translation keys/strings from templates.

    • Provide information about the template being rendered for the profiler.

    Help

    • https://symfony.com/doc/current/cookbook/templating/render_without_controller.html
    Render templates that do not require a controller, such as static pages.

  • Role

    Which ROLE allows you to impersonate a user?

    Correct

    • ROLE_ALLOWED_TO_SWITCH

    The choices were

    • ROLE_ADMIN_ALLOWED_TO_SWITCH

    • ROLE_ADMIN

    • ROLE_ALLOWED_TO_SWITCH

    • ROLE_USER_ALLOWED_TO_SWITCH

    Help

    • http://symfony.com/doc/current/security/impersonating_user.html
    ROLE_ALLOWED_TO_SWITCH

  • SecurityBundle

    Given the following access_control configuration:

    access_control:
        - { path: ^/profile, roles: ROLE_USER, requires_channel: https }
        - { path: ^/profile, roles: ROLE_ADMIN }
    YAML

    The requested url is http://mydomain.tld/profile. Which role is needed to access to /profile ?

    Wrong

    • ROLE_ADMIN

    The choices were

    • Neither ROLE_USER nor ROLE_ADMIN, an exception is thrown

    • ROLE_ADMIN

    • ROLE_USER

    Help

    requires_channel allows to make a redirection, it's not involved in request matching

    • https://symfony.com/doc/2.7/security/access_control.html

  • Validation constraints

    Which of the following elements can contain validation constraints?

    Wrong

    • Public properties

    • Classes

    • Public getters/issers

    The choices were

    • Public getters/issers

    • Public properties

    • Private and protected getters/issers

    • Classes

    • Private and protected properties

    Help

    • https://symfony.com/doc/6.0/validation.html#getters

  • Interfaces

    Which of the following language structures are allowed in an interface?

    Wrong

    • Public methods signatures.

    • Traits imports.

    • Public concrete methods.

    • Public constants.

    The choices were

    • Private (or protected) methods signatures.

    • Static attributes.

    • Public constants.

    • Traits imports.

    • Public methods signatures.

    • Private (or protected) constants.

    • Public concrete methods.

    Help

    https://www.php.net/manual/en/language.oop5.interfaces.php


  • Interfaces

    Which of the following language structures are allowed in an interface?

    Wrong

    • Public methods signatures.

    • Private (or protected) constants.

    • Public constants.

    The choices were

    • Public methods signatures.

    • Traits imports.

    • Public constants.

    • Private (or protected) constants.

    • Private (or protected) methods signatures.

    • Static attributes.

    • Public concrete methods.

    Help

    https://www.php.net/manual/en/language.oop5.interfaces.php


  • Attributes and Methods Scopes

    Which of the following are supported visibilities for class attributes and methods in PHP ?

    Correct

    • Protected

    • Private

    • Public

    The choices were

    • Global

    • Private

    • Public

    • Protected

    • Friend

    Help

    http://php.net/manual/en/language.oop5.visibility.php

    Protected Private Public

  • Object definitions

    How do you call a variable defined at an object level ?

    Correct

    • Property

    The choices were

    • Attribute

    • ClassVar

    • Argument

    • Property

    Help

    • https://www.php.net/manual/en/language.oop5.properties.php
    Property

  • Console helpers

    What are the console helpers ?

    Correct

    • Process helper

    • Question helper

    • Formatter helper

    The choices were

    • Process helper

    • Answer helper

    • Formatter helper

    • Validator helper

    • Question helper

    • Dialog helper

    Help

    https://symfony.com/doc/5.0/components/console/helpers/index.html

    Process helper Question helper Formatter helper

  • Console Script

    What is the format of the bin/console file?

    Correct

    • Plain PHP script

    The choices were

    • Binary file

    • Plain PHP script

    • PHAR file

    • Self-executable compressed file

    Help

    • https://github.com/symfony/recipes/blob/main/symfony/console/5.3/bin/console#L1-L2
    Plain PHP script

  • Redirection

    What does the 308 HTTP status code stand for?

    Correct

    • Permanent redirect

    The choices were

    • Temporary redirect

    • Permanent redirect

    • Found (moved temporarily)

    • Moved permanently

    Help

    • https://tools.ietf.org/html/rfc7538
    Permanent redirect

  • Usage

    Which method is used to generate an hashed password?

    Correct

    • PasswordHasherInterface::hash

    The choices were

    • PasswordHasherInterface::new

    • PasswordHasherInterface::encode

    • PasswordHasherInterface::hash

    • PasswordHasherInterface::crypt

    Help

    https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/PasswordHasher/PasswordHasherInterface.php

    PasswordHasherInterface::hash

  • Clock PSR

    Which PSR described a common interface for reading the system clock, implemented by the Clock component since Symfony 6.2?

    Correct

    • PSR-20

    The choices were

    • PSR-20

    • PSR-8

    • PSR-4

    • PSR-17

    Help

    https://www.php-fig.org/psr/psr-20/

    PSR-20

  • Form events

    Which event listeners can the following form have?

    <?php
    namespace App\Form\Type;
    // ... use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; // ...
    class LocationType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('address', TextareaType::class) ->add('zipcode', TextType::class) ->add('city', TextType::class) ->add('country', TextType::class); }
    public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Location::class, 'inherit_data' => true, ]); } }

    Wrong

    • POST_SUBMIT

    • PRE_SUBMIT

    • SUBMIT

    • POST_SET_DATA

    • PRE_SET_DATA

    The choices were

    • PRE_SUBMIT

    • PRE_SET_DATA

    • POST_SUBMIT

    • SUBMIT

    • POST_SET_DATA

    Help

    https://symfony.com/doc/current/form/inherit_data_option.html


  • Safe HTTP verbs.

    Which HTTP verbs are safe ?

    Wrong

    • POST

    • DELETE

    • PUT

    • GET

    • PATCH

    The choices were

    • OPTIONS

    • HEAD

    • DELETE

    • COPY

    • GET

    • PUT

    • POST

    • LINK

    • PATCH

    • TRACE

    Help

    • https://tools.ietf.org/html/rfc7231#section-4.2.1
    • https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods

  • HTTP method

    Consider the following HTML generated from a Symfony form:

    <form method="POST" action="/">
        <input type="hidden" name="_method" value="PUT" />
    </form>
    HTML

    Which HTTP method will be present in the Symfony Request object assuming HTTP methods overriding setting is turned on?

    Wrong

    • POST

    The choices were

    • PATCH

    • GET

    • PUT

    • POST

    Help

    • https://symfony.com/doc/4.1/form/action_method.html (see "Note" at the bottom of the page)

  • PHP version

    Since which PHP version can you use anonymous functions ?

    Correct

    • PHP 5.3

    The choices were

    • PHP 5.5

    • PHP 5.3

    • PHP 7.0

    • PHP 5.4

    • PHP 5.6

    Help

    • https://www.php.net/manual/en/functions.anonymous.php
    • https://www.php.net/ChangeLog-5.php#PHP_5_3
    PHP 5.3

  • Http methods

    Which of these methods aren't mentioned as commonly implemented in the RFC7231 (previously RFC2616 ?

    Correct

    • PATCH

    • LINK

    The choices were

    • TRACE

    • LINK

    • CONNECT

    • PATCH

    Help

    https://datatracker.ietf.org/doc/html/rfc7231#section-4.3

    PATCH LINK

  • Verbosity

    What are the console verbosity levels?

    Correct

    • OutputInterface::VERBOSITY_QUIET
    • OutputInterface::VERBOSITY_VERBOSE
    • OutputInterface::VERBOSITY_DEBUG
    • OutputInterface::VERBOSITY_NORMAL
    • OutputInterface::VERBOSITY_VERY_VERBOSE

    The choices were

    • OutputInterface::VERBOSITY_VERBOSE
    • OutputInterface::VERBOSITY_NO_DEBUG
    • OutputInterface::VERBOSITY_VERY_VERBOSE
    • OutputInterface::VERBOSITY_DEBUG
    • OutputInterface::VERBOSITY_QUIET
    • OutputInterface::VERBOSITY_NONE
    • OutputInterface::VERBOSITY_VERY_VERY_VERBOSE
    • OutputInterface::VERBOSITY_NORMAL

    Help

    • http://symfony.com/doc/current/console/verbosity.html
    OutputInterface::VERBOSITY_QUIETPHP OutputInterface::VERBOSITY_VERBOSEPHP OutputInterface::VERBOSITY_DEBUGPHP OutputInterface::VERBOSITY_NORMALPHP OutputInterface::VERBOSITY_VERY_VERBOSEPHP

  • Options deprecations

    If you define an option as deprecated thanks to OptionsResolver::setDeprecated(), when will the deprecation message appear?

    Correct

    • Only if the option is provided by the user

    The choices were

    • When running tests

    • Only if the option is provided by the user

    • Always

    Help

    https://symfony.com/doc/current/components/options_resolver.html#deprecating-the-option

    Only if the option is provided by the user

  • Security

    Which sentences are true about security events ?

    Correct

    • On a session-based authentication, the security.authentication.success is dispatched on each page when the user is authenticated

    • security.authentication.failure is launched when an authentication attempt fails

    The choices were

    • security.logout_on_change is triggered when the user use the logout feature of the firewall

    • On a session-based authentication, the security.authentication.success is dispatched on each page when the user is authenticated

    • When you log in via an http basic header, a security.interactive_login event is triggered

    • security.authentication.failure is launched when an authentication attempt fails

    Help

    • https://symfony.com/doc/4.3/components/security/authentication.html
    On a session-based authentication, the security.authentication.success is dispatched on each page when the user is authenticated security.authentication.failure is launched when an authentication attempt fails

  • Security

    Which sentences are true about security events?

    Correct

    • On a session-based authentication, the security.authentication.success is dispatched on each page when the user is authenticated

    • security.authentication.failure is launched when an authentication attempt fails

    The choices were

    • When you log in via an http basic header, a security.interactive_login event is triggered

    • security.authentication.failure is launched when an authentication attempt fails

    • On a session-based authentication, the security.authentication.success is dispatched on each page when the user is authenticated

    • security.logout_on_change is triggered when the user use the logout feature of the firewall

    Help

    https://symfony.com/doc/4.x/components/security/authentication.html#authentication-events

    On a session-based authentication, the security.authentication.success is dispatched on each page when the user is authenticated security.authentication.failure is launched when an authentication attempt fails

  • Normalizers

    Which of the followings are built-in normalizers?

    Correct

    • ObjectNormalizer

    • DataUriNormalizer

    • GetSetMethodNormalizer

    • DateTimeNormalizer

    • CustomNormalizer

    The choices were

    • GetSetMethodNormalizer

    • DateTimeNormalizer

    • JsonNormalizer

    • CustomNormalizer

    • DataUriNormalizer

    • XmlNormalizer

    • DateNormalizer

    • TimeNormalizer

    • ObjectNormalizer

    Help

    • https://github.com/symfony/symfony/tree/3.1/src/Symfony/Component/Serializer/Normalizer
    ObjectNormalizer DataUriNormalizer GetSetMethodNormalizer DateTimeNormalizer CustomNormalizer

  • mkdir

    What is returned by the Symfony\Component\Filesystem\Filesystem::mkdir method if the directory has been successfully created ?

    Correct

    • Nothing

    The choices were

    • true or false

    • A string with the directory path

    • The FileSystem object

    • Nothing

    Help

    • https://symfony.com/doc/2.7/components/filesystem.html#mkdir
    • https://github.com/symfony/filesystem/blob/2.7/Filesystem.php#L85
    Nothing

  • Assertions

    Given an object Foo which implements \Countable and the method count() which return 1, what will be displayed?

    {% if foo is empty %}
        {{ foo.get('name') }}
    {% endif %}
    Twig

    Correct

    • Nothing

    The choices were

    • The value of foo.get('name')

    • Nothing

    Help

    https://twig.symfony.com/doc/1.x/tests/empty.html

    Nothing

  • Array functions

    What is the output of the following PHP script?

    <?php
    $values = [ 15, 12, '15', 34, 15 => 25 ];
    $key = array_search('15', $values);
    if (!$key) { echo "Not found"; } else { // gettype() will return either 'string' or 'integer' echo $key . ' - ' . strtolower(gettype($values[$key])); }

    Correct

    • Not found

    The choices were

    • Not found

    • 2 - string

    • 4 - integer

    • 0 - integer

    Help

    • https://www.php.net/array
    • https://php.net/manual/en/function.array-search.php
    • https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
    Not found

  • Events usage

    Which class can be used as argument when listening to kernel.controller_arguments?

    Wrong

    • None, this event does not exist

    The choices were

    • FilterControllerEvent

    • FilterControllerArgumentsEvent

    • None, this event does not exist

    • ControllerArgumentsEvent

    • ControllerEvent

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php


  • Finder

    What is the finder service id ?

    Correct

    • None of them, the finder is not a service

    The choices were

    • None of them, the finder is not a service

    • finder.iterator

    • finder

    • finder.finder

    Help

    The finder is not a service due to its stateful nature

    • https://symfony.com/doc/3.3/components/finder.html#usage
    None of them, the finder is not a service

  • The "with" tag

    Given that Twig is configured with "strict_variables" set to true.

    Consider the following Twig snippet:

    {% with %}
        {% set maxItems = 7 %}
        {# ... #}
    {% endwith %}
    {# ... #}
    {% for i in 1..maxItems %} {# ... #} {% endfor %}
    Twig

    Will the Twig template work as expected?

    Correct

    • No. The template will display an error because the maxItems variable is not defined outside the with tag.

    The choices were

    • Yes

    • No. The template will display an error because the maxItems variable is not defined outside the with tag.

    • No. The template won't iterate from 1 to 7. It will execute the for loop just one time (where i is 1).

    • No. The template will display an error because the with tag is not defined.

    Help

    Twig 1.28 (November 2016) introduced a new with tag that allows to create different scopes in the same template. Variables defined inside a with tag are not available outside of it. See http://twig.symfony.com/doc/tags/with.html

    No. The template will display an error because the maxItems variable is not defined outside the with tag.

  • Button usage

    Could an event subscriber be added to a Button

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/ButtonBuilder.php#L181

    No

  • Coding standards

    Does the following code follow the Twig coding standard?

    {{foo}}
    Twig

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://twig.symfony.com/doc/1.x/coding_standards.html

    No

  • Safe usage

    Is the Safe header considered as a secure mechanism?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://datatracker.ietf.org/doc/html/rfc8674#name-security-considerations

    No

  • `render_esi`

    Does the render_esi Twig function throw an exception when the request is not coming from a gateway cache?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/6.0/http_cache/esi.html

    No

  • Route compilation

    Could a Route defined with /page/{foo}/{foo} path be compiled?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Routing/RouteCompiler.php#L39
    • https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Routing/RouteCompiler.php#L137
    No

  • Listener usage

    Could a button receive an event listener?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/ButtonBuilder.php#L176

    No

  • Helpers

    Could you use Helper::strlen() to obtain the length of a string?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://github.com/symfony/symfony/blob/5.4/UPGRADE-6.0.md#console
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Console/Helper/Helper.php
    • The Helper::strlen() method has been removed, consider using Helper::width() or Helper::length() instead.
    No

  • Session access

    Does the session service still available?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://github.com/symfony/symfony/blob/5.4/UPGRADE-6.0.md#frameworkbundle
    • The session alias has been deprecated, consider using Request::getSession() or RequestStack::getSession() instead.
    No

  • Template Inheritance

    Is this Twig template valid ?

    <h1>{{ title }}</h1>
    {% extends 'base.html.twig' %}
    {% block content %} <p>{{ content }}</p> {% endblock %}
    Twig

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://twig.symfony.com/doc/1.x/tags/extends.html
    • https://twig.symfony.com/doc/2.x/tags/extends.html
    • https://twig.symfony.com/doc/3.x/tags/extends.html
    No

  • The NotBlank validation constraint

    Will the following snippet throw an InvalidArgumentException ?

    use Symfony\Component\Validator\Validation;
    use Symfony\Component\Validator\Constraints\NotBlank;
    $expectedNotBlank = "0";
    $validator = Validation::createValidator(); $violations = $validator->validate($expectedNotBlank, [new NotBlank()]);
    if (0 !== count($violations)) { throw new InvalidArgumentException('The value is blank !'); }

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/reference/constraints/NotBlank.html

    No

  • Safe usage

    Could the safe directive be considered as a reliable indicator that the end user is a child?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://datatracker.ietf.org/doc/html/rfc8674#section-1

    No

  • Expires usage

    Given the following header, will the resource be considered as fresh?

    Expires: 0
    Plain text

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc7234#section-5.3
    • https://developer.mozilla.org/en/docs/Web/HTTP/Headers/Expires
    No

  • Permissions

    Is the following code valid?

    <?php
    use Symfony\Component\Filesystem\Filesystem;
    $fs = new Filesystem(); $fs->mkdir('/srv/app', 777); $fs->permissions('/srv/app', 775);

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/Filesystem/Filesystem.php#L65
    • Consider using chmod()
    No

  • Expires usage

    Is the following header value valid?

    Expires: - 7 hours
    Plain text

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc7234#section-5.3
    • https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.1
    • https://developer.mozilla.org/en/docs/Web/HTTP/Headers/Expires
    No

  • FrozenParameterBag usage

    Could a parameter be removed from a FrozenParameterBag?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php

    No

  • Route compilation

    Could a Route defined with /page/{2foo} path be compiled?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Routing/RouteCompiler.php#L39

    No

  • Cache usage

    Is it considered as a good practice to store in cache a response using the 511 status code?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://datatracker.ietf.org/doc/html/rfc6585#section-6
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511
    No

  • The IsFalse validation constraint

    Will the following snippet throw an InvalidArgumentException?

    <?php
    use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Constraints\IsFalse;
    $expectedFalse = '0';
    $validator = Validation::createValidator(); $violations = $validator->validate($expectedFalse, [new IsFalse()]);
    if (0 !== count($violations)) { throw new InvalidArgumentException('The value is not false !'); }

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/2.3/reference/constraints/IsFalse.html

    No

  • ImmutableEventDispatcher usage

    Could subscribers be removed from an ImmutableEventDispatcher?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    No

  • Cookie creation

    Could a Cookie be created from a string?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/3.3/components/http_foundation.html#setting-cookies
    • https://github.com/symfony/symfony/blob/3.3/src/Symfony/Component/HttpFoundation/Cookie.php

  • Anonymous user

    It is possible to handle anonymous users in a custom voter ?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/security/authenticator_manager.html#granting-anonymous-users-access-in-a-custom-voter


  • Testing PHP errors

    Consider the following simple PHPUnit test:

    /**
     * @expectedException PHPUnit_Framework_Error
     */
    public function testFailingInclude()
    {
        include 'not_existing_file.php';
    }

    Will the previous code successfully test the error that will happen? (Note: remember that in most PHP versions, this kind of errors doesn't trigger an exception).

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    By default, PHPUnit converts PHP errors, warnings, and notices that are triggered during the execution of a test to an exception. See https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors


  • ReverseContainer usage

    Could a service identifier be returned from a ReverseContainer if the service is not tagged as container.reversible and defined as private?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/DependencyInjection/ReverseContainer.php

    No

  • AttributeBag usage

    Could the session.attribute_bag service be used?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/5.4/UPGRADE-6.0.md#frameworkbundle

    No

  • Container configuration

    Could the build time be configured?

    Wrong

    • No

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/3.4/reference/configuration/kernel.html#container-build-time


  • Composer scripts

    Given the context the --no-scripts option is used with composer install and the Composer version set to < 2.1, will the autoload_runtime.php file be generated?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/5.3/components/runtime.html#usage

    No

  • Must-understand usage

    Could a response that use the must-understand directive be stored if the cache does not understand the directive?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#directives

    No

  • Doctrine bridge

    Given the context where the doctrine transport is used, could the connection be pinged and reconnected (if closed) each time a message is handled?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/messenger.html#middleware-for-doctrine


  • Immutable response

    Should an immutable cache-control header be used with non-secure protocol such as HTTP?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc8246
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
    No

  • Extract usage

    Should extract be used on $_GET, $_FILES and other unsecured data sources?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://www.php.net/manual/en/function.extract.php

    No

  • Route compilation

    Could a Route defined with /page/{_fragments} path be compiled?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Routing/RouteCompiler.php#L39


  • Twig template

    Does this syntax perform any check?

    {{ foo['bar'] }}
    Twig

    Wrong

    • No

    The choices were

    • Yes, if foo is an object then if it's an array

    • No

    • Yes if foo is an array

    Help

    https://twig.symfony.com/doc/1.x/templates.html#variables


  • Cache usage

    Could a response that use the 301 status code be cached without taking in consideration its header directives?

    Wrong

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301
    No

  • Functions & filters usage

    Could functions and filters be defined at runtime without any overhead?

    Wrong

    • No

    The choices were

    • Yes

    • No

    Help

    https://twig.symfony.com/doc/1.x/recipes.html#defining-undefined-functions-and-filters-on-the-fly


  • Question handling

    Could a hidden response be validated?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.5/components/console/helpers/questionhelper.html#validating-a-hidden-response


  • Serialization handling

    Could interfaces and/or abstract classes be serialized?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/4.1/components/serializer.html#serializing-interfaces-and-abstract-classes
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorResolverInterface.php

  • RouteCollection usage

    Does using Router::getRouteCollection() considered as a best practice when checking if a route exist?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • By default, if the RouteCollection is not loaded, the collection is fully loaded from the loader that trigger the cache compilation.
    • https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/Routing/Router.php#L133
    No

  • RedirectResponse

    Is it possible to create a Symfony\Component\HttpFoundation\RedirectResponse with the 201 status code?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    • https://tools.ietf.org/html/rfc7231#section-6.3.2
    • https://github.com/symfony/symfony/blob/2c14c5fca7182f11abf0a692e471326f14119c29/src/Symfony/Component/HttpFoundation/RedirectResponse.php#L41
    • https://github.com/symfony/symfony/blob/2c14c5fca7182f11abf0a692e471326f14119c29/src/Symfony/Component/HttpFoundation/Response.php#L1177

  • AbstractSessionListener usage

    Given the AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER header directive is set, is an expiration date defined in the response?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/4.1/http_cache.html#http-caching-and-user-sessions
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php#L68
    No

  • Transport setup

    Are the following Mailer configuration and environment variable definition valid?

    # .env
    MAILER_DSN=smtp://u$er:$ecret@smtp.example.com:25
    Plain text
    # config/packages/mailer.yaml
    framework:
      mailer:
        dsn: '%env(MAILER_DSN)%'
    YAML

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.x/mailer.html#transport-setup

    No

  • ContainerConfigurator usage

    Could environment variables be configured using ContainerConfigurator?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://github.com/symfony/dependency-injection/blob/5.3/Loader/Configurator/ContainerConfigurator.php#L198


  • MockHttpClient usage

    Could a MockResponse be issued outside of MockHttpClient?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/HttpClient/Response/MockResponse.php#L131

    No

  • HTTP

    Does the Pragma HTTP response header allow to efficiently transmit cache instructions in HTTP/1.1 ?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Pragma
    No

  • Safe content

    Is the following code valid when returning a "safe version" of a content?

    <?php
    # ...
    final class FooAction { #[Route(path: '/', name: 'home', methods: ['GET']) public function __invoke(Request $request): Response { $safeContent = # ...
    if ($request->preferSafeContent()) { $response = new Response($safeContent); $response->setContentSafe();
    return $response; }
    return new Response(...); } }

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/5.1/components/http_foundation.html#safe-content-preference
    • https://github.com/symfony/symfony/blob/5.1/src/Symfony/Component/HttpFoundation/Request.php#L1711
    • https://github.com/symfony/symfony/blob/5.1/src/Symfony/Component/HttpFoundation/Response.php#L1242

  • Async request

    Given the following code snippet:

    // ...
    /** @var Symfony\Contracts\HttpClient\HttpClientInterface $client */ $response = $client->request('GET', 'http://releases.ubuntu.com/18.04.2/ubuntu-18.04.2-desktop-amd64.iso');
    $this->onDownloadComplete($response);
    // ...
    public function onDownloadComplete(Response $response): void { $this->logger->info('Download completed.'); }

    Is the onDownloadComplete method guaranteed to be called when the .iso file had been downloaded completely?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://symfony.com/doc/6.0/http_client.html#making-requests

    No

  • CSRF token generation

    Is the Form component required to generate a csrf token in templates?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.1/security/csrf.html#generating-and-checking-csrf-tokens-manually

    No

  • Service visibility

    Could a service definition be hidden using setPrivate()?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/3.4/service_container.html#public-versus-private-services
    • https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/DependencyInjection/Definition.php#L626
    No

  • Visibilities

    Is it possible for a PHP class to be declared private or protected in order to limit its scope to the current namespace only ?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    http://php.net/manual/en/language.oop5.visibility.php

    No

  • Lazy services

    Given the context where the ProxyManager bridge is not installed, could lazy services be defined and used as lazy services?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.7/service_container/lazy_services.html#configuration

    No

  • Encoders

    Is the salt property needed for all encoders ?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/2.x/reference/configuration/security.html

    No

  • Service configurator

    Could service configurators use __invoke() to configure a service?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.3/service_container/configurators.html#using-the-configurator


  • Ip constraint

    Will the following snippet throw an InvalidArgumentException?

    <?php
    use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Constraints\Ip;
    $ip = "2607:f0d0:1002:51::4"; // This is a valid IPv6 address
    $validator = Validation::createValidator(); $violations = $validator->validate($ip, [new Ip()]);
    if (0 !== count($violations)) { throw new InvalidArgumentException(); }

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/reference/constraints/Ip.html#version


  • Form - Button

    Could a Button have a child?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/ButtonBuilder.php#L84
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Button.php#L120
    No

  • Badge usage

    Could the current firewall be retrieved from a BadgeInterface implementation?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/tree/5.1/src/Symfony/Component/Security/Http/Authenticator/Passport/Badge

    No

  • Enumeration - Transformation

    Is the following code valid?

    <?php
    enum Suit: string { case Hearts = 'H'; case Diamonds = 'D'; case Clubs = 'C'; case Spades = 'S'; }
    $h = Suit::tryFrom('E');

    Wrong

    • No

    The choices were

    • Yes

    • No

    Help

    https://www.php.net/manual/en/backedenum.tryfrom.php


  • Container configuration

    Could the build hash of the container be configured?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    • https://symfony.com/doc/3.4/reference/configuration/kernel.html#container-build-time
    • The container.build_hash parameter is exposed but cannot be configured, the hash is obtained thanks to ContainerBuilder::hash() during the compilation/dump phase of the container.
    No

  • Route matching

    Considering the following definition of route:

    use Symfony\Component\Routing\RouteCollection;
    use Symfony\Component\Routing\Route;
    $collection = new RouteCollection(); $collection->add('_hello', new Route('/hello/{username}', array( '_controller' => 'App\Controller\DemoController:hello', ), array( 'username' => '.+', )));

    Will the /hello/John/Doe URI match this route?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/4.4/routing.html#slash-characters-in-route-parameters


  • ContainerParameterBag usage

    Could a parameter be removed from a Symfony\Component\DependencyInjection\ParameterBag\ContainerBag?

    Correct

    • No

    The choices were

    • Yes

    • No

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php

    No

  • Signature compatibility rules

    Will the following code raise an error or a warning?

    <?php
    class A { public function foo($arg1) { // ... } }
    class B extends A { public function foo($arg1, $arg2) { // ... } }
    $b = new B();

    Wrong

    • No

    The choices were

    • Yes, the declaration of B::foo($arg1, $arg2) must be compatible with A::foo($arg1)

    • Yes, class B cannot inherit from class A

    • No

    Help

    https://www.php.net/manual/en/language.oop5.basic.php#language.oop.lsp


  • Routing

    Given the following routing configuration:

    // src/Controller/BlogController.php
    namespace App\Controller;
    use Symfony\Component\Routing\Annotation\Route;
    class BlogController { /** * @Route("/blog/articles", name="blog_articles") */ public function listArticles(int $page) { // ... } }

    Does the path /blog/articles?page=1 can display the page without error ?

    Correct

    • No

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.7/routing.html
    No

  • Constants vs Configuration Options

    According to the official Symfony Best Practices Guide, is it recommended to store global settings that rarely change in raw PHP constants instead of storing them under a configuration dedicated file?

    Wrong

    • No

    The choices were

    • No

    • Yes

    Help

    https://symfony.com/doc/current/best_practices.html#use-constants-to-define-options-that-rarely-change


  • class

    With the following class definition what will be returned by \NamespaceName\Example\ClassName::class?

    <?php
    namespace NamespaceName\Example;
    class ClassName { }

    Correct

    • NamespaceName\Example\ClassName

    The choices were

    • NamespaceName\Example\ClassName

    • \NamespaceName\Example\ClassName

    • NamespaceName\Example

    • ClassName

    Help

    • https://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class
    NamespaceName\Example\ClassName

  • PHP - Object assignment

    What will be the output ?

    <?php
    class SimpleClass {
    }
    $instance = new SimpleClass();
    $assigned = $instance; $reference =& $instance;
    $instance->var = '$assigned will have this value';
    $instance = null; // $instance and $reference become null
    var_dump($instance); var_dump($reference); var_dump($assigned);

    Correct

    • NULL
      NULL
      object(SimpleClass)#1 (1) {
        ["var"]=>
        string(30) "$assigned will have this value"
      }

    The choices were

    • An error

    • NULL
      NULL
      object(SimpleClass)#1 (1) {
        ["var"]=>
        string(30) "$assigned will have this value"
      }

    Help

    • https://www.php.net/manual/en/language.oop5.basic.php
    • https://3v4l.org/lO3oJ#v7.4.0
    NULL NULL object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" }

  • printf

    What is the output ?

    $name = 'Jean Luc';
    $age  = 9;
    printf("My name is %2$.4s and I'm %1$02d", $age, $name);

    Correct

    • My name is Jean and I'm 09

    The choices were

    • My name is Jean 9 and I'm Luc

    • My name is 9 and I'm Jean Luc

    • My name is Jean and I'm 09

    • My name is $Jean Luc and I'm $9

    • My name is Jean Luc and I'm 9

    Help

    http://php.net/manual/en/function.printf.php

    My name is Jean and I'm 09

  • Usage

    Which type of Message can be used to MessageConverter::toEmail() in order to create an Email?

    Correct

    • Message

    • RawMessage

    The choices were

    • RawMessage

    • Message

    • string

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Mime/MessageConverter.php#L31

    Message RawMessage

  • FrozenParameterBag usage

    Which exception is thrown when clearing parameters from a FrozenParameterBag?

    Correct

    • LogicException

    The choices were

    • InvalidArgumentException

    • RuntimeException

    • LogicException

    • BadMethodCallException

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php

    LogicException

  • FrozenParameterBag usage

    Which exception is thrown when removing a parameter from a FrozenParameterBag?

    Correct

    • LogicException

    The choices were

    • InvalidArgumentException

    • BadMethodCallException

    • RuntimeException

    • LogicException

    Help

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php

    LogicException

  • Translator configuration

    What is the purpose of the logging: true option in the translator config?

    framework:
        translator:
            logging: true
    YAML

    Correct

    • Log a message when Symfony doesn't find a translation for the given locale.

    The choices were

    • Translate all log messages in the default locale.

    • Log a message when Symfony translate a string in the given locale.

    • Log a message when the given local is not configured.

    • Log a message when Symfony doesn't find a translation for the given locale.

    Help

    https://symfony.com/doc/2.6/reference/configuration/framework.html#logging

    Log a message when Symfony doesn't find a translation for the given locale.

  • Twig loaders definition

    What are Twig loaders responsible for?

    Correct

    • Loaders are responsible for loading templates from a resource name.

    The choices were

    • Loaders are responsible for loading token parsers.

    • Loaders are responsible for loading extensions.

    • Loaders are responsible for loading environments such as Twig_Evironment.

    • Loaders are responsible for loading templates from a resource name.

    Help

    https://twig.symfony.com/doc/2.x/api.html#loaders

    Loaders are responsible for loading templates from a resource name.

  • Type Guesser Confidence

    What are the "confidence" constants available in the Symfony\Component\Form\Guess\Guess class?

    Correct

    • LOW_CONFIDENCE

    • HIGH_CONFIDENCE

    • MEDIUM_CONFIDENCE

    • VERY_HIGH_CONFIDENCE

    The choices were

    • UNKNOWN_CONFIDENCE

    • HIGH

    • VERY_VERY_LOW_CONFIDENCE

    • UNKNOWN

    • MEDIUM

    • VERY_VERY_HIGH

    • VERY_HIGH_CONFIDENCE

    • VERY_VERY_HIGH_CONFIDENCE

    • LOW

    • VERY_LOW_CONFIDENCE

    • LOW_CONFIDENCE

    • MEDIUM_CONFIDENCE

    • VERY_LOW

    • HIGH_CONFIDENCE

    • VERY_VERY_LOW

    • VERY_HIGH

    Help

    • https://symfony.com/doc/2.7/form/type_guesser.html
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Guess/Guess.php
    LOW_CONFIDENCE HIGH_CONFIDENCE MEDIUM_CONFIDENCE VERY_HIGH_CONFIDENCE

  • Standard

    The Symfony validator is based on…?

    Correct

    • JSR 303

    The choices were

    • RFC 2616

    • PSR-2

    • JSR 303

    • CVE-2015-2308

    Help

    http://symfony.com/doc/current/book/validation.html

    JSR 303

  • Array and loops

    Which interface(s) should an Object implement to be usable in a foreach statement?

    Wrong

    • IteratorAggregate

    • ArrayAccess

    The choices were

    • IteratorAggregate

    • ArrayAccess

    • Traversable

    Help

    https://www.php.net/manual/en/reserved.interfaces.php


  • Array behaviour

    Which interface should an object implement to use brackets notation as an array?

    Wrong

    • IteratorAggregate

    The choices were

    • Iterator

    • Traversable

    • IteratorAggregate

    • ArrayAccess

    Help

    https://www.php.net/manual/en/class.arrayaccess.php


  • Generator in response

    use Symfony\Component\HttpFoundation\JsonResponse;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\Routing\Annotation\Route;
    class DefaultController { #[Route('/', name: 'default')] public function default(Request $request) { return new JsonResponse([ 'data' => $this->getData(), ]); }
    private function getData(): \Generator { yield 'foo'; yield 'bar'; yield 'baz'; } }

    Wrong

    • It will return {"data":["foo","bar","baz"]}

    The choices were

    • It will throw an \InvalidArgumentException

    • It will return {"data":["foo","bar","baz"]}

    • It will return {"data":{}}

    Help

    • To make use of generators in a JsonReponse you'll have to use StreamedJsonResponse introduced in 6.3.
    • https://symfony.com/blog/new-in-symfony-6-3-dx-improvements-part-2#streamed-json-responses
    • https://phpsandbox.io/e/x/lq86x?layout=EditorPreview&defaultPath=%2F&theme=dark&showExplorer=no&openedFiles=

  • Console

    Given the following console event subscriber:

    <?php
    use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Console\ConsoleEvents;
    class ConsoleListener implements EventSubscriberInterface { private AppChecker $appChecker;
    public function __construct(AppChecker $appChecker) { $this->appChecker = $appChecker; }
    public static function getSubscribedEvents() { return [ ConsoleEvents::TERMINATE => 'setCode' ]; }
    public function setCode(ConsoleEvent $event): void { if (!$this->appChecker->isOk()) { $event->getCommand()->setCode(232); } } }

    What will be the result of setCode method call?

    Wrong

    • It will change the command exit status code to 232

    The choices were

    • It will change the command exit status code to 232

    • It will trigger an error

    Help

    https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/Console/Command/Command.php#L248


  • HTTP Expiration Model

    What can happen to an HTTP response whose Cache-Control header value equals private, max-age=120?

    Correct

    • It will be cached by the web browser.

    The choices were

    • It will only be cached by any shared proxy servers including reverse proxies.

    • It prevents the response from being cached by the web browser or any shared proxies.

    • It will be cached by the web browser.

    • It will be cached by a reverse proxy cache like Varnish.

    • It will be cached by any proxy server.

    Help

    https://tools.ietf.org/html/rfc2616#page-79

    It will be cached by the web browser.

  • CardScheme Constraint

    What does the CardScheme Constraint stand for ?

    Correct

    • It validates that a card number is valid for a given credit card company

    The choices were

    • It validates that a card number is valid for a given credit card company

    • It doesn't exist

    • It validates if a credit card is a VISA one

    • It validates a credit card number

    Help

    https://symfony.com/doc/2.2/reference/constraints/CardScheme.html

    It validates that a card number is valid for a given credit card company

  • Max-forwards usage

    What should do an intermediary if the Max-Forwards header is equal to 0?

    Correct

    • It should not forward the request

    The choices were

    • It should not forward the request

    • Nothing

    • This header doesn't exist

    • It should forward the request no matter the header value

    Help

    https://tools.ietf.org/html/rfc7231#section-5.1.2

    It should not forward the request

  • The FrameworkBundle AbstractController Class

    Which of the following statements is true about the AbstractController class located in the FrameworkBundle bundle?

    Wrong

    • It must always be the parent class for every single controller of the application.

    The choices were

    • It must always be the parent class for every single controller of the application.

    • It declares a controller as a service.

    • It provides helper methods.

    • It can provide by default any services of the application.

    Help

    • https://github.com/symfony/symfony/blob/3.3/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
    • https://symfony.com/doc/current/controller.html

  • Default command name

    What is the default command of a Symfony/Component/Console/Application?

    In other words, what is the default value of the Symfony\Component\Console\Application::$defaultCommand property?

    Wrong

    • It is mandatory to specify a default command name when creating a Symfony\Component\Console\Application.

    The choices were

    • help

    • It is mandatory to specify a default command name when creating a Symfony\Component\Console\Application.

    • version

    • list

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Console/Application.php#L96 https://symfony.com/doc/6.0/components/console/changing_default_command.html


  • CSRF Protection

    With de the default configuration, how to enable CSRF protection on a form ?

    Correct

    • It is enabled by default.

    The choices were

    • By adding the csrf_token option to the form type.

    • By adding the csrf_token option to the form view.

    • It is enabled by default.

    • By adding the csrf_protection option to the form type.

    Help

    • https://symfony.com/doc/current/reference/configuration/framework.html
    It is enabled by default.

  • Options

    Which of the following are true about Symfony\Component\OptionsResolver\Options?

    Correct

    • It is an interface.

    • The OptionsResolver class implements Options.

    The choices were

    • It is an abstract class.

    • The OptionsResolver class implements Options.

    • It is an interface.

    • The OptionsResolver class extends Options.

    Help

    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/OptionsResolver/Options.php
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/OptionsResolver/OptionsResolver.php
    It is an interface. The OptionsResolver class implements Options.

  • Access Decision Manager

    How does the AccessDecisionManager behave when configured with a consensus voting strategy?

    Correct

    • It grants access if there is at least a majority of all the voters granting access.

    The choices were

    • It grants access if over two-thirds of voters answer the access is granted.

    • It grants access as soon as there is one voter granting access.

    • It grants access if there is at least a majority of all the voters granting access.

    • It only grants access if none of the voters deny access.

    Help

    https://symfony.com/doc/2.x/security/voters.html#changing-the-access-decision-strategy

    It grants access if there is at least a majority of all the voters granting access.

  • Normalization

    What is the purpose of Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::fixXmlConfig ?

    Correct

    • It ensures that single XML elements are turned into an array

    • It normalizes XML element name (e.g. pluralizing the key used in XML)

    The choices were

    • It applies a custom function to an XML element if an error occurs

    • It normalizes XML element name (e.g. pluralizing the key used in XML)

    • It ensures that single XML elements are turned into an array

    • It always applies a custom function to an XML element

    Help

    http://symfony.com/doc/current/components/config/definition.html#normalization

    It ensures that single XML elements are turned into an array It normalizes XML element name (e.g. pluralizing the key used in XML)

  • BirthdayType overriding.

    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 ?

    Correct

    • It defaults the years option to 120 years ago to the current year.

    The choices were

    • It defaults the years option to 120 years ago to the current year.

    • It adds a little "bithday cake" icon right before the widget.

    • Those form types does not inherit from each other.

    • This is only semantical, there is no real difference between them.

    Help

    http://symfony.com/doc/current/reference/forms/types/birthday.html

    It defaults the years option to 120 years ago to the current year.

  • Inheritance type check

    Which of the following assertions are true about the instanceof keyword?

    Wrong

    • It checks if a variable value is an instance of a dedicated class.

    • It checks if a variable value is an instance of a class that implements a certain interface.

    The choices were

    • It checks if a variable value is an instance of a class that implements a certain interface.

    • It checks if a variable value is an iterable data structure.

    • It checks if a variable value is of type object.

    • It checks if a variable value is an instance of a dedicated class.

    Help

    • http://www.php.net/instanceof

  • Console

    Which sentence is true about the ConsoleLogger shipped in the console component ?

    Correct

    • It allows to display log messages to stdout

    The choices were

    • It allows to display log messages to stdout

    • It allows to log messages (formatted in a simpler format than Monolog default log format) into a file without having to install Monolog

    • It allows to log messages (formatted with Monolog default log format) into a file without having to install Monolog

    Help

    • https://symfony.com/doc/2.5/components/console/logger.html
    It allows to display log messages to stdout

  • Autowiring

    What is the purpose of the autowire configuration flag in a service definition?

    Correct

    • It allows implicit dependencies registration based on the service constructor's typehint.

    The choices were

    • It allows the service to be automatically called on some kernel events.

    • It allows to get ride of the a circular reference error for the service.

    • It allows implicit dependencies registration based on the service constructor's typehint.

    Help

    https://symfony.com/doc/current/components/dependency_injection/autowiring.html

    It allows implicit dependencies registration based on the service constructor's typehint.

  • Constraint

    Which of the following are Symfony built-in validation constraint?

    Correct

    • IsNull

    • Blank

    • NotNull

    • NotBlank

    The choices were

    • Null

    • IsNull

    • NotNull

    • Blank

    • IsBlank

    • NotBlank

    Help

    • http://symfony.com/doc/current/reference/constraints.html
    IsNull Blank NotNull NotBlank

  • Request usage

    Which exception is thrown if Request::getClientIps() detect that ips are not consistent?

    Wrong

    • InvalidArgumentException

    The choices were

    • LogicException

    • InconsistentIpsException

    • ConflictingHeadersException

    • InvalidArgumentException

    • RuntimeException

    Help

    https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/HttpFoundation/Request.php#L798


  • Wrap operation

    What is the purpose of the wrap method of the AbstractString class?

    Correct

    • Instantiate multiple objects of the String component in one call by passing an array of strings as an argument

    The choices were

    • Instantiate multiple objects of the String component in one call by passing an array of strings as an argument

    • To concatenate multiple strings in one, like the \implode(...) native method

    • To compress strings passed as arguments to minimize memory consumption when dealing with gigantic strings

    Help

    https://github.com/symfony/symfony/blob/5.0/src/Symfony/Component/String/AbstractString.php

    Instantiate multiple objects of the String component in one call by passing an array of strings as an argument

  • Storing Web Assets

    According to the official Symfony Best Practices Guide, where do you have to store your assets?

    Correct

    • Inside the assets/ directory.

    The choices were

    • Inside the public/ directory.

    • Inside the assets/ directory.

    • Inside the src/Resources/public/ directory.

    Help

    • https://symfony.com/doc/current/best_practices.html#web-assets
    • https://symfony.com/doc/6.0/frontend/encore/simple-example.html
    Inside the assets/ directory.

  • Options variants.

    Which of the following are not built-in option variants ?

    Wrong

    • InputOption::VALUE_OPTIONAL

    • InputOption::VALUE_NONE

    • InputOption::VALUE_REQUIRED

    • InputOption::VALUE_IS_ARRAY

    The choices were

    • InputOption::VALUE_NOT_REQUIRED

    • InputOption::VALUE_IS_ARRAY

    • InputOption::VALUE_NONE

    • InputOption::VALUE_REQUIRED

    • InputOption::VALUE_OPTIONAL

    • InputOption::VALUE_IS_MULTIPLE

    Help

    • http://symfony.com/doc/current/console/input.html#using-command-options

  • Dynamic routes

    Given the following route attribute, to display a blog post:

    #[Route('/blog/{post<[0-9]+>}', name:'view_blog_post')]

    how to retrieve the post id ?

    Wrong

    • Injecting $post into the controller action:

      public function viewBlogPost(int $post): Response
      {
          //...
      }

      $post will contain the post id

    • public function viewBlogPost(Request $request): Response
      {
          $postId = $request->attributes->get('post');
      //... }
    • public function viewBlogPost(Request $request): Response
      {
          $postId = $request->attributes->post;
      //... }

    The choices were

    • public function viewBlogPost(Request $request): Response
      {
          $postId = $request->attributes->post;
      //... }
    • public function viewBlogPost(Request $request): Response
      {
          $postId = $request->route->get("post");
      //... }
    • public function viewBlogPost(Request $request): Response
      {
          $postId = $request->route->post;
      //... }
    • Injecting $post into the controller action:

      public function viewBlogPost(int $post): Response
      {
          //...
      }

      $post will contain the post id

    • public function viewBlogPost(Request $request): Response
      {
          $postId = $request->attributes->get('post');
      //... }

    Help

    • https://symfony.com/doc/5.2/routing.html
    • https://github.com/symfony/symfony/blob/7fa617d4175e08a3d8e1cb5d67aa4523ad034dd8/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php#L126

  • LocaleListener

    What is the aim of the Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest() listener on kernel.request event?

    Correct

    • Initializes the locale based on the current request.

    The choices were

    • Find the user locale based on the user session.

    • Initializes the locale based on the current request.

    • Save the current locale in a cookie

    Help

    • https://github.com/symfony/symfony/blob/3f43534332046a141a179184eb58620b7e3d9ed3/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php#L56
    Initializes the locale based on the current request.

  • RouterListener

    What is the aim of the Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest() listener on kernel.request event?

    Correct

    • Initializes the context from the request and sets request attributes based on a matching route.

    The choices were

    • Initializes the context from the request and sets request attributes based on a matching route.

    • Find the correct URL to generate for a route to create a redirect response.

    • Checks if the user is allowed to use the current route.

    Help

    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php#L91
    Initializes the context from the request and sets request attributes based on a matching route.

  • Status Codes

    What do 1xx codes stand for ?

    Correct

    • Informational

    The choices were

    • Client Error

    • They don't exist.

    • Server Error

    • Informational

    Help

    https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1

    Informational

  • Form buttons

    Given the context where a form needs to contain multiple buttons, where shouldn't the buttons be defined?

    Correct

    • In the template

    The choices were

    • In the controller

    • In the template

    • In the form type

    Help

    https://symfony.com/doc/2.x/form/multiple_buttons.html

    In the template

  • Application-Related Configuration

    According to the official Symfony Best Practices Guide, where should the application specific configuration parameters be stored?

    Correct

    • In the config/services.yaml file.

    The choices were

    • In the .app.yml file at the root of the project directory.

    • In the config/parameters.yaml file.

    • In the src/Kernel.php file.

    • In global environment variables.

    • In the config/services.yaml file.

    Help

    http://symfony.com/doc/4.0/best_practices/configuration.html#application-related-configuration

    In the config/services.yaml file.

  • Storing Informations

    Where should sensitive informations (like API tokens) be stored ?

    Correct

    • In an .env file like .env.local.

    The choices were

    • In config/parameters.yaml.

    • In config/services.yaml.

    • In an .env file like .env.local.

    Help

    • https://symfony.com/doc/current/configuration/secrets.html
    In an .env file like .env.local.

  • Form inheritance.

    What should you do in order to use the form inheritance mechanism ?

    Correct

    • Implement the getParent method of the Symfony\Component\Form\FormTypeInterface.

    The choices were

    • Declare your form as a service and define the parent property on it.

    • Implement the getParent method of the Symfony\Component\Form\FormTypeInterface.

    • Set the inherit_data option to true.

    • Use the PHP built-in class inheritance.

    Help

    http://symfony.com/doc/current/form/create_custom_field_type.html

    Implement the getParent method of the Symfony\Component\Form\FormTypeInterface.

  • ETag validation

    Which Request header is used to check the ETag validity ?

    Correct

    • If-None-Match

    The choices were

    • If-None-Match

    • Last-Modified

    • Etag

    • Cache-Control

    Help

    http://symfony.com/doc/current/http_cache/validation.html#validation-with-the-etag-header

    If-None-Match

  • Types

    Among the following, which one is not a built-in form type?

    Correct

    • IbanType

    The choices were

    • PasswordType

    • MoneyType

    • IbanType

    • NumberType

    Help

    http://symfony.com/doc/current/reference/forms/types.html

    IbanType

  • Is user logged in

    Which role allows you to check that a user is logged in (whatever the means, ex: remember_me cookie, login form, etc)?

    Correct

    • IS_AUTHENTICATED

    • IS_AUTHENTICATED_FULLY

    • IS_AUTHENTICATED_REMEMBERED

    The choices were

    • IS_AUTHENTICATED

    • IS_FULLY_AUTHENTICATED

    • IS_AUTHENTICATED_ANONYMOUSLY

    • IS_AUTHENTICATED_REMEMBERED

    • IS_AUTHENTICATED_FULLY

    Help

    • https://github.com/symfony/symfony/blob/b101b71ddacfa664485bb09ec6272971e458f49f/src/Symfony/Component/Security/Core/Authorization/Voter/AuthenticatedVoter.php#L75
    • https://github.com/symfony/symfony/blob/b101b71ddacfa664485bb09ec6272971e458f49f/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php#L26
    IS_AUTHENTICATED IS_AUTHENTICATED_FULLY IS_AUTHENTICATED_REMEMBERED

  • Exception

    Which exception is thrown when a directory creation has failed ?

    Correct

    • IOException

    The choices were

    • DirectoryException

    • FileException

    • FileSystemException

    • IOException

    • InvalidFileException

    Help

    https://symfony.com/doc/2.7/components/filesystem.html#error-handling

    IOException

  • Loading type

    Which type of loader is not supported by Symfony?

    Correct

    • INI

    The choices were

    • YML

    • Closure

    • INI

    • PHP

    Help

    https://github.com/symfony/symfony/tree/3.0/src/Symfony/Component/Routing/Loader

    INI

  • Autoload

    What will be the output of the following code?

    spl_autoload_register(function ($a) {
        echo 'I am at the top of the auto-loaders stack';
    }, true, true);
    if (class_exists('\Exception', true)) { echo 'Loaded'; }

    Wrong

    • I am at the top of the auto-loaders stackLoaded

    The choices were

    • PHP Fatal error: Uncaught Error: Class 'Exception' not found

    • Nothing

    • I am at the top of the auto-loaders stackLoaded

    • I am at the top of the auto-loaders stack

    • Loaded

    Help

    • http://php.net/manual/en/intro.spl.php
    • http://php.net/manual/en/class.exception.php
    • http://php.net/manual/en/function.spl-autoload-register.php
    • http://php.net/manual/en/function.class-exists.php

  • Form Extension

    Which of these extensions are a built-in ones ?

    Wrong

    • HttpFoundationRequestHandler

    • HttpFoundationExtension

    The choices were

    • DataCollectorExtension

    • HttpFoundationExtension

    • HttpFoundationRequestHandler

    • DependencyInjectionExtension

    Help

    • https://github.com/symfony/symfony/tree/2.3/src/Symfony/Component/Form/Extension
    • HttpFoundationRequestHandler is an implementation of RequestHandlerInterface and not an extension.

  • Form Extension

    Which of these extensions are a built-in ones ?

    Wrong

    • HttpFoundationExtension

    • DependencyInjectionExtension

    The choices were

    • DependencyInjectionExtension

    • HttpFoundationExtension

    • HttpFoundationRequestHandler

    • DataCollectorExtension

    Help

    • https://github.com/symfony/symfony/tree/2.3/src/Symfony/Component/Form/Extension
    • HttpFoundationRequestHandler is an implementation of RequestHandlerInterface and not an extension.

  • Null coalesce operator

    If the user variable is not defined, what will be the result of rendering this Twig template?

    Hi {{ user.name ?? 'anonymous' }}!
    Twig

    Correct

    • Hi anonymous!

    The choices were

    • Hi null!

    • Hi anonymous!

    • This template will display an error when rendering it.

    • Hi!

    • Hi ??!

    Help

    • The ?? operator is called "null coalesce operator" (as in PHP) and it was introduced in Twig 1.24 (January 2016)
    • http://twig.symfony.com/doc/templates.html#other-operators
    Hi anonymous!

  • FragmentListener

    What is the aim of the Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest() listener on kernel.request event?

    Correct

    • Handle as content fragments by this listener all URL paths starting with /_fragment.

    The choices were

    • Handle as content fragments by this listener all URL paths starting with /_fragment.

    • Handle as content all files to let user download them.

    • Handle as content all image, css, javascript that not require security.

    • Handle as content all image, css, javascript that require security.

    Help

    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php
    Handle as content fragments by this listener all URL paths starting with /_fragment.

  • PSR-7

    What is PSR-7 about?

    Correct

    • HTTP

    The choices were

    • Autoloading

    • Logger

    • Caching

    • HTTP

    Help

    http://www.php-fig.org/psr/

    HTTP

  • OOP Basics

    What does FQCN stand for ?

    Correct

    • Fully Qualified Class Name

    The choices were

    • Fake Query Content Normalizer

    • Fully Qualified Class Name

    • Full Query Class Normalize

    Help

    • https://www.php.net/manual/en/language.namespaces.rules.php
    Fully Qualified Class Name

  • Events

    If you need to modify the data given during pre-population or modify a form depending on the pre-populated data (adding or removing fields dynamically), to which event your code should be hooked?

    Correct

    • FormEvents::PRE_SET_DATA

    The choices were

    • FormEvents::POST_SET_DATA

    • FormEvents::SUBMIT

    • FormEvents::POST_SUBMIT

    • FormEvents::PRE_SET_DATA

    • FormEvents::PRE_SUBMIT

    Help

    • http://symfony.com/doc/current/components/form/form_events.html
    FormEvents::PRE_SET_DATA

  • HiddenType errors display

    What mechanism determines whether the errors belonging to a Symfony\Component\Form\Extension\Core\Type\HiddenType form type will be displayed ?

    Wrong

    • Form type inheritance.

    The choices were

    • Hidden fields listener.

    • Form type inheritance.

    • It is not possible to change the behavior of whether HiddenType errors are displayed.

    • Error bubbling.

    Help

    https://symfony.com/doc/current/reference/forms/types/hidden.html


  • Instanceof Operator

    What would be the output of this code ?

    class Foo extends Bar implements Baz
    {
    }
    $foo = new Foo(); if ($foo instanceof Foo) { echo 'Foo '; } if ($foo instanceof Bar) { echo 'Bar '; } if ($foo instanceof Baz) { echo 'Baz '; }

    Correct

    • Foo Bar Baz

    The choices were

    • Foo Bar Baz

    • Bar

    • Foo

    • Foo Bar

    Help

    • https://www.php.net/manual/en/language.operators.type.php
    Foo Bar Baz

  • Validator

    Given the following object to validate configuration (and assuming no group is specified when validate is called):

    use Symfony\Component\Validator\Constraints as Assert;
    use Symfony\Component\Validator\GroupSequenceProviderInterface;
    /** * @Assert\GroupSequenceProvider */ class Product implements GroupSequenceProviderInterface { /** * @Assert\NotBlank(groups={"foo"}) */ private $foo;
    /** * @Assert\NotBlank(groups={"foo"}) */ private $foo2;
    /** * @Assert\NotBlank(groups={"Product"}) */ private $bar;
    /** * @Assert\NotBlank() */ private $bar2;
    public function getGroupSequence(): array { return [['foo', 'Product']]; } }

    Wrong

    • First, $foo, $foo2 will be validated, then, $bar will be validated, and finally $bar2

    The choices were

    • $foo, $foo2, $bar, $bar2 will be validated in the same time

    • $foo, $foo2, $bar will be validated in the same time

    • First, $foo, $foo2 will be validated, then, $bar will be validated, and finally $bar2

    • First, $foo, $foo2 will be validated and then, $bar

    • First, $foo, $foo2 will be validated and then, $bar, $bar2

    Help

    • https://symfony.com/doc/3.4/validation/sequence_provider.html

  • Events usage

    Which class can be used as argument when listening to kernel.controller_arguments?

    Wrong

    • FilterControllerArgumentsEvent

    The choices were

    • None, this event does not exist

    • FilterControllerEvent

    • ControllerEvent

    • ControllerArgumentsEvent

    • FilterControllerArgumentsEvent

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php


  • Twig loaders

    Which of the following classes are Twig loaders available by default?

    Correct

    • FilesystemLoader

    • ArrayLoader

    • ChainLoader

    The choices were

    • FilesystemLoader

    • DoctrineLoader

    • ArrayLoader

    • CacheLoader

    • ChainLoader

    Help

    https://github.com/twigphp/Twig/tree/2.x/src/Loader

    FilesystemLoader ArrayLoader ChainLoader

  • Code interpretation

    Assuming that the validate() method detects no violations, what will the Response object contain?

    // Controller/BookController.php
    public function indexAction()
    {
        $book = new Book();
        $validator = $this->get('validator');
        $errors = $validator->validate($book);
        return new Response((string) $errors);
    }

    Wrong

    • Fatal error: Object of class ConstraintViolationList could not be converted to string.

    The choices were

    • Fatal error: Object of class ConstraintViolationList could not be converted to string.

    • Notice: Array to string conversion.

    • An empty string

    • False

    Help

    • https://symfony.com/doc/2.7/validation.html#using-the-validator-service
    • https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/Validator/ConstraintViolationList.php

  • Best Practices

    According to the Symfony Best practices, is "smoke testing" considered a bad practice ?

    Correct

    • False

    The choices were

    • True

    • False

    Help

    • https://symfony.com/doc/5.0/best_practices.html
    False

  • Authorization

    Authorization is the process that makes sure that a user is who he claims to be?

    Correct

    • False

    The choices were

    • True

    • False

    Help

    http://symfony.com/doc/current/components/security/authorization.html

    False

  • Process

    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.

    Correct

    • False

    The choices were

    • False

    • True

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Process/Process.php#L636
    False

  • `Expires` header usage

    True or false: The Expires header's value must contain the number of seconds the response should be cached.

    Correct

    • False

    The choices were

    • True

    • False

    Help

    https://symfony.com/doc/6.0/http_cache/expiration.html#expiration-with-the-expires-header

    False

  • Assertions usage

    What will be the result of that assertion?

    $this->assertContainsOnly('string', ['1', '2', 3]);

    Correct

    • Failure

    The choices were

    • Failure

    • Success

    Help

    • https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertContainsOnly
    Failure

  • assertSame

    What will be the result of that assertion in a PHPUnit test?

    self::assertSame('2204', 2204);

    Correct

    • Failure

    The choices were

    • Success

    • Failure

    Help

    • https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertSame
    Failure

  • FormExtension usage

    What is the prerequisite to create a FormTypeExtension

    Wrong

    • Extending the Symfony\Component\Form\AbstractTypeExtension

    The choices were

    • Creating a service with the form.type_extension tag

    • Implementing the interface Symfony\Component\Form\FormTypeExtensionInterface

    • Extending the Symfony\Component\Form\AbstractTypeExtension

    • Putting the new MyFormExtension class in the Form\Extension namespace

    Help

    • https://symfony.com/doc/4.2/form/create_form_type_extension.html#defining-the-form-type-extension
    • https://symfony.com/doc/4.2/form/create_form_type_extension.html#registering-your-form-type-extension-as-a-service

  • What are the four headers in http cache ?

    What are the four primary headers in HTTP cache?

    Correct

    • Expires

    • ETag

    • Last-Modified

    • Cache-Control

    The choices were

    • Expires-After

    • Expires

    • Cache-Control

    • Last-Modified

    • ETag

    • Cached-Until

    Help

    https://www.rfc-editor.org/rfc/rfc9111.html

    Expires ETag Last-Modified Cache-Control

  • Expiration Cache Model

    Which of the following HTTP response headers belong to the expiration caching model?

    Correct

    • Expires

    • Cache-Control

    The choices were

    • Etag

    • Last-Modified

    • Cache-Control

    • Expires

    • Pragma

    Help

    https://tools.ietf.org/html/rfc2616#page-79

    Expires Cache-Control

  • HTTP Cache Models

    Which of the following assertions is true about HTTP caching?

    Wrong

    • Expiration and validation are mutually exclusive and therefore cannot be used simultaneously.

    The choices were

    • Expiration and validation are mutually exclusive and therefore cannot be used simultaneously.

    • Validation always wins over expiration.

    • Expiration always wins over validation.

    Help

    http://symfony.com/doc/current/http_cache/validation.html


  • Exceptions

    Consider the following code snippet:

    try {
        call_this_undefined_function();
    } catch (???? $e) {
        echo 'Oups, there is a serious problem there!';
    }

    Since PHP 7.0, which type/class could be used to replace the ???? placeholder in order to output Oups, there is a serious problem there! ?

    Wrong

    • Exception

    The choices were

    • Warning

    • ErrorException

    • Exception

    • Error

    • BadFunctionCallException

    Help

    • http://php.net/manual/en/language.exceptions.php
    • http://php.net/manual/en/class.error.php

  • HTTP Cache Headers

    Which HTTP response headers are involved in the validation caching model?

    Correct

    • Etag

    • Last-Modified

    The choices were

    • Last-Modified

    • Cache-Control: s-max-age

    • Cache-Control: max-age

    • Etag

    Help

    https://datatracker.ietf.org/doc/html/rfc7234#section-4.3

    Etag Last-Modified

  • Variadic functions

    What will be the result of this code?

    <?php
    function foo(...$params, $arg) { echo "$arg"; }
    foo(1,2,3,4);

    Correct

    • Error: Only the last parameter can be variadic

    The choices were

    • 1

    • 2

    • Error: Only the last parameter can be variadic

    • Error : Variadic functions should have only one argument.

    Help

    https://www.php.net/manual/en/migration56.new-features.php#migration56.new-features.variadics

    Error: Only the last parameter can be variadic

  • Twig template

    Which method is used to render the desired template?

    Correct

    • Environment::render()

    The choices were

    • Environment::showTemplate()

    • Environment::resolveTemplate()

    • Environment::render()

    • Environment::display()

    Help

    • https://twig.symfony.com/doc/1.x/api.html#rendering-templates
    • https://github.com/twigphp/Twig/blob/1.x/src/Environment.php#L370
    Environment::render()

  • Using a Persistence Layer

    According to the Symfony Best Practices Guide and the Symfony's coding conventions, which directory of your application is meant to store your Doctrine entity classes?

    Correct

    • Entity

    The choices were

    • Mapping

    • ActiveRecord

    • Entity

    • Model

    • Doctrine

    Help

    https://symfony.com/doc/current/best_practices.html#use-the-default-directory-structure

    Entity

  • HttpKernel

    Which sentence about page fragments caching methods is true ?

    Correct

    • Edge Side Includes are partially implemented by Symfony

    The choices were

    • Server Side Includes are more performant than Edge Side Includes and are recommanded by Symfony

    • Server Side Includes don't exist

    • Server Side Includes are not implemented by Symfony

    • Edge Side Includes are partially implemented by Symfony

    Help

    ESI are partially implemented ("The ESI specification describes tags you can embed in your pages to communicate with the gateway cache. Only one tag is implemented in Symfony[...]")

    • https://symfony.com/doc/4.3/http_cache/esi.html
    • https://symfony.com/doc/4.3/http_cache/ssi.html
    Edge Side Includes are partially implemented by Symfony

  • Filesystem behaviour

    Is the Filesystem component based on a lazy or eager implementation?

    Wrong

    • Eager

    The choices were

    • Eager

    • Lazy

    Help

    https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Filesystem/Filesystem.php


  • Validation model

    Which HTTP headers can be used with the validation model?

    Correct

    • ETag

    • Last-Modified

    The choices were

    • ETag

    • Cache-Control

    • Expires

    • Last-Modified

    Help

    https://symfony.com/doc/6.0/http_cache/validation.html

    ETag Last-Modified

  • Command

    What kind of help provides the bin/console config:dump-reference command?

    Correct

    • Dumps the default configuration of a bundle.

    The choices were

    • Dumps the current configuration of a bundle.

    • Dumps the current configuration in .htaccess format using the php_value directive.

    • Adds the default configuration of a bundle in the app/config/config.yml file.

    • Dumps the default configuration of a bundle.

    Help

    https://symfony.com/doc/current/configuration.html#configuration-reference-dumping

    Dumps the default configuration of a bundle.

  • Symfony and Databases

    What is the default ORM that integrates with Symfony ?

    Correct

    • Doctrine.

    The choices were

    • Hibernate.

    • Doctrine.

    • Propel.

    • Symfony ORM.

    Help

    • https://symfony.com/doc/current/doctrine.html
    Doctrine.

  • Debug command

    What does the command debug:container router?

    Wrong

    • Displays the configured routes

    The choices were

    • Displays information for the service router

    • Displays the configured routes

    Help

    • http://symfony.com/doc/current/book/service_container.html#debugging-services

  • Component arhitecture

    What is the aim of the HandleTrait?

    Wrong

    • Dispatch sync message via a BusList and return a MessageList

    The choices were

    • Dispatch async messages and return the messages as a MessageList

    • Dispatch sync message via a BusList and return a MessageList

    • Dispatch sync messages via a bus and return its result.

    Help

    https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Messenger/HandleTrait.php


  • Connecting Listeners - Priority

    What's true about the addListener()'s $priority value from Symfony\Component\EventDispatcher\EventDIspatcherInterface?

    Correct

    • Defaults to 0

    • The higher this value, the earlier an event listener will be triggered in the chain

    The choices were

    • The higher this value, the later an event listener will be triggered in the chain

    • Defaults to 1

    • The higher this value, the earlier an event listener will be triggered in the chain

    • Defaults to 100

    • Defaults to 0

    Help

    • http://symfony.com/doc/current/components/event_dispatcher.html#connecting-listeners
    Defaults to 0 The higher this value, the earlier an event listener will be triggered in the chain

  • Date format

    Which formats of date are accepted in Email->date()?

    Correct

    • DatetimeImmutable

    • Datetime

    The choices were

    • string

    • DatetimeImmutable

    • Datetime

    Help

    https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Mime/Email.php#L65

    DatetimeImmutable Datetime

  • Idempotent HTTP verbs.

    Which HTTP verbs are idempotent ?

    Correct

    • DELETE

    • PUT

    • HEAD

    • GET

    • OPTIONS

    The choices were

    • POST

    • CONNECT

    • PATCH

    • DELETE

    • PUT

    • OPTIONS

    • HEAD

    • GET

    Help

    • https://tools.ietf.org/html/rfc7231#section-4.2.2
    • https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods_and_web_applications
    DELETE PUT HEAD GET OPTIONS

  • HTTP

    Which encryption means is used to secure credentials when authenticating an HTTP request with the HTTP Basic mechanism?

    Correct

    • Credentials are not encrypted but only Base64 encoded.

    The choices were

    • Hashing (md5, sha1, etc.)

    • Credentials are not encrypted but only Base64 encoded.

    • Asymmetric-key encryption

    • Symmetric-key encryption

    • Credentials are not encrypted and transmitted in plain text in the HTTP request.

    Help

    • https://tools.ietf.org/html/rfc7235
    • https://en.wikipedia.org/wiki/Basic_access_authentication
    Credentials are not encrypted but only Base64 encoded.

  • FrameworkBundle

    From Symfony 5, what is provided by the ControllerTrait ?

    Correct

    • ControllerTrait doesn't exist anymore

    The choices were

    • ControllerTrait doesn't exist anymore

    • some helpers to render views

    • shortcuts to return specific responses (json responses, redirect responses...)

    • a service locator

    Help

    • https://github.com/symfony/framework-bundle/tree/5.0/Controller
    ControllerTrait doesn't exist anymore

  • Injection Types

    What are the recommended types of injections when injecting a service dependency into another?

    Wrong

    • Constructor injection

    • Immutable-setter Injection

    The choices were

    • Setter injection

    • Constructor injection

    • Getter injection

    • Property injection

    • Immutable-setter Injection

    Help

    • https://symfony.com/doc/7.0/service_container/injection_types.html
    • Immutable-setter Injection was introduced in 4.3
    • using property injection is not recommanded

  • ValidateRequestListener exception

    Which exception is thrown if ValidateRequestListener::onKernelRequest() detect that ips are not consistent?

    Correct

    • ConflictingHeadersException

    The choices were

    • InvalidArgumentException

    • LogicException

    • ConflictingHeadersException

    • RuntimeException

    • InconsistentIpsException

    Help

    • https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php
    • https://github.com/symfony/symfony/blob/7d89a657f13e73069ba40f1d0793c1652b01dfc2/src/Symfony/Component/HttpFoundation/Request.php#L1974
    ConflictingHeadersException

  • ChoiceType rendering

    If the expanded and multiple options are set to true on a Symfony\Component\Form\Extension\Core\Type\ChoiceType form type, what is displayed when rendering the form ?

    Correct

    • Checkboxes.

    The choices were

    • Checkboxes.

    • Radio buttons.

    • Select tag.

    • Select tag (with multiple attribute).

    Help

    http://symfony.com/doc/current/reference/forms/types/choice.html

    Checkboxes.

  • Security User Providers

    What UserProvider allows to fetch users from multiple sources ?

    Correct

    • ChainUserProvider

    The choices were

    • CompositeUserProvider

    • ChainUserProvider

    • MultipleUserProvider

    • AggregateUserProvider

    Help

    • https://symfony.com/doc/5.x/security/user_providers.html
    ChainUserProvider

  • HTTP

    Which HTTP response header instructs a cache to send a request to the origin server for validation before releasing a cached copy ?

    Correct

    • Cache-control: must-revalidate

    • Cache-control: no-cache

    The choices were

    • Cache-control: no-store

    • Cache-control: must-revalidate

    • Cache-control: no-cache

    • Cache-control: private

    Help

    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#Controlling_caching
    Cache-control: must-revalidate Cache-control: no-cache

  • Cache

    Which of these HTTP headers tell a reverse proxy cache like Varnish to cache the response it receives during 90 minutes?

    Correct

    • Cache-Control: public, s-maxage=5400

    The choices were

    • Cache-Control: public, s-maxage=5400

    • Cache-Control: public, s-maxage=90

    • Cache-Control: public

    • Cache-Control: private, maxage=5400

    • Cache-Control: private, maxage=90

    Help

    • https://tools.ietf.org/html/rfc2616
    • https://tools.ietf.org/html/rfc7234#section-5.2
    Cache-Control: public, s-maxage=5400

  • Path utilities

    Given the following code, what will be displayed?

    <?php
    use Symfony\Component\Filesystem\Path;
    echo Path::getRoot("C:\Programs\Apache\Config");

    Correct

    • C:/

    The choices were

    • C:/Programs

    • C:/Programs/

    • C:/Programs/Apache/Config

    • C:/

    • C:/Programs/Apache/

    • C:/Programs/Apache

    Help

    • https://symfony.com/doc/5.4/components/filesystem.html#finding-directories-root-directories
    • https://github.com/symfony/filesystem/blob/5.4/Path.php#L207
    C:/

  • Binary content

    When dealing with binary content, which class of the String component are you the most likely to use?

    Correct

    • ByteString

    The choices were

    • ByteString

    • CodePointString

    • UnicodeString

    Help

    https://symfony.com/doc/5.0/components/string.html

    ByteString

  • Static arrow functions

    We sometimes come across arrow functions declared as static, like in the code below:

    class Foo
    {
        public function bar(): iterable
        {
            $array = \range(1, 10);
    return array_map(static fn($x) => $x*$x, $array); } }

    Which of the following choices is true

    Correct

    • By using the static modifier, $this (representing the current instance of Foo) won't be bound and "injected" in the arrow function. It will result in a faster execution, as this binding doesn't have to be made

    The choices were

    • By using the static modifier, $this (representing the current instance of Foo) won't be bound and "injected" in the arrow function. It will result in a faster execution, as this binding doesn't have to be made

    • It allows the arrow function to be able to access to $this, representing the current instance of Foo calling this method

    • Nothing actually changes

    Help

    https://wiki.php.net/rfc/arrow_functions_v2

    By using the static modifier, $this (representing the current instance of Foo) won't be bound and "injected" in the arrow function. It will result in a faster execution, as this binding doesn't have to be made

  • HTTP2

    With cURL installed, how does the HTTP/2 support can be activated for http URLs?

    Correct

    • By using the 'http_version' => '2.0' configuration key when creating a new HttpClient

    The choices were

    • It's activated by default

    • By using the 'http_version' => '2.0' configuration key when creating a new HttpClient

    Help

    https://symfony.com/doc/5.0/http_client.html#http-2-support

    By using the 'http_version' => '2.0' configuration key when creating a new HttpClient

  • Config definition

    How to overwrite a configuration array if the value is also defined in a second configuration array ?

    Correct

    • By using ->performNoDeepMerging()

    The choices were

    • By using ->canBeOverwritten()

    • By using ->performNoDeepMerging()

    • By using ->performDeepMerging()

    • By using ->enableMerging()

    Help

    http://symfony.com/doc/current/components/config/definition.html#merging-options

    By using ->performNoDeepMerging()

  • Console

    How is it possible to generate absolute URLs from the Console?

    Correct

    • By running

      $this->getContainer()->get('router')->getContext()->setHost('example.org');
    • By overloading the parameter router.request_context.host in the configuration.

    The choices were

    • By overloading the parameter router.request_context.host in the configuration.

    • The host is automatically known by Symfony, there is no need to specify it in CLI.

    • By running

      $this->getContainer()->get('router')->getContext()->setHost('example.org');
    • By specifying the host parameter in the Twig function url().

    Help

    https://symfony.com/doc/4.x/routing.html#generating-urls-in-commands

    By running $this->getContainer()->get('router')->getContext()->setHost('example.org'); By overloading the parameter router.request_context.host in the configuration.

  • Compiler Passes

    How can you register a new compiler pass?

    Correct

    • By passing an instance of the CompilerPass to the addCompilerPass of a ContainerBuilder.

    The choices were

    • By passing an instance of the CompilerPass to the pushCompilerPass of a ContainerBuilder.

    • By creating a new service with the tag compiler_pass.

    • By passing an instance of the CompilerPass to the registerCompilerPass of a ContainerBuilder.

    • By passing an instance of the CompilerPass to the addCompilerPass of a ContainerBuilder.

    • By creating a new service with the tag compiler.pass.

    Help

    https://symfony.com/doc/current/service_container/compiler_passes.html

    By passing an instance of the CompilerPass to the addCompilerPass of a ContainerBuilder.

  • OOP

    How can you modify the copy of an object during a clone operation ?

    Correct

    • By implementing the __clone() method.

    The choices were

    • By implementing the __construct() method.

    • By implementing the __clone() method.

    • By creating your own method and putting the @clone annotation on it.

    • By implementing the __get() and __set() methods.

    • It is not possible.

    Help

    http://php.net/manual/en/language.oop5.cloning.php

    By implementing the __clone() method.

  • Registering Functions

    What are the possibles ways to register new functions in Symfony\Component\ExpressionLanguage\ExpressionLanguage?

    Correct

    • By calling the register() method.

    • By calling the addFunction() method.

    • By calling the registerProvider() method.

    The choices were

    • By calling the registerProvider() method.

    • By calling the register() method.

    • By calling the createFunction() method.

    • By calling the addFunction() method.

    • By calling the setFunctions() method.

    Help

    • https://symfony.com/doc/2.6/components/expression_language/extending.html
    • https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php
    By calling the register() method. By calling the addFunction() method. By calling the registerProvider() method.

  • Host conditions

    How to make a route matching only a specific host ?

    Wrong

    • By adding a hostkey in the requirements section of a route definition

    The choices were

    • By adding domain key in the route definition

    • By adding a host key in the route definition

    • it's not possible

    • By adding a hostkey in the requirements section of a route definition

    • By adding domain key in the requirements section of a route definition

    Help

    http://symfony.com/doc/current/routing/hostname_pattern.html


  • Command

    When is the Symfony\Component\Console\Command::interact method executed?

    Wrong

    • Before Symfony\Component\Console\Command::execute method.

    • After Symfony\Component\Console\Command::initialize method.

    The choices were

    • Before Symfony\Component\Console\Command::initialize method.

    • Before Symfony\Component\Console\Command::execute method.

    • After Symfony\Component\Console\Command::execute method.

    • After the InputDefinition is validated.

    • Before the InputDefinition is validated.

    • After Symfony\Component\Console\Command::initialize method.

    Help

    • http://symfony.com/doc/current/console.html#command-lifecycle
    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/Console/Command/Command.php

  • Trait

    What will be the output of the following code?

    <?php
    class Base { public function sayFoo() { echo 'Bar'; } }
    trait SayFoo { public function sayFoo() { parent::sayFoo(); echo 'Foo'; } }
    class Foo extends Base { use SayFoo; }
    $foo = new Foo(); $foo->sayFoo();

    Correct

    • BarFoo

    The choices were

    • BarFoo

    • Bar

    • FooBar

    • Foo

    Help

    • http://php.net/manual/en/language.oop5.traits.php
    BarFoo

  • ImmutableEventDispatcher usage

    Which exception is thrown when trying to remove a subscriber from an ImmutableEventDispatcher?

    Correct

    • BadMethodCallException

    The choices were

    • InvalidArgumentException

    • FrozenEventDispatcherException

    • BadMethodCallException

    • RuntimeException

    • LogicException

    • InvalidArgumentException

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    BadMethodCallException

  • ImmutableEventDispatcher usage

    Which exception is throw when trying to add a subscriber into an ImmutableEventDispatcher?

    Correct

    • BadMethodCallException

    The choices were

    • RuntimeException

    • BadMethodCallException

    • InvalidArgumentException

    • FrozenEventDispatcherException

    • LogicException

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    BadMethodCallException

  • ImmutableEventDispatcher usage

    Which exception is throw when trying to add a listener into an ImmutableEventDispatcher?

    Correct

    • BadMethodCallException

    The choices were

    • LogicException

    • RuntimeException

    • Symfony\Component\DependencyInjection\Exeption\InvalidArgumentException

    • InvalidArgumentException

    • BadMethodCallException

    • FrozenEventDispatcherException

    Help

    https://github.com/symfony/symfony/blob/2.1/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

    BadMethodCallException

  • Method overriding

    Consider the following PHP code snippet:

    <?php
    class A { protected $foo;
    private function foo() { $this->foo = 'A-foo'; }
    public function bar() { $this->foo();
    return $this->foo; } }
    class B extends A { private function foo() { $this->foo = 'B-foo'; } }
    echo (new B())->bar();

    What is the expected output when executing this script?

    Wrong

    • B-foo

    The choices were

    • PHP will raise a fatal error because it's not allowed to override a private method.

    • B-foo
    • A-foo
    • NULL

    Help

    • https://3v4l.org/InSq9

  • Utils

    Which class can be used to extracts security errors from a Request?

    Correct

    • AuthenticationUtils

    The choices were

    • FrameworkUtils

    • AuthenticationUtils

    • HttpUtils

    • RequestUtils

    • SecurityUtils

    Help

    • https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php
    AuthenticationUtils

  • Format

    Which of the following formats are available to define validation rules or constraints?

    Wrong

    • Attributes

    • YAML

    • Annotations

    • PHP

    The choices were

    • PHP

    • JSON

    • Attributes

    • XML

    • YAML

    • Annotations

    Help

    • https://github.com/symfony/symfony/tree/master/src/Symfony/Component/Validator/Mapping/Loader
    • http://symfony.com/doc/current/validation.html#constraint-configuration

  • Entities mapping

    According to the official Symfony Best Practices Guide, which format do you need to use to define the mapping information of the Doctrine entities?

    Correct

    • Attributes

    The choices were

    • Annotations

    • Yaml

    • Xml

    • PHP

    • Attributes

    Help

    https://symfony.com/doc/5.3/best_practices.html#use-attributes-to-define-the-doctrine-entity-mapping

    Attributes

  • Slugger

    Which slugger is defined in the String Component?

    Correct

    • AsciiSlugger

    The choices were

    • Slugger

    • AsciiSlugger

    • UnicodeSlugger

    • TraceableSlugger

    Help

    https://github.com/symfony/symfony/tree/6.2/src/Symfony/Component/String/Slugger

    AsciiSlugger

  • References and foreach

    What is the output of such a script ?

    $a = [1, 2, 3];
    foreach ($a as &$c) { } foreach ($a as $c) { }
    print_r($a);

    Correct

    • Array
      (
          [0] => 1
          [1] => 2
          [2] => 2
      )

    The choices were

    • Array
      (
          [0] => 1
          [1] => 2
          [2] => 3
      )
    • An error

    • Array
      (
          [0] => 2
          [1] => 2
          [2] => 2
      )
    • Array
      (
          [0] => 1
          [1] => 2
          [2] => 2
      )
    • Array
      (
          [0] => 1
          [1] => 1
          [2] => 1
      )

    Help

    • http://php.net/manual/en/language.references.php
    • http://php.net/manual/en/control-structures.foreach.php
    Array ( [0] => 1 [1] => 2 [2] => 2 )PHP

  • OOP

    What type is the __debugInfo() magic method supposed to return?

    Correct

    • Array

    The choices were

    • Object

    • Boolean

    • Any type

    • Array

    • String

    • Nothing

    Help

    http://php.net/manual/en/language.oop5.magic.php#object.debuginfo

    Array

  • Apply usage

    What's the aim of the apply tag?

    Correct

    • Apply one or multiple filters on a block

    The choices were

    • Apply one and only one filter on a block

    • Define a new tag

    • Apply a camelCase transformation to a text

    • Apply one or multiple filters on a block

    Help

    https://twig.symfony.com/doc/1.x/tags/apply.html

    Apply one or multiple filters on a block

  • Routing match

    Given the following two routes, what controller will be executed for the URL /book/123?

     # config/routes.yaml
     book_detail_section:
         path:       /book/{id}/{section}
         controller: 'App\Controller\BookController::detailSection'
         defaults:   { section: home }
     book_detail:
         path:      /book/{id}
         controller: 'App\Controller\BookController::detail'
    YAML

    Wrong

    • App\Controller\BookController::detail

    The choices were

    • App\Controller\BookController::detailSection

    • App\Controller\BookController::detail

    • Error: The routing file contains unsupported keys for “defaults”

    • Error: No route found

    Help

    • https://symfony.com/doc/current/routing.html#priority-parameter
    • https://symfony.com/doc/current/routing.html#extra-parameters

  • Route matching

    Given the following routes, what controller will be executed for /book/123 ?

    # config/routes.yaml
    book_list:
        path:       /books
        controller: 'App\Controller\BookController::list'
    book_detail:
        path:       /books/{slug}
        controller: 'App\Controller\BookController::detail'
    book_download:
        path:       /books/{slug}/download
        controller: 'App\Controller\BookController::download'
    YAML

    Wrong

    • App\Controller\BookController::detail

    The choices were

    • App\Controller\BookController::download

    • Error: No route found

    • App\Controller\BookController::detail

    • App\Controller\BookController::list

    Help

    • https://symfony.com/doc/2.x/routing.html
    • https://www.youtube.com/watch?v=4F4qzPbcFiA

  • Routing match

    If no methods are specified for a route, what methods will be matched?

    Correct

    • Any methods

    The choices were

    • Safe methods: GET or HEAD

    • Any methods

    • GET or POST

    • GET

    Help

    • https://symfony.com/doc/4.3/routing.html#matching-http-methods
    Any methods

  • Business Logic

    According to the official Symfony Best Practices Guide, what format do you need to use to define/configure your own services?

    Wrong

    • Annotations

    The choices were

    • Annotations

    • XML

    • PHP

    • YAML

    Help

    http://symfony.com/doc/current/best_practices/business-logic.html#service-format-yaml


  • Option

    If I want to allow the client to specify CLI option --force, what am I going to add to the definition?

    Correct

    • An option InputOption.

    The choices were

    • A parameter InputParameter.

    • An option InputOption.

    • An argument InputArgument.

    • A choice InputChoice.

    Help

    • http://symfony.com/doc/current/components/console/introduction.html#creating-a-basic-command
    • http://symfony.com/doc/current/components/console/console_arguments.html
    • http://symfony.com/doc/current/console/input.html#using-command-options
    An option InputOption.

  • File

    What is the kind of value of $file in the following code?

    <?php
    use Symfony\Component\Finder\Finder;
    $finder = new Finder(); $finder->files()->in(__DIR__);
    foreach ($finder as $file) { // ... }

    Correct

    • An instance of Symfony\Component\Finder\SplFileInfo.

    The choices were

    • An instance of Symfony\Component\Finder\File.

    • An instance of Symfony\Component\Finder\File\SplFileInfo.

    • An instance of Symfony\Component\Finder\FileInfo.

    • An instance of Symfony\Component\Finder\File\SplFile.

    • An instance of Symfony\Component\Finder\SplFileInfo.

    • An instance of Symfony\Component\Finder\File\File.

    Help

    https://symfony.com/doc/2.0/components/finder.html

    An instance of Symfony\Component\Finder\SplFileInfo.

  • Process handling

    Given a new process created in front of a Symfony command that return a 1 code, what will be returned by Process::mustRun()?

    Wrong

    • An instance of Process

    The choices were

    • 1

    • An instance of Process

    • true

    • Nothing, a ProcessFailedException will be thrown

    • false

    Help

    https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/Process/Process.php#L209


  • Empty_data usage

    Which type of argument is passed if a closure is used in empty_data option?

    Correct

    • An instance of FormInterface

    The choices were

    • An array

    • An instance of FormInterface

    • Nothing

    • An instance of Option

    Help

    https://symfony.com/doc/2.7/form/use_empty_data.html#option-2-provide-a-closure

    An instance of FormInterface

  • Streams

    What will be the output of the following piece of code ?

    $google = fopen('http://www.google.com', 'r+');
    echo fwrite($google, 'foo');

    Correct

    • An error saying Failed to open stream: HTTP wrapper does not support writeable connections.

    The choices were

    • 1

    • An error saying Failed to open stream: HTTP wrapper does not support writeable connections.

    • 3

    • The results of the "foo" search on Google as plaintext.

    • An error saying Failed to open stream: Permission denied.

    • The results of the "foo" search on Google as HTML.

    Help

    • http://php.net/manual/en/book.stream.php
    • http://php.net/manual/en/function.fopen.php
    An error saying Failed to open stream: HTTP wrapper does not support writeable connections.

  • Anonymous Functions

    What would be the output of this code ?

    $myArray = [1, 2, 3];
    $closure = function (int $a): int {
        return $myArray[$a];
    };
    echo $closure(1);

    Correct

    • An error is thrown

    The choices were

    • An error is thrown

    • 2

    • 1

    Help

    • https://www.php.net/manual/en/functions.anonymous.php
    An error is thrown

  • Array functions

    What is the output of the following PHP script?

    <?php
    $values = [37, 5, '09'];
    $sorted = sort($values);
    foreach ($sorted as $v) { echo $v; }

    Correct

    • An error

    The choices were

    • 50937

    • 09537

    • An error

    • 375509

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.sort.php
    An error

  • Array functions

    What is the output ?

    <?php
    array_combine([1, 2, 3, 6], [4,5,6]);

    Correct

    • An error

    The choices were

    • [1, 2, 3, 4, 5, 6]

    • An error

    • [1 => 4, 2 => 5, 3 => 6]

    • [1 => 2, 3 => 4, 5 => 6]

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-combine.php
    An error

  • Form Type

    Which of the following can be represented as a Symfony\Component\Form\Extension\Core\Type\FormType?

    Wrong

    • An entire <form> with multiple fields to edit a user profile

    • A group of several HTML fields used to input a postal address

    The choices were

    • An entire <form> with multiple fields to edit a user profile

    • A group of several HTML fields used to input a postal address

    • A single <input type="text"> form field

    Help

    https://symfony.com/doc/6.0/forms#form-types


  • `empty_data` and `data_class` options

    What is the default value of the empty_data option when data_class is set?

    Wrong

    • An empty string

    The choices were

    • An empty string

    • An empty array

    • null

    • A new instance of the class set in data_class

    Help

    https://symfony.com/doc/current/form/use_empty_data.html


  • `MimeTypes::getExtensions` return type

    What will return Symfony\Component\Mime\MimeTypes::getExtensions(string $mimeType) when passing it an invalid MIME type?

    Example: $mimeTypes->getExtensions('not/a-valid-type')

    Correct

    • An empty array

    The choices were

    • An Exception will be thrown.

    • null

    • An empty array

    Help

    https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Mime/MimeTypes.php#L90

    An empty array

  • The Serializer Context

    What is a serializer context?

    Correct

    • An array passed on (de)serialization to control serializer features

    The choices were

    • An array passed on (de)serialization to control serializer features

    • The global configuration of the serializer component

    • The object to update during deserialization

    • The initial data to serialize/deserialize

    Help

    • https://symfony.com/doc/5.x/serializer.html#serializer_serializer-context
    An array passed on (de)serialization to control serializer features

  • Stamps

    What is the constructor argument of ValidationStamp?

    Correct

    • An array of string or a GroupSequence

    The choices were

    • An instance of Constraint

    • A formatted string using the following syntax foo, bar

    • An array of string or a GroupSequence

    Help

    https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Messenger/Stamp/ValidationStamp.php

    An array of string or a GroupSequence

  • Asserting exceptions

    Which of the following are valid ways in PHPUnit to test the exceptions that occur when executing some PHP code?

    Correct

    • Add the following PHP call inside the test method:

      $this->expectException('Fully\\Qualified\\ExceptionClassName');

    The choices were

    • You can't test PHP exceptions with PHPUnit.

    • Wrap the entire test method in a try...catch but without processing the exception in any special way:

      public function testSomething()
      {
          try {
              // ...
          } catch(\Exception $e) {}
      }
    • Add the following PHP call inside the test method:

      $this->expectException('Fully\\Qualified\\ExceptionClassName');

    Help

    https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions

    Add the following PHP call inside the test method: $this->expectException('Fully\\Qualified\\ExceptionClassName');PHP

  • Content negotiation headers

    Which headers can trigger a 406 response status code if the server cannot produce a valid response?

    Correct

    • Accept-Language

    • Accept

    • Accept-Encoding

    The choices were

    • If-Range

    • If-None-Match

    • If-Match

    • Accept-Encoding

    • Accept

    • Accept-Language

    Help

    • https://httpwg.org/specs/rfc7231.html#status.406
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406
    Accept-Language Accept Accept-Encoding

  • Security informations

    Which are the constants defined in Symfony\Component\Security\Core\Security class?

    Correct

    • AUTHENTICATION_ERROR

    • ACCESS_DENIED_ERROR

    • LAST_USERNAME

    • MAX_USERNAME_LENGTH

    The choices were

    • LAST_USERNAME

    • BAD_CREDENTIALS

    • ACCESS_DENIED_ERROR

    • AUTHENTICATION_ERROR

    • MAX_USERNAME_LENGTH

    • AUTHENTICATION_FAILURE

    • WRONG_PASSWORD

    Help

    https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Security/Core/Security.php

    AUTHENTICATION_ERROR ACCESS_DENIED_ERROR LAST_USERNAME MAX_USERNAME_LENGTH

  • Array functions

    Which of the following statements best describes the purpose of PHP's extract() function? This function accepts an array as its first argument.

    Correct

    • A variable is created in the current scope for each element in the given associative array.

    The choices were

    • The second argument is used to specify a data type (such as 'string'). All values in the passed array of that type are returned in a new array.

    • Any ZIP files referenced in the passed array are extracted to the current working directory.

    • The passed array is populated by any variables in the current scope.

    • A variable is created in the current scope for each element in the given associative array.

    Help

    • https://www.php.net/array
    • https://php.net/manual/en/function.extract.php
    A variable is created in the current scope for each element in the given associative array.

  • Sub Requests

    What is a sub request?

    Correct

    • A sub request serves to render just one small portion of a page instead of a full page.

    The choices were

    • A sub request is a request from a HTTP reverse proxy.

    • A sub request serves to render just one small portion of a page instead of a full page.

    • A sub request serves to create HTTP cache headers.

    • A sub request is a request used in tests.

    Help

    • http://symfony.com/doc/current/components/http_kernel.html#sub-requests
    A sub request serves to render just one small portion of a page instead of a full page.

  • Controller

    What value type is returned by the Symfony\Bundle\FrameworkBundle\Controller\AbstractController::renderView() method?

    Correct

    • A string.

    The choices were

    • A string.

    • An instance of Symfony\Component\HttpFoundation\Response.

    • An instance of Symfony\Component\View\View.

    • An instance of Symfony\Component\BrowserKit\Response.

    Help

    • https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
    • https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php#L243
    A string.

  • Connecting Listeners

    What is the third argument of the addListener method of the Symfony\Component\EventDispatcher\EventDispatcher class?

    Correct

    • A priority integer that determines when a listener is triggered versus other listeners.

    The choices were

    • A PHP callable that will be executed when the specified event is dispatched

    • An Event object.

    • The event name (string) that this listener wants to listen to.

    • A priority integer that determines when a listener is triggered versus other listeners.

    Help

    • http://symfony.com/doc/current/components/event_dispatcher/introduction.html#connecting-listeners
    A priority integer that determines when a listener is triggered versus other listeners.

  • PHP and Databases

    What is mysqlnd?

    Correct

    • A low level connector designed to replace libmysql dependency

    The choices were

    • A low level connector designed to replace libmysql dependency

    • A persistent connection to a MySQL server

    • A PHP extension adding some functions to interact with a MySQL server, like PDO

    • A new RDBMS like MySQL or MariaDB

    Help

    http://www.php.net/mysqlnd

    A low level connector designed to replace libmysql dependency

  • Dumpers

    What is a Dumper?

    Wrong

    • A dumper is responsible for getting each property values of PHP object.

    The choices were

    • A dumper is responsible for getting each property values of PHP object.

    • A dumper is responsible for creating a var_export of any PHP variable.

    • A dumper is responsible for outputting a string representation of a PHP variable.

    • A dumper is responsible for creating a var_dump of any PHP variable.

    Help

    https://symfony.com/doc/2.6/components/var_dumper/advanced.html#dumpers


  • Standards

    What is PSR-12?

    Correct

    • A coding style guide.

    The choices were

    • A standard way to convert fully qualified names into file paths.

    • A utility to convert non-namespaced PHP classes into namespaced ones.

    • A coding style guide.

    • A common logger interface.

    Help

    https://www.php-fig.org/psr/psr-12/

    A coding style guide.

  • Standards

    What are PSR-0 and PSR-4?

    Wrong

    • A coding style guide.

    The choices were

    • A specification for autoloading classes from file paths.

    • A utility to convert non-namespaced PHP classes into namespaced ones.

    • A coding style guide.

    • A common logger interface.

    Help

    • http://www.php-fig.org/psr/psr-0/
    • http://www.php-fig.org/psr/psr-4/

  • Standards

    What is PSR-1?

    Correct

    • A basic coding standard.

    The choices were

    • A coding style guide.

    • A basic coding standard.

    • A standard way to convert fully qualified names into file paths.

    • A common logger interface.

    Help

    http://www.php-fig.org/psr/psr-1/

    A basic coding standard.

  • Cloners

    What will be in $result with the following code?

    <?php
    use Symfony\Component\VarDumper\Cloner\VarCloner;
    $myVar = /*...*/;
    $cloner = new VarCloner(); $result = $cloner->cloneVar($myVar);

    Correct

    • A Symfony\Component\VarDumper\Cloner\Data object

    The choices were

    • An array.

    • A Symfony\Component\VarDumper\Cloner\Clone object

    • A Symfony\Component\VarDumper\Cloner\Data object

    • An object of the same class of $myVar.

    • A Symfony\Component\VarDumper\Cloner\CloneData object

    • A Symfony\Component\VarDumper\Data object

    Help

    • https://github.com/symfony/symfony/blob/240e9648af3daa5ed19580fdec74d768e30692a6/src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php#L24
    • https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/VarDumper/Cloner/Data.php
    • https://symfony.com/doc/2.6/components/var_dumper/advanced.html#cloners
    A Symfony\Component\VarDumper\Cloner\Data object

  • Reading from Arrays

    What will be the result of the following code?

    use Symfony\Component\PropertyAccess\PropertyAccess;
    $accessor = PropertyAccess::createPropertyAccessor();
    $person = array( 'first_name' => 'Wouter', );
    $age = $accessor->getValue($person, '[age]');

    Wrong

    • A Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException will be thrown.

    The choices were

    • A Symfony\Component\PropertyAccess\Exception\NoSuchIndexException will be thrown.

    • The value of $age will be null.

    • The value of $age will be 0.

    • A Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException will be thrown.

    Help

    • http://symfony.com/doc/current/components/property_access/introduction.html#reading-from-arrays

  • Reading from Arrays

    What will be the result of the following code?

    <?php
    use Symfony\Component\PropertyAccess\PropertyAccess;
    $accessor = PropertyAccess::createPropertyAccessor();
    $person = array( 'first_name' => 'Wouter', );
    $age = $accessor->getValue($person, 'age');

    Wrong

    • A Symfony\Component\PropertyAccess\Exception\NoSuchIndexException will be thrown.

    The choices were

    • The value of $age will be null.

    • A Symfony\Component\PropertyAccess\Exception\NoSuchIndexException will be thrown.

    • The value of $age will be 0.

    • A Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException will be thrown.

    Help

    • https://symfony.com/doc/2.7/components/property_access.html#reading-from-arrays
    • https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php
    • https://github.com/symfony/symfony/blob/2.4/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L206

  • Exception

    With the following class:

    <?php
    use Symfony\Component\OptionsResolver\OptionsResolver;
    class Mailer { private $options;
    public function __construct(array $options = array()) { $resolver = new OptionsResolver(); $resolver->setDefaults(array( 'host' => 'smtp.example.org', 'username' => 'user', 'password' => 'pa$$word', 'port' => 25, ));
    $this->options = $resolver->resolve($options); } }

    what exception will be thrown while executing the code:

    $mailer = new Mailer(array(
        'usernme' => 'johndoe',
    ));

    Correct

    • A Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException.

    The choices were

    • A Symfony\Component\OptionsResolver\Exception\InvalidOptionsException.

    • A Symfony\Component\OptionsResolver\Exception\NoSuchOptionException.

    • A Symfony\Component\OptionsResolver\Exception\OptionDefinitionException.

    • A Symfony\Component\OptionsResolver\Exception\MissingOptionsException.

    • A Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException.

    Help

    • https://symfony.com/doc/2.8/components/options_resolver.html#usage
    A Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException.

  • HTTP Request Handling

    Consider the following code:

    $result = $kernel->handle($request);

    What does the $result variable contain at the end of this script?

    Correct

    • A Symfony\Component\HttpFoundation\Response instance.

    The choices were

    • An array.

    • A Symfony\Component\HttpFoundation\Request instance.

    • A Symfony\Component\HttpFoundation\Response instance.

    • A string.

    • A Symfony\Component\BrowserKit\Response instance.

    • A Symfony\Component\BrowserKit\Request instance.

    Help

    • https://symfony.com/doc/current/components/http_kernel/introduction.html
    A Symfony\Component\HttpFoundation\Response instance.

  • Output-disabled process

    What happens if you try to get the output of process that has its output disabled?

    Correct

    • A LogicException is thrown

    The choices were

    • An InvalidArgumentException is thrown

    • An empty string is returned

    • A LogicException is thrown

    • null is returned

    Help

    https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Process/Process.php#L565-L578

    A LogicException is thrown

  • Not yet started process's output

    What happens if you try to get the output of process that has not been started yet?

    Correct

    • A LogicException is thrown

    The choices were

    • null is returned

    • An InvalidArgumentException is thrown

    • A LogicException is thrown

    • An empty string is returned

    Help

    https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Process/Process.php#L563-L577

    A LogicException is thrown

  • Date Handling

    What will be stored in $yaml with the following code:

    <?php
    use Symfony\Component\Yaml\Yaml;
    $yaml = Yaml::parse('1983-07-01');

    Wrong

    • A DateTime object

      DateTime {
        +"date": "1983-07-01 00:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }

    The choices were

    • An array

      array:1 [
        0 => '1983-07-01'
      ]
    • 425865600
    • An array

      array:1 [
        0 => DateTime {
          +"date": "1983-07-01 00:00:00.000000"
          +"timezone_type": 3
          +"timezone": "UTC"
        }
      ]
    • 1983-07-01
    • An array

      array:1 [
        0 => 425865600
      ]
    • A DateTime object

      DateTime {
        +"date": "1983-07-01 00:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }

    Help

    • http://symfony.com/doc/current/components/yaml.html#date-handling

  • Collection Length

    Which constraint should be used to assert that a collection contains exactly 2 items?

    We assume that Assert is an Alias to Symfony\Component\Validator\Constraints namespace.

    Correct

    • @Assert\Count(min=2, max=2)

    The choices were

    • @Assert\Length(2)
    • @Assert\Length(min=2, max=2)
    • @Assert\Count(min=2, max=2)
    • @Assert\Count(min=2)

    Help

    http://symfony.com/doc/current/reference/constraints/Count.html

    @Assert\Count(min=2, max=2)

  • Function named arguments as an array

    Is the following code correct?

    class Foo
    {
        public function qux(): void
        {
            $args = [
                'secondArgument' => 'arg',
                'firstArgument' => true,
            ];
    $this->bar(...$args); }
    private function bar(bool $firstArgument, string $secondArgument): void { // ... } }

    Wrong

    • No

    The choices were

    • Yes

    • No

    Help

    • https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments
    • https://3v4l.org/ts3aJ#v8.0.0
    ? class Foo { public function qux(): void { $args = [ 'secondArgument' => 'arg', 'firstArgument' => true, ]; $this->bar(...$args); } private function bar(bool $firstArgument, string $secondArgument): void { // ... } }PHP Wrong No

  • Configuration parameters in Route

    Is the following route definition correct?

    /**
     * @Route("/%kernel.environment%/page", name="page")
     */
    public function action(): Response
    {
        // ...
    }

    Correct

    • Yes

    The choices were

    • No

    • Yes

    Help

    • https://symfony.com/doc/2.7/routing/service_container_parameters.html
    • https://symfony.com/doc/current/configuration.html#configuration-parameters
    ? /** * @Route("/%kernel.environment%/page", name="page") */ public function action(): Response { // ... }PHP Correct Yes

  • General knowledge

    Which of the following assertions is correct?

    Wrong

    • PHP is a loosely-typed declarative language.

    The choices were

    • PHP is a strongly-typed imperative language.

    • PHP is a strongly-typed, functionnal language.

    • PHP is a loosely-typed imperative language.

    • PHP is a loosely-typed functionnal language.

    • PHP is a loosely-typed declarative language.

    Help

    • https://en.wikipedia.org/wiki/Programming_paradigm
    ? Wrong PHP is a loosely-typed declarative language.

  • Array functions

    In the following code, what is the key of the element with value 25?

    <?php
    $myArray = [ 'foo' => 'bar', 7 => 15, 28 ];
    $myArray[] = 25;

    Correct

    • 9

    The choices were

    • 9

    • 0

    • 8

    • 29

    Help

    • https://php.net/array
    9

  • Array functions

    What is the output of the following PHP script?

    <?php
    $numbers = array(5, 6, 7, 8);
    end($numbers);
    while (key($numbers)) { echo current($numbers); prev($numbers); }

    Correct

    • 876

    The choices were

    • 5678

    • 876

    • 8765

    • 321

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.key.php
    • https://php.net/manual/en/function.current.php
    • https://php.net/manual/en/function.end.php
    • https://php.net/manual/en/function.prev.php
    876

  • Terminal usage

    What will be the value stored in $width when using the following code within a command and assuming that no environment variables are set and the stty command isn't available.

    <?php
    use Symfony\Component\Console\Terminal;
    $width = (new Terminal())->getWidth();

    Correct

    • 80

    The choices were

    • 0

    • An error

    • Nothing

    • The width of the actual terminal

    • 120

    • 80

    • 200

    Help

    https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Console/Terminal.php

    80

  • Status code

    What are the HTTP status codes for Server Error?

    Correct

    • 5xx

    The choices were

    • 1xx

    • 5xx

    • 3xx

    • 2xx

    • 4xx

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    5xx

  • Network access

    Which status code will be returned if a proxy detect that a client must be authenticated to gain network access?

    Correct

    • 511

    The choices were

    • 506

    • 508

    • 404

    • 511

    • 510

    Help

    • https://datatracker.ietf.org/doc/html/rfc6585#section-6
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/511
    511

  • Status code

    What is the HTTP status codes for HTTP Version Not Supported?

    Correct

    • 505

    The choices were

    • 504

    • 505

    • 503

    • 502

    • 500

    • 501

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    • https://tools.ietf.org/html/rfc2616#section-10.5.6
    505

  • Status code

    What is the HTTP status codes for Gateway Timeout?

    Correct

    • 504

    The choices were

    • 501

    • 502

    • 504

    • 503

    • 505

    • 500

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    • https://tools.ietf.org/html/rfc2616#section-10.5.5
    504

  • Status code

    What is the HTTP status codes for Bad Gateway?

    Correct

    • 502

    The choices were

    • 505

    • 502

    • 501

    • 500

    • 504

    • 503

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    • https://tools.ietf.org/html/rfc2616#section-10.5.3
    502

  • Status code

    What is the HTTP status codes for Not Implemented?

    Correct

    • 501

    The choices were

    • 503

    • 505

    • 500

    • 502

    • 504

    • 501

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    • https://tools.ietf.org/html/rfc2616#section-10.5.2
    501

  • Status code

    What is the HTTP status codes for Internal Server Error?

    Correct

    • 500

    The choices were

    • 505

    • 501

    • 500

    • 503

    • 502

    • 504

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    • https://tools.ietf.org/html/rfc2616#section-10.5.1
    500

  • Count function

    What will be the output of the following script?

    <?php
    $a = ['foo', 'bar' => 'baz', ['foobar', 'baz']];
    echo count($a, true);

    Correct

    • 5

    The choices were

    • An error

    • 2
    • 4
    • 5
    • 3

    Help

    • https://php.net/manual/en/function.count.php
    5

  • Status code

    What are the HTTP status codes for client errors?

    Correct

    • 4xx

    The choices were

    • 3xx

    • 4xx

    • 1xx

    • 5xx

    • 2xx

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    4xx

  • Legal conditions

    Which status code must be used to respond if a resource is unavailable due to legal reasons?

    Correct

    • 451

    The choices were

    • 425

    • 418

    • 401

    • 404

    • 403

    • 451

    Help

    • https://httpwg.org/specs/rfc7725.html#n-451-unavailable-for-legal-reasons
    • https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/451
    451

  • Status code

    What is the status code for Too Many Requests?

    Correct

    • 429

    The choices were

    • 431

    • 502

    • 429

    • 420

    • 503

    Help

    • https://tools.ietf.org/html/rfc6585#section-4
    429

  • Status code

    What is the status code for Gone?

    Correct

    • 410

    The choices were

    • 411

    • 403

    • 404

    • 410

    • 409

    Help

    • https://tools.ietf.org/html/rfc2616#section-10.4.11
    410

  • HTTP code status

    What is the status code for Unauthorized ?

    Wrong

    • 403

    The choices were

    • 401

    • 405

    • 402

    • 403

    Help

    https://developer.mozilla.org/fr/docs/Web/HTTP/Status/401


  • String manipulations

    What will be the output of the following code?

    echo count(explode ('/', '///'));

    Correct

    • 4

    The choices were

    • 2
    • An error

    • 3
    • 0
    • 4

    Help

    • http://php.net/manual/en/function.explode.php
    4

  • Status code

    What are the HTTP status codes for redirection?

    Correct

    • 3xx

    The choices were

    • 3xx

    • 4xx

    • 5xx

    • 1xx

    • 2xx

    Help

    • https://tools.ietf.org/html/rfc2616#section-6.1.1
    3xx

  • PHP operators

    What is the output ?

    <?php
    $a = 4 << 2 + 1;
    echo $a;
    ?>

    Correct

    • 32

    The choices were

    • 17

    • 32

    • 1

    • 16

    • 9

    Help

    http://php.net/operators.precedence

    32

  • Status code

    What is the default status code of a Symfony\Component\HttpFoundation\RedirectResponse object?

    Wrong

    • 301

    The choices were

    • 300

    • 304

    • 301

    • 302

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/RedirectResponse.php#L35
    • https://tools.ietf.org/html/rfc2616#section-10.3.3

  • Array functions

    What is the output of the following PHP code?

    <?php
    $myArray = [
        0,
        NULL,
        '',
        '0',
        -1
    ];
    echo count( array_filter($myArray) );

    Wrong

    • 3

    The choices were

    • 3

    • An error

    • 4

    • 1

    • 5

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-filter.php
    • https://php.net/manual/en/function.count.php

  • Application events

    The Application class of the Console component allows you to optionally hook into the lifecycle of a console application via events.

    How many events are dispatched?

    Wrong

    • 3

    The choices were

    • 6

    • 1

    • 2

    • 4

    • 3

    • 5

    Help

    https://symfony.com/doc/5.x/components/console/events.html


  • Arithmetic Operators

    What will be displayed by the following code?

    var_dump($expressionLanguage->evaluate(
        'life + universe * everything',
        array(
            'life' => 10,
            'universe' => 10,
            'everything' => 22,
        )
    ));

    Correct

    • 230

    The choices were

    • 230

    • 42

    • 440

    • true

    • 1

    Help

    • http://php.net/manual/en/language.operators.precedence.php
    • http://symfony.com/doc/current/components/expression_language/syntax.html#arithmetic-operators
    230

  • Status code

    What is the default status code of a Symfony\Component\HttpFoundation\Response object?

    Correct

    • 200

    The choices were

    • 204

    • 201

    • 400

    • 202

    • 200

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Response.php#L127

    200

  • BC promise

    When was the Symfony BC promise introduced ?

    Correct

    • 2.3

    The choices were

    • 2.0

    • 2.6

    • 2.9

    • 3.2

    • 2.8

    • 2.3

    • 3.3

    • 2.1

    • 3.0

    • 2.7

    • 3.1

    • 2.4

    • 2.2

    • 2.5

    Help

    https://symfony.com/doc/2.8/contributing/code/bc.html

    2.3

  • Cookies

    How many HTTP requests (without using JavaScript) are required to determine whether or not a client supports cookies?

    Correct

    • 2

    The choices were

    • 2

    • This is not possible without javascript.

    • 1

    • 0

    Help

    • https://tools.ietf.org/html/rfc7230
    2

  • Reference

    What will be the output of the following code?

    class Foo {
        public $value = 42;
        public function &getValue() {
            return $this->value;
        }
    }
    $foo = new Foo;
    $myValue = &$foo->getValue();
    $foo->value = 2;
    echo $myValue;

    Correct

    • 2

    The choices were

    • 0

    • 2

    • 42

    • null

    Help

    • http://php.net/manual/en/language.references.php
    2

  • PHP variables references

    What is the output of the following code ?

    
    function &find_variable(&$one, &$two, &$three) {
        if ($one > 10 && $one < 20) return $one;
        if ($two > 10 && $two < 20) return $two;
        if ($three > 10 && $three < 20) return $three;
    }
    $one = 2; $two = 20; $three = 15;
    $var = &find_variable($one, $two, $three); $var++;
    print "1: $one, 2: $two, 3: $three";

    Correct

    • 1:2, 2:20, 3:16

    The choices were

    • 1:2, 2:30, 3:15

    • 1:3, 2:21, 3:16

    • 1:2, 2:20, 3:16

    • 1:3, 2:20, 3:15

    • 1:2, 2:21, 3:15

    Help

    http://php.net/manual/en/language.references.php

    1:2, 2:20, 3:16

  • Birth

    When was PHP first released by Rasmus Lerdorf?

    Correct

    • 1995

    The choices were

    • 1995

    • 2000

    • 2005

    • 1987

    Help

    • http://php.net/manual/en/history.php.php
    1995

  • Array functions

    What is the output of the following script?

    <?php
    function reducer($total, $elt) { return $elt + $total; }
    $arr = [1, 2, 3, 4, 5];
    echo array_reduce($arr, 'reducer', 1);

    Wrong

    • 15

    The choices were

    • 4

    • 16

    • 5

    • 15

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-reduce.php

  • Terminal helpers

    Given the context where COLUMNS is set as an environment variable with the value of 120, what will be the value returned using the following code?

    <?php
    use Symfony\Component\Console\Terminal;
    echo (new Terminal())->getWidth();

    Correct

    • 120

    The choices were

    • Nothing

    • The width of the actual terminal if used in the context of a terminal

    • 80

    • An error

    • 0

    • 200

    • 120

    Help

    https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Console/Terminal.php

    120

  • Global variables

    Consider the following code snippet:

    $a = 20;
    function my_function($b) { $a = 30; global $a, $c;
    return $c = ($b + $a); }
    print my_function(40) + $c;

    What does this script output when it's executed with PHP?

    Correct

    • 120

    The choices were

    • An error saying something like Undefined variable: ....

    • 70

    • 110

    • 60

    • 120

    Help

    • http://php.net/manual/en/language.variables.scope.php
    • https://3v4l.org/Jrmgk
    120

  • Worker configuration

    What the default sleep option value of the worker?

    Correct

    • 1000000

    The choices were

    • 10

    • 1000

    • 1000000

    • 100

    Help

    https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Messenger/Worker.php#L59

    1000000

  • Arrays

    What will be the output of the following code ?

    $a = [1, 2, 4, 8];
    $b = [0, 2, 4, 6, 8, 10];
    echo count(array_merge(array_diff($a, $b), array_diff($b, $a)));

    Wrong

    • 10

    The choices were

    • 4

    • 2

    • 10

    • 8

    Help

    • http://php.net/count
    • http://php.net/array-merge
    • http://php.net/array-diff

  • Code interpretation

    What is the output of the following twig code?

    {% for i in range(1, 10, 2) %}
        {{ i }}{% if not loop.last %},{% endif %}
    {% endfor %}
    Twig

    Correct

    • 1,3,5,7,9

    The choices were

    • 1,3,5,7,9

    • 2,4,6,8,10

    • 1,10,1,10

    • 1,2,3,4,5,6,7,8,9,10

    Help

    • http://twig.symfony.com/doc/functions/range.html
    1,3,5,7,9

  • Parser

    What is the output ?

    <?php
    function fsplit()
    {
        $spl = 1;
    ?>
    <?php echo $spl; }
    fsplit();

    Correct

    • 1

    The choices were

    • 1

    • 2

    • Nothing

    • Error, function declarations can not be split over multiple PHP segments

    Help

    http://php.net/manual/en/language.basic-syntax.php

    1

  • Array functions

    What is the output ?

    <?php
    $array = [1.1 => '1', 1.2 => '1'];
    echo count ($array);

    Correct

    • 1

    The choices were

    • 4

    • 2

    • 0

    • 1

    Help

    https://www.php.net/manual/en/language.types.array.php

    1

  • Spaceship operator

    Given the following code, what will be displayed?

    <?php
    $a = (object) ['a' => 'b']; $b = (object) ['a' => 'c'];
    echo $b <=> $a;

    Correct

    • 1

    The choices were

    • 1

    • 0

    • -1

    Help

    • https://www.php.net/manual/en/language.operators.comparison.php
    • https://www.php.net/manual/en/types.comparisons.php
    • https://3v4l.org/K4M7W
    1

  • The printf function

    What will be the output of the following script ?

    $str = printf('%.1f', 1/8);
    echo 'Total is ';
    echo $str;

    Correct

    • 0.1Total is 3

    The choices were

    • 3Total is 3

    • 1/8Total is 1/8

    • 0.1Total is 3

    • 0.125Total is 0.1

    • 0.125Total is 0.125

    Help

    http://php.net/manual/en/function.printf.php

    0.1Total is 3

  • Listener priority

    What is the priority of the MessageListener->onMessage()?

    Correct

    • 0

    The choices were

    • -100

    • 0

    • 100

    • -255

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Mailer/EventListener/MessageListener.php#L78

    0

  • Spaceship operator

    Given the following code, what will be displayed?

    <?php
    $a = (object) ['a' => 'a']; $b = (object) ['a' => 'a'];
    echo $b <=> $a;

    Correct

    • 0

    The choices were

    • -1

    • 0

    • 1

    Help

    • https://www.php.net/manual/en/language.operators.comparison.php
    • https://www.php.net/manual/en/types.comparisons.php
    • https://3v4l.org/4aVqU
    0

  • Compiler passes usage

    What is the default priority used when adding a new compiler pass?

    Correct

    • 0

    The choices were

    • 1000

    • -255

    • 0

    • 100

    • 10

    Help

    • https://symfony.com/doc/4.1/components/dependency_injection/compilation.html#controlling-the-pass-ordering
    • https://github.com/symfony/symfony/blob/4.1/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php#L113
    0

  • PHP typecasts

    What is the output ?

    echo strcmp(123, '123');

    Correct

    • 0

    The choices were

    • 1

    • 0

    • An error

    • -1

    Help

    • http://php.net/manual/en/language.types.type-juggling.php
    • http://php.net/manual/fr/function.strcmp.php
    0

  • Process handling

    Given a new process created in front of a Symfony command that return a 0 code, what will be returned by Process::mustRun()?

    Wrong

    • 0

    The choices were

    • false

    • 0

    • An instance of Process

    • true

    • 1

    Help

    https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/Process/Process.php#L209


  • Filesystem

    Given /var/www/myfile.txt is a regular file (not a symlink); what does (new Filesystem())->readlink("/var/www/myfile.txt") return ?

    Wrong

    • /var/www/myfile.txt

    The choices were

    • null

    • /var/www/myfile.txt

    • nothing, an exception is thrown

    Help

    • https://symfony.com/doc/3.2/components/filesystem.html
    • https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Filesystem/Filesystem.php#L398

  • Filesystem usage

    Given the following code and an existing path set to /srv/app which is a symbolic link to srv/sf, what will be stored in $value?

    <?php
    $fs = new Filesystem(); $value = $fs->readLink('/srv/app', false);

    Correct

    • /srv/sf

    The choices were

    • An error

    • false

    • /srv/sf

    • /srv/app

    • true

    Help

    https://symfony.com/doc/3.2/components/filesystem.html#readlink

    /srv/sf

  • Identifying a Request

    For a request to http://example.com/blog/index.php/post/hello-world, what will be the value of $pathInfo in the following code?

    $pathInfo = $request->getPathInfo();

    Correct

    • /post/hello-world

    The choices were

    • example.com/blog/index.php/post/hello-world

    • /index.php/post/hello-world

    • /post/hello-world

    • /blog/index.php/post/hello-world

    Help

    • http://symfony.com/doc/current/components/http_foundation.html#identifying-a-request
    /post/hello-world

  • Route generation

    Given the following definition of the book_list route, what will be the value of the generated URL when calling $router->generate('book_list', ['page' => 2]);?

    # config/routes.yaml
    book_list:
        path:     /books
        controller: 'App\Controller\DefaultController::list'
        methods: [POST]
    YAML

    Correct

    • /books?page=2

    The choices were

    • An error will be thrown

    • https://example.com/books?_page=2

    • https://example.com/books?page=2

    • /books?page=2

    • /books?_page=1

    Help

    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php
    /books?page=2

  • Parameters in route

    Given the following definition of the book_list route, what will be the value of the variable $url?

    # config/routes.yaml
    book_list:
        path:     /books
        controller: 'App\Controller\DefaultController::list'
        methods: [POST]
    YAML
    <?php
    namespace App\Controller;
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    class HomeController extends AbstractController { public function index() { $url = $this->generateUrl('book_list', ['page' => 1]); // ... } }

    Correct

    • /books?page=1

    The choices were

    • /books?_page=1

    • https://example.com/books?page=1

    • https://example.com/books?_page=1

    • Error: Parameter "page" is not defined.

    • /books?page=1

    Help

    https://symfony.com/doc/4.0/routing.html#generating-urls-with-query-strings

    /books?page=1

  • Optional parameters

    What will be the generated URL when calling path('list') from a Twig template?

    /**
     * @Route(
     *  "/blog/{page}",
     *  name="list",
     *  requirements={"page": "\d+"},
     *  defaults={"page": 1}
     * )
     */
    public function list(int $page): Response
    {
        // ...
    }

    Wrong

    • /blog/1

    The choices were

    • /blog

    • /blog/1

    • A MissingMandatoryParametersException will be raised.

    • /blog/

    Help

    • https://symfony.com/doc/2.7/routing/optional_placeholders.html
    • https://symfony.com/doc/2.x/reference/twig_reference.html#path

  • Route matching

    According to the following definition of route, which ones are matching?

    app:
        path: /blog/{page}
        requirements:
            page: \d+
        defaults:
            page: 1
    YAML

    Correct

    • /blog

    • /blog/

    • /blog/1

    The choices were

    • /blog/1

    • /blog/page-1

    • /blog

    • /blog/

    Help

    • http://symfony.com/doc/current/book/routing.html#adding-requirements
    /blog /blog/ /blog/1

  • Support of `.gitignore` files when using the Finder

    When using the Finder to search for files in a directory, it can be instructed to ignore files and paths excluded from Git using the .gitignore file.

    What is the said instruction ?

    Wrong

    • /** @var \Symfony\Component\Finder\Finder $finder */
      $finder->ignoreVCS(true);

    The choices were

    • /** @var \Symfony\Component\Finder\Finder $finder */
      $finder->ignoreVCS(true);
    • /** @var \Symfony\Component\Finder\Finder $finder */
      $finder->ignoreVCSIgnored(true);
    • /** @var \Symfony\Component\Finder\Finder $finder */
      $finder->excludeFromGitIgnore(true);

    Help

    • https://symfony.com/doc/current/components/finder.html#version-control-files
    • https://symfony.com/blog/new-in-symfony-5-4-misc-features-part-2#recursive-gitignore-support-in-finder

  • Path usage

    Given the following code, what will be displayed?

    <?php
    use Symfony\Component\Filesystem\Path;
    echo Path::getRoot("/etc/apache2/sites-available");

    Correct

    • /

    The choices were

    • /etc/apache2/sites-available

    • /

    • /etc/apache2

    • /etc

    • /etc/apache2/

    • /etc/

    Help

    • https://symfony.com/doc/5.4/components/filesystem.html#finding-directories-root-directories
    • https://github.com/symfony/filesystem/blob/5.4/Path.php#L207
    /

  • Function calls

    Consider the following code snippet:

    function sum( ??? )
    {
        return array_sum($args);
    }
    echo 6 === sum(1, 2, 3) ? 'Yes' : 'No';

    What must the ??? placeholder be replaced with in order to make the script print the string Yes on the standard output since PHP 5.6?

    Correct

    • ...$args

    The choices were

    • ...$args

    • $args

    • $args = func_get_args()

    • array $args

    Help

    • http://php.net/manual/en/functions.arguments.php
    • http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list
    ...$args

  • Debug

    What is the console option to display debug message verbosity?

    Correct

    • -vvv

    The choices were

    • --debug-messages

    • --debug

    • -d

    • -vvv

    Help

    https://symfony.com/doc/2.x/console/verbosity.html

    -vvv

  • Listener priority

    What is the priority of the EnvelopeListener->onMessage()?

    Correct

    • -255

    The choices were

    • 255

    • -255

    • 0

    • -100

    • 100

    Help

    https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php#L59

    -255

  • The spaceship operator.

    What will be the output of the following code?

    $a = (object) ["a" => "b"]; 
    $b = (object) ["a" => "c"]; 
    echo $a <=> $b;

    Correct

    • -1

    The choices were

    • -1

    • 1

    • 0

    Help

    http://php.net/manual/en/language.operators.comparison.php

    -1

  • Node Type default value

    How can you set true as default value for a Node Type ?

    Wrong

    • ->default(true);
    • ->setDefault(true);

    The choices were

    • ->defaultTrue();
    • ->isTrue();
    • ->setDefault(true);
    • ->defaultValue(true);
    • ->default(true);

    Help

    https://symfony.com/doc/2.3/components/config/definition.html#default-and-required-values


  • Table helper: column width

    What will be the output of the following command?

    // ...
    class SomeCommand extends Command { public function execute(InputInterface $input, OutputInterface $output) { $table = new Table($output); $table ->setHeaders(['ISBN', 'Title', 'Author']) ->setRows([ ['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'], ['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'], new TableSeparator(), ['960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'], ['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'], ]); $table->setColumnWidth(0, 8); $table->setColumnWidth(2, 30); $table->render(); } }

    Correct

    • +---------------+--------------------------+--------------------------------+
      | ISBN          | Title                    | Author                         |
      +---------------+--------------------------+--------------------------------+
      | 99921-58-10-7 | Divine Comedy            | Dante Alighieri                |
      | 9971-5-0210-0 | A Tale of Two Cities     | Charles Dickens                |
      +---------------+--------------------------+--------------------------------+
      | 960-425-059-0 | The Lord of the Rings    | J. R. R. Tolkien               |
      | 80-902734-1-6 | And Then There Were None | Agatha Christie                |
      +---------------+--------------------------+--------------------------------+
      Plain text

    The choices were

    • +----------+--------------------------+--------------------------------+
      | ISBN     | Title                    | Author                         |
      +----------+--------------------------+--------------------------------+
      | 99921-58 | Divine Comedy            | Dante Alighieri                |
      | 9971-5-0 | A Tale of Two Cities     | Charles Dickens                |
      +----------+--------------------------+--------------------------------+
      | 960-425- | The Lord of the Rings    | J. R. R. Tolkien               |
      | 80-90273 | And Then There Were None | Agatha Christie                |
      +----------+--------------------------+--------------------------------+
      Plain text
    • +---------------+--------------------------+--------------------------------+
      | ISBN          | Title                    | Author                         |
      +---------------+--------------------------+--------------------------------+
      | 99921-58-10-7 | Divine Comedy            | Dante Alighieri                |
      | 9971-5-0210-0 | A Tale of Two Cities     | Charles Dickens                |
      +---------------+--------------------------+--------------------------------+
      | 960-425-059-0 | The Lord of the Rings    | J. R. R. Tolkien               |
      | 80-902734-1-6 | And Then There Were None | Agatha Christie                |
      +---------------+--------------------------+--------------------------------+
      Plain text
    • +-------------+--------------------------+--------------------------------+
      | ISBN        | Title                    | Author                         |
      +-------------+--------------------------+--------------------------------+
      | 99921-58... | Divine Comedy            | Dante Alighieri                |
      | 9971-5-0... | A Tale of Two Cities     | Charles Dickens                |
      +-------------+--------------------------+--------------------------------+
      | 960-425-... | The Lord of the Rings    | J. R. R. Tolkien               |
      | 80-90273... | And Then There Were None | Agatha Christie                |
      +-------------+--------------------------+--------------------------------+
      Plain text

    Help

    https://symfony.com/doc/current/components/console/helpers/table.html

    +---------------+--------------------------+--------------------------------+ | ISBN | Title | Author | +---------------+--------------------------+--------------------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | +---------------+--------------------------+--------------------------------+ | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | | 80-902734-1-6 | And Then There Were None | Agatha Christie | +---------------+--------------------------+--------------------------------+Plain text

  • XPath

    Considering the following HTML structure:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8" />
        </head>
        <body bgcolor="test">
            <a href="test.com">Some link</a>
        </body>
    </html>
    HTML

    And the following PHP script:

    $dom = new DomDocument;
    $dom->load('test.xml');
    $xpath = new DomXPath($dom);
    $nodes = $xpath->query(/* ... */);
    echo $nodes->item(0)->getAttributeNode('bgcolor')->value;

    What Xpath query should go in the /* ... */ to display the bgcolor attribute of the first body node in the XML Document ?

    Correct

    • *[local-name()="body"]

    The choices were

    • /body[0]/text

    • *[local-name()="body"]

    • *[lname()="body"]

    • name="body"

    • /body/body[0]

    Help

    • https://www.w3.org/TR/1999/REC-xpath-19991116/#function-local-name
    • https://www.php.net/manual/fr/class.domxpath.php
    *[local-name()="body"]

  • Process output types

    What are valid output types defined in Process?

    Correct

    • 'err'

    • 'out'

    The choices were

    • 'input'

    • 'output'

    • 'out'

    • 'err'

    • 'error'

    • 'in'

    Help

    • https://symfony.com/doc/2.3/components/process.html#getting-real-time-process-output
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Process/Process.php
    'err' 'out'

  • ChoiceType choice_label option

    With the following code, what can be set as the value of the choice_label option to display the name property of each choice ?

    class Post
    {
        private $name;
        public function __construct($name)
        {
             $this->name = $name;
        }
        public function getName()
        {
            return $this->name;
        }
    }
    $formBuilder->add('posts', ChoiceType::class, [ 'choices' => [new Post('foo'), new Post('bar')] 'choice_label' => /* ... */ ]);

    Wrong

    • 'Post::getName'
    • 'getName'

    The choices were

    • function ($values, $key, $index) {
          return $values[$key];
      }
    • 'getName'
    • 'Post::getName'
    • function ($value, $key, $index) {
          return $value->getName();
      }
    • 'name'
    • false

    Help

    https://symfony.com/doc/2.x/reference/forms/types/choice.html#choice-label


  • Validator

    Which of the following values doesn't trigger a violation when the Date constraint is applied to it?

    Wrong

    • '15/01/2020'

    • new \DateTime('2020-01-15')

    • '2020-01-15'

    The choices were

    • '15/01/2020'

    • '2020-13-15'

    • '15/13/2020'

    • null

    • new \DateTime('2020-01-15')

    • '2020-01-15'

    Help

    • https://symfony.com/doc/6.0/reference/constraints/Date.html
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Validator/Constraints/DateValidator.php
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/Validator/Constraints/DateValidator.php#L45

  • Date Validation

    Which of the following values don't trigger a violation when the Date constraint is applied to them?

    Wrong

    • '15/01/2020'

    • new \DateTime('2020-01-15')

    • '2020-01-15'

    The choices were

    • '2020-01-15'

    • '15/01/2020'

    • '2020-13-15'

    • null

    • new \DateTime('2020-01-15')

    • '15/13/2020'

    Help

    • https://symfony.com/doc/5.0/reference/constraints/Date.html
    • https://github.com/symfony/symfony/blob/5.0/src/Symfony/Component/Validator/Constraints/DateValidator.php

  • ESI Symfony support

    Which ESI (Edge Side Include) element is supported by Symfony?

    Correct

    • <esi:include src="..."/>

    The choices were

    • <esi:remove>

    • <esi:comment text="..." />

    • <esi:inline name="...">

    • <esi:include src="..."/>

    • <esi:choose>

    • <esi:try>

    • <esi:vars>

    Help

    https://symfony.com/doc/6.0/http_cache/esi.html

    <esi:include src="..."/>

  • Escaping

    Which will be the output of the following code ?

    {% set twig = '<h1>Hello from Twig</h1>' %}
    {{ twig|raw|escape('html') }}
    Twig

    Correct

    • &lt;h1&gt;Hello from Twig&lt;/h1&gt;

    The choices were

    • Hello from Twig

    • &lt;h1&gt;Hello from Twig&lt;/h1&gt;

    • An error

    Help

    https://twig.symfony.com/doc/1.x/filters/escape.html

    &lt;h1&gt;Hello from Twig&lt;/h1&gt;

  • Loading Message Catalogs

    What is the way to add a loader to the translator?

    Correct

    • $translator->addLoader('array', new ArrayLoader());

    The choices were

    • $translator->addArrayLoader(new ArrayLoader());
    • $translator->addLoader(new ArrayLoader());
    • $translator->addLoader('array', new ArrayLoader());
    • $translator->addLoader(new ArrayLoader(), 'array');

    Help

    • https://symfony.com/doc/2.x/components/translation/usage.html
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Translation/Translator.php#L68
    $translator->addLoader('array', new ArrayLoader());PHP

  • Parameters in route

    Considering the following definition of route:

    blog:
        path: /blog/{page}
        controller: 'App\Controller\BlogController::index'
        defaults:
            title: "Hello world!"
    YAML

    How can you retrieve the parameter title?
    From the Request object passed by argument to the action of the controller, by writing the following:

    Correct

    • $title = $request->attributes->get('title');

    The choices were

    • $title = $request->attributes['title'];
    • $title = $request->getAttributes()['title'];
    • $title = $request->getAttributes()->get('title');
    • $title = $request->attributes->get('title');

    Help

    • https://symfony.com/doc/4.3/routing.html#extra-parameters
    • https://symfony.com/doc/4.3/routing.html#getting-the-route-name-and-parameters
    • https://github.com/symfony/symfony/blob/e7142a6651bedb33dcce7fb33d2895e3032764e4/src/Symfony/Component/HttpFoundation/Request.php#L82-L87
    $title = $request->attributes->get('title');PHP

  • OOP

    What statement _______ is missing for this code to display 'bar' as a result ?

    class A
    {
        protected static $attr = 'foo';
        public static function getAttr()
        {
            return __________;
        }
    }
    class B extends A { protected static $attr = 'bar'; }
    echo B::getAttr();

    Wrong

    • $this->attr

    The choices were

    • $this->$attr
    • $this->attr
    • static::$attr
    • self::$attr

    Help

    http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php


  • Properties

    How would one access the $a property from within the commented part of the following code?

    <?php
    class Foo { public $a;
    public function __construct() { // ... } }

    Correct

    • $this->a;

    The choices were

    • self::$a;
    • $self->a;
    • $this->$a;
    • self->$a;
    • $this->a;

    Help

    • http://php.net/manual/en/language.oop5.properties.php
    $this->a;PHP

  • Stub

    How to make a stub to throw an exception on a method call?

    Correct

    • $stub
          ->method('doSomething')
          ->will($this->throwException(new Exception))
      ;

    The choices were

    • $stub
          ->method('doSomething')
          ->will(new Exception)
      ;
    • $stub
          ->method('doSomething')
          ->willReturn(new Exception)
      ;
    • $stub
          ->method('doSomething')
          ->will(throw new Exception)
      ;
    • $stub
          ->method('doSomething')
          ->will($this->throwException(new Exception))
      ;

    Help

    • https://phpunit.de/manual/5.7/en/test-doubles.html#test-doubles.stubs.examples.StubTest8.php
    $stub ->method('doSomething') ->will($this->throwException(new Exception)) ;PHP

  • Array functions

    Consider the following PHP script.

    <?php
    function square($val) { return $val ** 2; }
    $arr = [1, 2, 3, 4];
    /** line **/
    $i = 0; foreach ($squares as $value) { if ($i++ > 0) { echo "."; }
    echo $value; }

    What /** line **/ should be used to apply a callback function to every element of an array?

    Correct

    • $squares = array_map('square', $arr);

    The choices were

    • $squares = call_user_func_array($arr, 'square');
    • $squares = array_map('square', $arr);
    • $squares = array_walk($arr, 'square');
    • $squares = call_user_func_array('square', $arr);

    Help

    • https://php.net/array
    • https://php.net/manual/en/function.array-map.php
    $squares = array_map('square', $arr);PHP

  • Varying the Response for HTTP Cache

    Which are the valid ways of caching a Response based not only on the URI but also the value of the Accept-Encoding and User-Agent request headers?

    Wrong

    • $response->setVary('Accept-Encoding, User-Agent');
    • $response->setVary(['Accept-Encoding', 'User-Agent']);
    • $response->headers->set('Vary', 'Accept-Encoding');
      $response->headers->set('Vary', 'User-Agent', false);
    • $response->headers->set('Vary', ['Accept-Encoding', 'User-Agent']);
    • $response->setVary('Accept-Encoding');
      $response->setVary('User-Agent', false);

    The choices were

    • This is the default behavior

    • $response->setVary('Accept-Encoding');
      $response->setVary('User-Agent');
    • $response->setVary('Accept-Encoding, User-Agent');
    • This is not possible without calling a reverse proxy

    • $response->headers->set('Vary', 'Accept-Encoding');
      $response->headers->set('Vary', 'User-Agent', false);
    • $response->headers->set('Vary', ['Accept-Encoding', 'User-Agent']);
    • $response->setVary('Accept-Encoding');
      $response->setVary('User-Agent', false);
    • $response->headers->set('Vary', 'Accept-Encoding, User-Agent');
    • $response->setVary(['Accept-Encoding', 'User-Agent']);
    • $response->headers->set('Vary', 'Accept-Encoding');
      $response->headers->set('Vary', 'User-Agent');

    Help

    • http://symfony.com/doc/current/http_cache/cache_vary.html
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/HttpFoundation/Response.php#L1042
    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php#L98

  • Varying the Response for HTTP Cache

    Which are the valid ways of caching a Response based not only on the URI but also the value of the Accept-Encoding and User-Agent request headers?

    Wrong

    • $response->setVary('Accept-Encoding, User-Agent');
    • $response->headers->set('Vary', 'Accept-Encoding, User-Agent');

    The choices were

    • $response->headers->set('Vary', 'Accept-Encoding');
      $response->headers->set('Vary', 'User-Agent', false);
    • $response->setVary(['Accept-Encoding', 'User-Agent']);
    • $response->headers->set('Vary', 'Accept-Encoding');
      $response->headers->set('Vary', 'User-Agent');
    • This is not possible without calling a reverse proxy

    • $response->setVary('Accept-Encoding');
      $response->setVary('User-Agent');
    • $response->headers->set('Vary', 'Accept-Encoding, User-Agent');
    • $response->headers->set('Vary', ['Accept-Encoding', 'User-Agent']);
    • This is the default behavior

    • $response->setVary('Accept-Encoding, User-Agent');
    • $response->setVary('Accept-Encoding');
      $response->setVary('User-Agent', false);

    Help

    • http://symfony.com/doc/current/http_cache/cache_vary.html
    • https://github.com/symfony/symfony/blob/6.0/src/Symfony/Component/HttpFoundation/Response.php#L1042
    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php#L98

  • Cache

    Which of theses are the way to add the Cache-Control: public,s-maxage=900 HTTP response header on a Symfony\Component\HttpFoundation\Response object?

    Correct

    • $response->setSharedMaxAge(900);

    The choices were

    • $response->setSharedMaxAge(900);
    • $response->setSMaxAge(900);
    • $response->setMaxAge(900, true);
    • $response->setShareMaxAge(900);

    Help

    https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Response.php#L693

    $response->setSharedMaxAge(900);PHP

  • Setting Cookies

    How can one add a cookie named foo with value bar in a Response?

    Correct

    • $response->headers->setCookie(new Cookie('foo', 'bar'));

    The choices were

    • $request->headers->set('foo', 'bar');
    • $request->getCookies()->set('foo', 'bar');
    • $request->get('cookie')->set('foo', 'bar');
    • $response->headers->setCookie(new Cookie('foo', 'bar'));

    Help

    • http://symfony.com/doc/current/components/http_foundation/introduction.html#setting-cookies
    • https://github.com/symfony/symfony/blob/2c14c5fca7182f11abf0a692e471326f14119c29/src/Symfony/Component/HttpFoundation/Cookie.php#L91
    $response->headers->setCookie(new Cookie('foo', 'bar'));PHP

  • OptionsResolver defined options

    In which cases the following call will return true?

    $resolver->isDefined('username');

    Wrong

    • $resolver->setDefined(['username']);
    • $resolver->setDefined('username');

    The choices were

    • $resolver->setDefined(['username']);
    • $resolver->setRequired('username');
    • $resolver->setDefined('username');
    • $resolver->setDefault('username', null);

    Help

    https://symfony.com/doc/2.x/components/options_resolver.html#options-without-default-values


  • OptionsResolver defined options

    In which cases the following call will return true?

    $resolver->isDefined('username');

    Wrong

    • $resolver->setDefined(['username']);
    • $resolver->setDefault('username', null);

    The choices were

    • $resolver->setDefined(['username']);
    • $resolver->setRequired('username');
    • $resolver->setDefault('username', null);
    • $resolver->setDefined('username');

    Help

    https://symfony.com/doc/2.x/components/options_resolver.html#options-without-default-values


  • Option with no default value

    How can you add an option named my_option without setting a default value?

    Correct

    • $resolver->setDefined('my_option');

    The choices were

    • $resolver->setDefined('my_option');
    • $resolver->setDefault('my_option', null);
    • $resolver->setNotRequired('my_option');
    • $resolver->setDefault('my_option');

    Help

    • http://symfony.com/doc/current/components/options_resolver.html#options-without-default-values
    $resolver->setDefined('my_option');PHP

  • Accessing Request Data

    How to access $_SERVER data when using a Symfony\Component\HttpFoundation\Request $request object?

    Correct

    • $request->server

    The choices were

    • $request->server
    • $request->getServerData()
    • $request->getServer()
    • $request->servers
    • $request->getServersData()

    Help

    https://symfony.com/doc/2.3/components/http_foundation/introduction.html#accessing-request-data

    $request->server

  • Accessing Request Data

    How to access $_POST data when using a Symfony\Component\HttpFoundation\Request $request object?

    Correct

    • $request->request

    The choices were

    • $request->post
    • $request->request
    • $request->getPostData()
    • $request->getPost()

    Help

    • http://symfony.com/doc/current/components/http_foundation.html#accessing-request-data
    $request->request

  • Cookie

    How to get a cookie from a $request object?

    Wrong

    • $request->getCookies->get('key', 'default value');

    The choices were

    • $request->getCookies->get('key', 'default value');
    • $request->cookies->get('key', 'default value');
    • $request->get('cookie')->get('key', 'default value');
    • $request->headers->get('key', 'default value');

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Request.php
    • http://symfony.com/doc/current/components/http_foundation/introduction.html#setting-cookies

  • Request

    Which of the following are valid statements to read request data from the Request object?

    Correct

    • $request->files->get('avatar');
    • $request->server->get('HTTP_HOST');
    • $request->headers->get('Accept-Language');

    The choices were

    • $request->session->get('security._last_username');
    • $request->files->get('avatar');
    • $request->headers->get('Accept-Language');
    • $request->server->get('HTTP_HOST');
    • $request->env->get('CLI_COLOR');

    Help

    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Request.php
    • https://symfony.com/doc/2.x/components/http_foundation.html#accessing-request-data
    $request->files->get('avatar');PHP $request->server->get('HTTP_HOST');PHP $request->headers->get('Accept-Language');PHP

  • Accessing Request Data

    How to access $_FILES data when using a Symfony\Component\HttpFoundation\Request $request object?

    Correct

    • $request->files

    The choices were

    • $request->file
    • $request->getFiles()
    • $request->getFileData()
    • $request->getFilesData()
    • $request->files

    Help

    • http://symfony.com/doc/current/components/http_foundation.html#accessing-request-data
    $request->files

  • Creating a request object.

    Which of the following is not a valid way to create an instance of Symfony\Component\HttpFoundation\Request?

    Wrong

    • $request = new Request(/* ... */);

    The choices were

    • $request = new Request(/* ... */);
    • $request = Request::createFromGlobals(/* ... */);
    • $request = Request::createRequestFromFactory(/* ... */);
    • $request = Request::create(/* ... */);

    Help

    • http://symfony.com/doc/current/components/http_foundation.html#request
    • http://symfony.com/doc/current/components/http_foundation.html#simulating-a-request
    • https://github.com/symfony/http-foundation/blob/6.0/Request.php

  • Simulate a Request

    How could you simulate a POST request to /login with login parameter set to admin ?

    Correct

    • $request = Request::create(
          '/login',
          'POST',
          ['login' => 'admin']
      );

    The choices were

    • $request = Request::create(
          '/login',
         null,
          ['login' => 'admin']
      );
    • $request = Request::create(
          'POST',
          '/login',
          ['login' => 'admin']
      );
    • $request = Request::create(
          '/login',
          'POST',
          ['login' => 'admin']
      );
    • $request = Request::create(
         null,
          '/login',
          ['login' => 'admin']
      );

    Help

    • http://symfony.com/doc/current/components/http_foundation.html#simulating-a-request
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpFoundation/Request.php#L266
    $request = Request::create( '/login', 'POST', ['login' => 'admin'] );PHP

  • Simulate a Request

    How could you simulate a GET request to /hello-world ?

    Correct

    • $request = Request::create(
          '/hello-world',
          'GET'
      );
    • $request = Request::create(
          '/hello-world'
      );

    The choices were

    • $request = Request::create(
          '/hello-world',
          'GET'
      );
    • $request = Request::create(
          'GET',
          '/hello-world'
      );
    • $request = Request::create(
          '/hello-world'
      );
    • $request = Request::create(
          null,
          '/hello-world'
      );

    Help

    • https://symfony.com/doc/2.8/components/http_foundation.html#simulating-a-request
    • https://github.com/symfony/symfony/blob/88f3ef62d6ab870128352c8686c7889562698faf/src/Symfony/Component/HttpFoundation/Request.php#L316
    $request = Request::create( '/hello-world', 'GET' );PHP $request = Request::create( '/hello-world' );PHP

  • PID

    What is the method to access the pid of the running process of the following code :

    use Symfony\Component\Process\Process;
    $process = new Process('/usr/bin/php worker.php'); $process->start();

    Correct

    • $pid = $process->getPid();

    The choices were

    • $pid = $process->getPid();
    • $pid = $process->getProcessId();
    • $pid = $process->getData()->getPid();
    • $pid = $process->getData()->getProcessId();

    Help

    • https://symfony.com/doc/2.x/components/process.html#process-pid
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Process/Process.php#L337
    $pid = $process->getPid();PHP

  • SQL knowledge

    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'";

    Correct

    • $pass = "foobar' WHERE user='admin' --";

    The choices were

    • None

    • $pass = "foobar' WHERE user='admin' --";
    • $user = "foobar\' WHERE user='admin'";
    • $pass = "\"foobar\" WHERE";
      $user = "\"admin\"";
    • $user = "foobar\' WHERE user="admin"";

    Help

    http://php.net/manual/fr/security.database.sql-injection.php

    $pass = "foobar' WHERE user='admin' --";PHP

  • OptionsResolver and callable with default values

    What happens if you remove the type-hint Options of $options, in the callable below?

    $resolver->setDefault('port', function (Options $options) {
        if ('ssl' === $options['encryption']) {
            return 465;
        }
    return 25; });

    Wrong

    • $options will automatically be casted to a nullable array

    The choices were

    • Nothing special

    • $options will automatically be casted to a nullable array

    • A fatal error is thrown because of the lack of type-hint

    • The callable itself will be considered as the default value

    Help

    https://symfony.com/doc/6.2/components/options_resolver.html#default-values-that-depend-on-another-option


  • Array functions

    How do you add the value 10 to an array called $myArray?

    Wrong

    • $myArray = array_merge($myArray, [10]);
    • array_shift($myArray, 10);

    The choices were

    • $myArray = array_merge($myArray, 10);
    • array_unshift($myArray, 10);
    • $myArray = array_merge($myArray, [10]);
    • array_shift($myArray, 10);

    Help

    • https://www.php.net/manual/en/language.types.array.php
    • https://www.php.net/manual/en/function.array-merge
    • https://www.php.net/manual/en/function.array-shift
    • https://www.php.net/manual/en/function.array-unshift

  • Passing in Variables

    What is the way to return Honeycrisp with the following code?

    use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
    $language = new ExpressionLanguage();
    class Apple { public $variety; }
    $apple = new Apple(); $apple->variety = 'Honeycrisp';

    Correct

    • $language->evaluate(
          'fruit.variety',
          array(
              'fruit' => $apple,
          )
      );

    The choices were

    • $language->evaluate('apple.variety', $apple);
    • $language->evaluate(
          'fruit.variety',
          array(
              'fruit' => $apple,
          )
      );
    • $language->evaluate('variety', $apple);
    • $language->compile('apple.variety', $apple);

    Help

    • http://symfony.com/doc/current/components/expression_language.html#passing-in-variables
    $language->evaluate( 'fruit.variety', array( 'fruit' => $apple, ) );PHP

  • Array counting

    What is the most recommended way to count the number of occurences of each unique value in the following array?

    <?php
    $a = [1, 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 3, 2, 2, 2];

    Wrong

    • $k = array_unique($a);
      $v = array_fill(0, count($k), 0);
      $n = array_combine($k, $v);
      reset($a); for ($i = 0; $i < count($a); $i++) { ++$n[current($a)]; next($a); }

    The choices were

    • $k = array_unique($a);
      $v = array_fill(0, count($k), 0);
      $n = array_combine($k, $v);
      foreach ($a as $i) { ++$n[$i]; }
    • $n = array_count_values($a);
    • $n = array_total_values($a);
    • $k = array_unique($a);
      $v = array_fill(0, count($k), 0);
      $n = array_combine($k, $v);
      reset($a); for ($i = 0; $i < count($a); $i++) { ++$n[current($a)]; next($a); }
    • $n = count($a);

    Help

    • https://php.net/arrays
    • https://php.net/manual/en/function.array-count-values.php
    • https://php.net/manual/en/function.count.php

  • Array counting

    What is the most recommended way to count the number of occurences of each unique value in the following array?

    <?php
    $a = [1, 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 3, 2, 2, 2];

    Wrong

    • $k = array_unique($a);
      $v = array_fill(0, count($k), 0);
      $n = array_combine($k, $v);
      foreach ($a as $i) { ++$n[$i]; }

    The choices were

    • $n = count($a);
    • $k = array_unique($a);
      $v = array_fill(0, count($k), 0);
      $n = array_combine($k, $v);
      reset($a); for ($i = 0; $i < count($a); $i++) { ++$n[current($a)]; next($a); }
    • $n = array_count_values($a);
    • $n = array_total_values($a);
    • $k = array_unique($a);
      $v = array_fill(0, count($k), 0);
      $n = array_combine($k, $v);
      foreach ($a as $i) { ++$n[$i]; }

    Help

    • https://php.net/arrays
    • https://php.net/manual/en/function.array-count-values.php
    • https://php.net/manual/en/function.count.php

  • Absolute path

    What is the Symfony\Component\Filesystem\Filesystem method to check if the given path is absolute ?

    Correct

    • $fs->isAbsolutePath('/tmp');

    The choices were

    • $fs->isAbsolutePath('/tmp');
    • $fs->checkAbsolutePath('/tmp');
    • $fs->isAbsolute('/tmp');
    • $fs->absolutePath('/tmp');

    Help

    http://symfony.com/doc/current/components/filesystem.html#isabsolutepath

    $fs->isAbsolutePath('/tmp');PHP

  • Dump contents to a file

    What is the Symfony\Component\Filesystem\Filesystem method to dump contents to a file?

    Correct

    • $fs->dumpFile('file.txt', 'Hello World');

    The choices were

    • $fs->dumpFile('file.txt', 'Hello World');
    • $fs->dumpToFile('file.txt', 'Hello World');
    • $fs->dump('file.txt', 'Hello World');
    • $fs->file('file.txt', 'Hello World');

    Help

    http://symfony.com/doc/current/components/filesystem.html#dumpfile

    $fs->dumpFile('file.txt', 'Hello World');PHP

  • RangeType options

    Which of the following snippets is valid to set the maximum and minimum value for a Symfony\Component\Form\Extension\Core\Type\RangeType form type ?

    Correct

    • $formBuilder->add('name', RangeType::class, [
          'attr' => [
              'min' => 5,
              'max' => 50
          ]
      ]);

    The choices were

    • $formBuilder->add('name', RangeType::class, [
          'attr' => [
              'minimum' => 5,
              'maximum' => 50
          ]
      ]);
    • $formBuilder->add('name', RangeType::class, [
          'attr' => [
              'min' => 5,
              'max' => 50
          ]
      ]);
    • $formBuilder->add('name', RangeType::class, [
          'minimum' => 5,
          'maximum' => 50
      ]);
    • $formBuilder->add('name', RangeType::class, [
          'min' => 5,
          'max' => 50
      ]);

    Help

    http://symfony.com/doc/current/reference/forms/types/range.html

    $formBuilder->add('name', RangeType::class, [ 'attr' => [ 'min' => 5, 'max' => 50 ] ]);PHP

  • Submitting a Form

    Which method of a Symfony\Component\Form\Form instance is the most recommended one to invoke in order to process a form in a Symfony controller?

    Correct

    • $form->handleRequest(...);

    The choices were

    • $form->validate(...);

    • $form->submit(...);

    • $form->handleRequest(...);

    • $form->bind(...);

    • $form->process(...);

    Help

    https://symfony.com/doc/2.8/forms.html#handling-form-submissions

    $form->handleRequest(...);

  • Reading from Arrays

    What is the way to get the value of the first_name index of the $person array?

    $person = array(
        'first_name' => 'Wouter',
    );

    Wrong

    • $firstName = $accessor->getValue($person, 'first_name');

    The choices were

    • $firstName = $accessor->readProperty($person, 'first_name');
    • $firstName = $accessor->getValue($person, '[first_name]');
    • $firstName = $accessor->readIndex($person, 'first_name');
    • $firstName = $accessor->getValue($person, 'first_name');

    Help

    • http://symfony.com/doc/current/components/property_access/introduction.html#reading-from-arrays

  • Finder depth

    Which solution will match /home/me/myFile.txt file ?

    Wrong

    • $finder->in('/home/me')->depth('== 0');
    • $finder->in('/home/me');

    The choices were

    • $finder->files()->in('/home')->depth('< 1');
    • $finder->in('/home/me')->depth('== 0');
    • $finder->files()->in('/home');
    • $finder->in('/home/me');
    • $finder->directories()->in('/home')->depth('== 1');
    • $finder->files()->in('/home')->depth('> 1');

    Help

    https://symfony.com/doc/current/components/finder.html#directory-depth


  • Finder depth

    Which solution will match /home/me/myFile.txt file ?

    Wrong

    • $finder->in('/home/me')->depth('== 0');
    • $finder->files()->in('/home')->depth('> 1');
    • $finder->files()->in('/home');
    • $finder->in('/home/me');

    The choices were

    • $finder->in('/home/me')->depth('== 0');
    • $finder->files()->in('/home');
    • $finder->files()->in('/home')->depth('< 1');
    • $finder->directories()->in('/home')->depth('== 1');
    • $finder->files()->in('/home')->depth('> 1');
    • $finder->in('/home/me');

    Help

    https://symfony.com/doc/current/components/finder.html#directory-depth


  • VCS Files

    By default, the Finder ignores popular VCS files, what is the method to use them ?

    Correct

    • $finder->ignoreVCS(false);

    The choices were

    • $finder->ignoreFiles(array('vcs' => false));
    • $finder->enableVCSFiles();
    • $finder->ignoreVCS(false);
    • $finder->useTypes(array('vcs' => true);
    • $finder->enableVCS();

    Help

    https://symfony.com/doc/2.7/components/finder.html#files-or-directories

    $finder->ignoreVCS(false);PHP

  • Finder depth

    Which solution will match /home/me/myFile.txt file ?

    Wrong

    • $finder->files()->in('/home')->depth('< 1');
    • $finder->files()->in('/home');

    The choices were

    • $finder->files()->in('/home')->depth('< 1');
    • $finder->in('/home/me')->depth('== 0');
    • $finder->in('/home/me');
    • $finder->files()->in('/home');
    • $finder->directories()->in('/home')->depth('== 1');
    • $finder->files()->in('/home')->depth('> 1');

    Help

    https://symfony.com/doc/current/components/finder.html#directory-depth


  • PHP DOM

    What should ????? be replaced with to add a <title> node with the value of "Hello, World!"?

    $title = $dom->createElement('title');
    $node = ?????????
    $title->appendChild($node); $head->appendChild($title);

    Correct

    • $dom->createTextNode('Hello, World!');

    The choices were

    • $dom->createTextNode('Hello, World!');
    • None of the above

    • $dom->appendTextNode($title, "Hello, World!");
    • $dom->createElement('text', 'Hello, World!');
    • $dom->appendElement($title, 'text', 'Hello, World!');

    Help

    • http://www.php.net/dom
    • http://php.net/manual/en/domdocument.createtextnode.php
    $dom->createTextNode('Hello, World!');PHP

  • Connecting Listeners

    How can you register the AcmeListener to the EventDispatcher in order to call the onFooAction method when the acme.action event is dispatched with the following code?

    <?php
    use Symfony\Component\EventDispatcher\EventDispatcher;
    $dispatcher = new EventDispatcher();
    $listener = new AcmeListener();

    Correct

    • $dispatcher->addListener('acme.action', array($listener, 'onFooAction'));

    The choices were

    • $dispatcher->addListener('acme.action', $listener, 'onFooAction');
    • $dispatcher->addListener('acme.action', array($listener, 'onFooAction'));
    • $dispatcher->registerListener('acme.action', $listener, 'onFooAction');
    • $dispatcher->registerListener('acme.action', array($listener, 'onFooAction'));

    Help

    • http://symfony.com/doc/current/components/event_dispatcher/introduction.html#connecting-listeners
    • https://github.com/symfony/symfony/blob/e71d4713c506686e6cf027af44c97ee5d94c7db4/src/Symfony/Component/EventDispatcher/EventDispatcher.php#L102
    $dispatcher->addListener('acme.action', array($listener, 'onFooAction'));PHP

  • Find by date

    It's 10AM, which values of $date Symfony\Component\Finder\Finder::date($date) will find a file modified yesterday at 9AM ?

    Wrong

    • $date = 'yesterday';
    • $date = 'until 1 day';
    • $date = 'before yesterday';
    • $date = 'before 1 day';

    The choices were

    • $date = 'since yesterday';
    • $date = 'until 1 day';
    • $date = 'yesterday';
    • $date = 'before 1 day';
    • $date = 'before yesterday';
    • $date = 'after 1 day ago';
    • $date = 'after 2 days ago';

    Help

    • https://symfony.com/doc/2.3/components/finder.html#file-date
    • https://www.php.net/manual/en/datetime.formats.php#datetime.formats.relative

  • Find by date

    It's 10AM, which values of $date Symfony\Component\Finder\Finder::date($date) will find a file modified yesterday at 9AM ?

    Wrong

    • $date = 'before yesterday';
    • $date = 'before 1 day';

    The choices were

    • $date = 'yesterday';
    • $date = 'until 1 day';
    • $date = 'before 1 day';
    • $date = 'after 1 day ago';
    • $date = 'after 2 days ago';
    • $date = 'before yesterday';
    • $date = 'since yesterday';

    Help

    • https://symfony.com/doc/2.3/components/finder.html#file-date
    • https://www.php.net/manual/en/datetime.formats.php#datetime.formats.relative

  • Service definition

    With the following service definition how is it possible to access the mailer service?

    services:
        app.mailer.one:
            class: App\OneMailer
            arguments: [sendmail]
            public: false
    app.mailer: alias: app.mailer.one public: true
    YAML

    Correct

    • $container->get('app.mailer');

    The choices were

    • $container->get('app.mailer.one');
    • It is not possible.

    • $container->get('app.mailer');

    Help

    • https://symfony.com/doc/current/components/dependency_injection/advanced.html#aliasing
    $container->get('app.mailer');PHP

  • Max retries configuration

    How can you control the maximum number of retry attempts with Symfony\Component\HttpClient\RetryableHttpClient?

    Wrong

    • $client = new RetryableHttpClient(HttpClient::create());
      $client = $client->withOptions(['max_retries' => 4]);
    • $client = new RetryableHttpClient(HttpClient::create(), null, 4);

    The choices were

    • $client = new RetryableHttpClient(HttpClient::create(), null, 4);
    • $client = new RetryableHttpClient(HttpClient::create(), null, ['max_retries' => 4]);
    • $client = new RetryableHttpClient(HttpClient::create());
      $client->request('GET', '/some/url', ['max_retries' => 4]);
    • $client = new RetryableHttpClient(HttpClient::create());
      $client = $client->withOptions(['max_retries' => 4]);

    Help

    • https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/HttpClient/RetryableHttpClient.php#L42
    • https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/HttpClient/RetryableHttpClient.php#L62
    • https://symfony.com/blog/new-in-symfony-6-4-dx-improvements-part-2#maximum-retries-in-http-client

  • DataTransformer

    How to add a DataTransformer to the tags field?

    Correct

    • 
      $builder->add(
          $builder
              ->create('tags', TextType::class)
              ->addModelTransformer(...)
      );
    • $builder->add('tags', TextType::class);
      $builder->get('tags')
              ->addModelTransformer(...);

    The choices were

    • $builder->add('tags', TextType::class)
              ->addModelTransformer(...);
    • 
      $builder->add(
          $builder
              ->create('tags', TextType::class)
              ->addModelTransformer(...)
      );
    • $builder->add('tags', TextType::class);
      $builder->get('tags')
              ->addModelTransformer(...);

    Help

    http://symfony.com/doc/current/form/data_transformers.html#simple-example-transforming-string-tags-from-user-input-to-an-array

    $builder->add( $builder ->create('tags', TextType::class) ->addModelTransformer(...) );PHP $builder->add('tags', TextType::class); $builder->get('tags') ->addModelTransformer(...);PHP

  • Magic __call() Method

    What is the way to enable magic __call method?

    Correct

    • $accessor = PropertyAccess::createPropertyAccessorBuilder()
          ->enableMagicCall()
          ->getPropertyAccessor()
      ;

    The choices were

    • $accessor = PropertyAccess::createPropertyAccessorBuilder()
          ->getPropertyAccessor(true)
      ;
    • $accessor = PropertyAccess::createPropertyAccessorBuilder()
          ->enableMagicCall()
          ->getPropertyAccessor()
      ;
    • $accessor = PropertyAccess::createPropertyAccessor(true);
    • $accessor = PropertyAccess::createPropertyAccessor()
          ->enableMagicCall()
      ;

    Help

    • http://symfony.com/doc/current/components/property_access/introduction.html#magic-call-method
    $accessor = PropertyAccess::createPropertyAccessorBuilder() ->enableMagicCall() ->getPropertyAccessor() ;PHP

  • Comparison operators.

    Which of the following operators is also known as the Elvis operator?

    Correct

    • $a ?: $b

    The choices were

    • $a ?: $b
    • $a <=> $b
    • $a ** $b

    Help

    • https://en.wikipedia.org/wiki/Elvis_operator#PHP
    $a ?: $bPHP

  • Predefined variables

    From which global arrays is it possible to read submitted form data?

    Wrong

    • $_GET

    • $_POST

    The choices were

    • $_POST

    • $_GET

    • $_COOKIE

    • $_REQUEST

    • $_SESSION

    • $_ENV

    Help

    • http://php.net/manual/en/reserved.variables.get.php
    • http://php.net/manual/en/reserved.variables.post.php
    • http://php.net/manual/en/reserved.variables.session.php
    • http://php.net/manual/en/reserved.variables.request.php
    • http://php.net/manual/en/reserved.variables.environment.php
    • http://php.net/manual/en/reserved.variables.cookies.php

  • Dotenv

    Given you have an already register env var MYVAR=foo in your shell and you load MYVAR=bar from a .env file via the Dotenv component. What will happen ?

    Wrong

    • $_ENV['MYVAR'] will be equal to bar

    • getenv('MYVAR') will return bar

    The choices were

    • $_ENV['MYVAR'] will be equal to bar

    • $_ENV['MYVAR'] will be equal to foo

    • getenv('MYVAR') will return bar

    • an exception will be thrown

    • getenv('MYVAR') will return foo

    Help

    • https://symfony.com/doc/3.3/components/dotenv.html

  • CLI PHP

    Which PHP superglobal variable contains the command line arguments when the script runs in CLI mode?

    Wrong

    • $_ENV

    The choices were

    • $_SERVER

    • $_POST

    • PHP cannot run from the command line interface.

    • $_CLI

    • $_ENV

    Help

    • http://php.net/manual/en/language.variables.superglobals.php

  • Security

    Which of the following list of potential data sources should be considered trusted ?

    Wrong

    • $_ENV

    The choices were

    • $_COOKIE

    • $_SERVER

    • None

    • $_ENV

    • $_POST

    Help

    http://php.net/manual/en/security.php


  • Composer + Symfony

    Which of the following Composer commands is recommended to execute on production servers to increase the performance of your Symfony applications?

    Wrong

    • $ composer dump-autoload --optimize --apc-class-autoload

    The choices were

    • $ composer optimize-autoload --no-dev

    • $ composer optimize-autoload

    • $ composer dump-autoloader --optimize --no-dev

    • $ composer dump-autoload --optimize --no-dev --classmap-authoritative

    • $ composer dump-autoload --optimize --apc-class-autoload

    Help

    • http://symfony.com/doc/current/performance.html
    • https://getcomposer.org/doc/articles/autoloader-optimization.md

  • Serialization Context

    How to specify the date format for a date attribute in a serialization context ?

    Correct

    • 
          #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
          public \DateTime $date;
      
    • 
          /**
           * @Serializer\Context({ DateTimeNormalizer::FORMAT_KEY = 'Y-m-d' })
           */
          public \DateTime $date;

    The choices were

    • 
          /**
           * @Serializer\Context({ DateTimeNormalizer::FORMAT_KEY = 'Y-m-d' })
           */
          public \DateTime $date;
    • It's not possible

    • 
          #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
          public \DateTime $date;
      
    • 
          /**
           * @Serializer\DateFormat('Y-m-d' )
           */
          public \DateTime $date;

    Help

    https://symfony.com/blog/new-in-symfony-5-3-inlined-serialization-context

    #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])] public \DateTime $date; PHP /** * @Serializer\Context({ DateTimeNormalizer::FORMAT_KEY = 'Y-m-d' }) */ public \DateTime $date;PHP

  • Routing default values

    Which of the following allows to give a default value to a route parameter ?

    Wrong

    • #[Route('/blog/posts/page/{page}', name:"paginated_posts", defaults:['page' => 1])]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts")]
      public function postPages(int $page=1): Response

    The choices were

    • #[Route('/blog/posts/page/{page}', name:"paginated_posts", defaults:['page' => 1])]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page?1}', name:"paginated_posts")]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page?default=1}', name:"paginated_posts")]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts")]
      public function postPages(int $page=1): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts", page:['defaults' => 1])]
      public function postPages(int $page): Response

    Help

    • https://symfony.com/doc/6.3/routing.html

  • Routing default values

    Which of the following allows to give a default value to a route parameter ?

    Wrong

    • #[Route('/blog/posts/page/{page?default=1}', name:"paginated_posts")]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts", defaults:['page' => 1])]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts")]
      public function postPages(int $page=1): Response

    The choices were

    • #[Route('/blog/posts/page/{page?default=1}', name:"paginated_posts")]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts")]
      public function postPages(int $page=1): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts", page:['defaults' => 1])]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page?1}', name:"paginated_posts")]
      public function postPages(int $page): Response
    • #[Route('/blog/posts/page/{page}', name:"paginated_posts", defaults:['page' => 1])]
      public function postPages(int $page): Response

    Help

    • https://symfony.com/doc/6.3/routing.html

  • Serializer

    Given the following denormalization attempt:

    class ValueObject
    {
      private $foo;
    public function __construct($bar) { $this->foo = $bar; }
    public function getFoo() { return $this->foo; } }
    $normalizer = new GetSetMethodNormalizer(); $vo = $normalizer->denormalize(['bar' => 'symfony'], ValueObject::class);
    echo $vo->getFoo();

    What will be displayed ?

    Correct

    • "symfony"

    The choices were

    • "symfony"

    • nothing, an exception will be thrown

    • an empty string

    Help

    • https://github.com/symfony/symfony/blob/8c778cbaa30db02fee9d972badcac834b51da0fa/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L369
    "symfony"

  • setAllowedTypes

    Which of the following are valid types to use in setAllowedTypes method of Symfony\Component\OptionsResolver\OptionsResolver to validate a integer value?

    Correct

    • "integer"
    • "int"

    The choices were

    • OptionsResolver::INT
    • "int"
    • OptionsResolver::INTEGER
    • "integer"

    Help

    • https://symfony.com/doc/2.3/components/options_resolver.html#configure-allowed-types
    • https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/OptionsResolver/OptionsResolver.php
    "integer"PHP "int"PHP

  • setAllowedTypes

    Which of the following are valid types to use in setAllowedTypes method of Symfony\Component\OptionsResolver\OptionsResolver to validate a boolean value?

    Correct

    • "boolean"
    • "bool"

    The choices were

    • OptionsResolver::BOOLEAN
    • "bool"
    • OptionsResolver::BOOL
    • "boolean"

    Help

    • https://symfony.com/doc/3.0/components/options_resolver.html#type-validation
    • https://github.com/symfony/symfony/blob/3.0/src/Symfony/Component/OptionsResolver/OptionsResolver.php
    "boolean"PHP "bool"PHP