Skip to content

Skipped annotation when line above contains double quote (v1.8.0) #307

@keksa

Description

@keksa

The second Regex annotation is ignored by annotation reader, if the line above contains a double quote ". See the very simplified example:

class

namespace AppBundle\Component;

use Symfony\Component\Validator\Constraints as Assert;

class Foo
{
    /**
     * @Assert\Regex(pattern="~[a-zA-Z]~")
     * "
     * @Assert\Regex(pattern="~[<>\\'""*]+~", match=false)
     */
    private $foo;
}

reader

$reflectionClass = new \ReflectionClass(\AppBundle\Component\Foo::class);
$property = $reflectionClass->getProperty('foo');

$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$annotations = $reader->getPropertyAnnotations($property);
dump($annotations);

expected result

array:2 [▼
  0 => Regex^ {#1592 ▼
    +message: "This value is not valid."
    +pattern: "~[a-zA-Z]~"
    +htmlPattern: null
    +match: true
    +payload: null
  }
  1 => Regex^ {#1533 ▼
    +message: "This value is not valid."
    +pattern: "~[<>\\'"*]+~"
    +htmlPattern: null
    +match: false
    +payload: null
  }
]

actual result

array:1 [▼
  0 => Regex^ {#1592 ▼
    +message: "This value is not valid."
    +pattern: "~[a-zA-Z]~"
    +htmlPattern: null
    +match: true
    +payload: null
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions