This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/UPGRADE-3.2.md
Fabien Potencier d2a7994a2d feature #19257 [Validator][Choice] Make strict the default option for choice validation (peterrehm)
This PR was squashed before being merged into the 3.2-dev branch (closes #19257).

Discussion
----------

[Validator][Choice] Make strict the default option for choice validation

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #18973
| License       | MIT
| Doc PR        | -

This is just the WIP as there are two options.

1. Just change default which would only possible to introduce in 4.x or in 3.2 if this BC break is considered as acceptable

2. Add a new option e.g. `strictComparison` which defaults to true in 4.x and deprecate the usage of the strict option for 3.2.

3. Just deprecate strict = false and remove the option but I would be against that as we remove flexibility which might be wanted.

As per discussion I went ahead with option 3. We can then still decide if we want to remove the option entirely or eventually reenable setting strict to false in a later release.

Commits
-------

177c513 [Validator][Choice] Make strict the default option for choice validation
2016-09-14 15:04:04 -07:00

2.8 KiB

UPGRADE FROM 3.1 to 3.2

FrameworkBundle

  • The Controller::getUser() method has been deprecated and will be removed in Symfony 4.0; typehint the security user object in the action instead.

DependencyInjection

  • Calling get() on a ContainerBuilder instance before compiling the container is deprecated and will throw an exception in Symfony 4.0.

Form

  • Calling isValid() on a Form instance before submitting it is deprecated and will throw an exception in Symfony 4.0.

    Before:

    if ($form->isValid()) {
        // ...
    }
    

    After:

    if ($form->isSubmitted() && $form->isValid()) {
        // ...
    }
    

FrameworkBundle

  • The service serializer.mapping.cache.doctrine.apc is deprecated. APCu should now be automatically used when available.

HttpFoundation

  • Extending the following methods of Response is deprecated (these methods will be final in 4.0):

    • setDate/getDate
    • setExpires/getExpires
    • setLastModified/getLastModified
    • setProtocolVersion/getProtocolVersion
    • setStatusCode/getStatusCode
    • setCharset/getCharset
    • setPrivate/setPublic
    • getAge
    • getMaxAge/setMaxAge
    • setSharedMaxAge
    • getTtl/setTtl
    • setClientTtl
    • getEtag/setEtag
    • hasVary/getVary/setVary
    • isInvalid/isSuccessful/isRedirection/isClientError/isServerError
    • isOk/isForbidden/isNotFound/isRedirect/isEmpty

Validator

  • Tests\Constraints\AbstractConstraintValidatorTest has been deprecated in favor of Test\ConstraintValidatorTestCase.

    Before:

    // ...
    use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
    
    class MyCustomValidatorTest extends AbstractConstraintValidatorTest
    {
        // ...
    }
    

    After:

    // ...
    use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
    
    class MyCustomValidatorTest extends ConstraintValidatorTestCase
    {
        // ...
    }
    
  • Setting the strict option of the Choice Constraint to false has been deprecated and the option will be changed to true as of 4.0.

    // ...
    use Symfony\Component\Validator\Constraints as Assert;
    
    class MyEntity
    {
        /**
         * @Assert\Choice(choices={"MR", "MRS"}, strict=true)
         */
        private $salutation;
    }
    

Yaml

  • Support for silently ignoring duplicate mapping keys in YAML has been deprecated and will lead to a ParseException in Symfony 4.0.

  • Mappings with a colon (:) that is not followed by a whitespace are deprecated and will lead to a ParseException in Symfony 4.0 (e.g. foo:bar must be foo: bar).