可以从此类文档中获得:
/**
* @mapping(table='example')
*/
class Example {
输出如下:
Array
(
[table] => 'example'
)
等等,多个逗号分隔的参数,如@mapping(table='example', else=something,...) 使用正则表达式?
这实际上是我当前用于解析反射类文档内容的代码,该代码位于堆栈的某处。我对正则表达式不是那么强,感谢您的帮助!
function parseAnnotations($doc)
{
preg_match_all('/@([a-z]+?)\s+(.*?)\n/i', $doc, $annotations);
if(!isset($annotations[1]) OR count($annotations[1]) == 0){
return [];
}
return array_combine(array_map("trim",$annotations[1]), array_map("trim",$annotations[2]));
}