Merge branch '3.x'

This commit is contained in:
Guilhem Niot 2020-09-20 20:38:43 +02:00
commit 416d1f2d2a
3 changed files with 6 additions and 4 deletions

View File

@ -48,7 +48,8 @@ class SymfonyConstraintAnnotationReader
foreach ($annotations as $annotation) {
if ($annotation instanceof Assert\NotBlank || $annotation instanceof Assert\NotNull) {
if ($annotation instanceof Assert\NotBlank && $annotation->allowNull) {
// To support symfony/validator < 4.3
if ($annotation instanceof Assert\NotBlank && \method_exists($annotation, 'allowNull') && $annotation->allowNull) {
// The field is optional
continue;
}

View File

@ -16,9 +16,6 @@ use OpenApi\Annotations as OA;
use OpenApi\Annotations\OpenApi;
use Symfony\Component\Routing\Route;
/**
* @internal
*/
trait RouteDescriberTrait
{
/**

View File

@ -49,6 +49,10 @@ class SymfonyConstraintAnnotationReaderTest extends TestCase
public function testOptionalProperty()
{
if (!\method_exists(Assert\NotBlank::class, 'allowNull')) {
$this->markTestSkipped('NotBlank::allowNull was added in symfony/validator 4.3.');
}
$entity = new class() {
/**
* @Assert\NotBlank(allowNull = true)