From 3f6afe54cdbdc63a8366195f72cf1a37c962692b Mon Sep 17 00:00:00 2001 From: Alex Kalineskou Date: Mon, 28 Sep 2020 22:45:24 +0300 Subject: [PATCH] Fix property_exists for SymfonyConstraintAnnotationReader --- .../Annotations/SymfonyConstraintAnnotationReader.php | 2 +- .../Annotations/SymfonyConstraintAnnotationReaderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php b/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php index 4f392ef..dfd10c2 100644 --- a/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php +++ b/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php @@ -49,7 +49,7 @@ class SymfonyConstraintAnnotationReader foreach ($annotations as $annotation) { if ($annotation instanceof Assert\NotBlank || $annotation instanceof Assert\NotNull) { // To support symfony/validator < 4.3 - if ($annotation instanceof Assert\NotBlank && \method_exists($annotation, 'allowNull') && $annotation->allowNull) { + if ($annotation instanceof Assert\NotBlank && \property_exists($annotation, 'allowNull') && $annotation->allowNull) { // The field is optional continue; } diff --git a/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php b/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php index a7e5827..fd1b245 100644 --- a/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php +++ b/Tests/ModelDescriber/Annotations/SymfonyConstraintAnnotationReaderTest.php @@ -49,7 +49,7 @@ class SymfonyConstraintAnnotationReaderTest extends TestCase public function testOptionalProperty() { - if (!\method_exists(Assert\NotBlank::class, 'allowNull')) { + if (!\property_exists(Assert\NotBlank::class, 'allowNull')) { $this->markTestSkipped('NotBlank::allowNull was added in symfony/validator 4.3.'); }