Xannotation 高性能的 PHP 注解分析器开源项目

我要开发同款
匿名用户2018年07月12日
92阅读

技术信息

官网地址
/josinli/phpdoc-parser
开源地址
https://gitee.com/josinli/phpdoc-parser
授权协议
LGPL

作品详情

phpdoc-parser

高性能的PHP注解分析器,基于PHP7.x开发的一个PHP扩展

AextesioforPHPdocumetparsig.writteiCcode.

Author:Josi774542602@qq.com

使用环境

PHP7.x

cmake编译或者PHP扩展编译

1、扩展编译

/usr/path_to_php/bi/phpize./cofigure --with-php-cofig=/usr/path_to_php/php-cofigmake -j && sudo make istall -jecho 'xaotatio.so' >> /usr/path_to_php/php.ii

2、cmake

需要cmake3.10版本

修改 CMakeLists.txt中的 php 路径, 然后执行如下命令即可     cmake .即可

简洁的APIs

Xa类构造函数

fial class Xa{    fuctio __costruct();}

类注解:Xa::getClassDocCommet($classNameOrObject)

/** * 返回类的注解字符串 *  * @param $classNameOrObject 类名称或者对象 */fuctio getClassDocCommet($classNameOrObject){    retur $this;}

方法注解:Xa::getMethodDocCommet($classNameOrObject,$methodName)

/** * 获取方法的注解信息,返回注解字符串 * * @param $classNameOrObject 类名称或者对象 * @param $methodName        方法名 */fuctio getMethodDocCommet($classNameOrObject, $methodName){}

解析注解:Xa::parseDocCommet($docCommets)

/** * 返回一个包含注解信息的对象,[body]包含的是说明信息,其余的注解每一个注解是一个数组 * 如: * /** *  * 类对象A *  * *  * @Route("/hello/world") *  * @NotEmpty(ame="age", versio="v2.1.1") *  */ * class A * { * } * * 那么返回结果如下: * Array * ( *     [aotatios] => Array *         ( *             [Route] => Array *                 ( *                     [1] => hello/world *                 ) *  *             [method] => Array *                 ( *                     [3] => vs *                     [value se] => hello *                     [yes] => fsdfls *                 ) *  *         ) *  *     [um] => 2 *     [body] =>  * ) * * @param $docCommets 需要解析的注解信息 */fuctio parseDocCommet($docCommets){}

获取数组形式的注解:Xa::getParseResult($docCommets)

/** * 同 parseDocComet() 结果,区别在于返回的数组还是对象 */fuctio getParseResult($docCommets){}

获取类的所有方法的注解信息:parseAllMethodsDocCommet($objectOrName)

/** * Fuctio: `parseAllMethodsDocCommet` used to parsig all methods which i class{$objectOrName} * retur the object cotais the result, the result format like this: * <pre> * Xa Object * ( *     [um] => 3 *     [aotatios] => Array *         ( *             [world] => Array *                 ( *                     [aotatios] => Array *                         ( *                             [Route] => Array *                                 ( *                                     [1] => hello/world *                                 ) * *                             [method] => Array *                                 ( *                                     [3] => vs *                                     [value se] => hello *                                     [yes] => fsdfls *                                 ) * *                         ) * *                     [um] => 2 *                     [body] => *                 ) * *             [getMethodDocCommet] => Array *                 ( *                     [aotatios] => *                     [um] => 0 *                     [body] => 获取方法的注解信息,返回一个对象 *                 ) * *             [getClassDocCommet] => Array *                 ( *                     [aotatios] => *                     [um] => 0 *                     [body] => 返回类的注解信息 *                 ) *         ) * ) * <pre> * * The result cotais the `um` key meas the methods umber * the `aotatios` key cotais the result array, each key-value pair cotais the key(The fuctio ame) & the value(array) * each value cotais three key-value pairs: * `aotatios`: The aotatios the fuctio cotais * `um`        : The umber of the aotatios * `body`       : The body of the aotatios * * @param $objectOrName  The class ame or object which you wat to obtai the aotatios * @retur this          The object cotais the value */fuctio parseAllMethodsDocCommet($objectOrName) : this{}

功能介绍

phpdoc-parser 高性能的 PHP 注解分析器,基于 PHP7.x 开发的一个PHP扩展 An extension for PHP document parsing. written ...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论