E
E
EVOSandru62018-02-20 19:52:46
PHP
EVOSandru6, 2018-02-20 19:52:46

Is it possible in PHP to get annotations for a specific property and vice versa?

Good afternoon,
You can pull it out of the class in this way:

function getClassAnnotations($class)
{       
    $r = new ReflectionClass($class);
    $doc = $r->getDocComment();
    preg_match_all('#@(.*?)\n#s', $doc, $annotations);
    return $annotations[1];
}

Is it possible to extract all its @annotations from a certain property of a class Or
, on the contrary, is it possible to extract all the properties of a class annotated by it using a certain annotation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question