waleedzahid106a/doc-reader
Composer 安装命令:
composer require waleedzahid106a/doc-reader
包简介
Just a Simple Annotation Parser in PHP
README 文档
README
Just a Simple Annotation Parser in PHP
Installation
Just Download this Repository and Place src folder on your server directory.
Examples
Type conversion example
<?php include_once "src/DocReader/DocReader.php"; class MyClass { /** * @var0 1.5 * @var1 1 * @var2 "123" * @var3 abc * @var4 ["a", "b"] * @var5 {"x": "y"} * @var6 {"x": {"y": "z"}} * @var7 {"x": {"y": ["z", "p"]}} * * @var8 * @var9 null * * @var10 true * @var11 tRuE * @var12 false * @var13 null * */ private function MyMethod() { } }; $reader = new DocReader\Reader("MyClass", "MyMethod"); var_dump($reader->getParams());
Multi value example
<?php include_once "src/DocReader/DocReader.php"; class MyClass { /** * @var x * @var2 1024 * @param string x * @param integer y * @param array z */ private function MyMethod() { } }; $reader = new DocReader\Reader("MyClass", "MyMethod"); var_dump($reader->getParams());
will print
array (size=3)
'var' => string 'x' (length=1)
'var2' => int 1024
'param' =>
array (size=3)
0 => string 'string x' (length=8)
1 => string 'integer y' (length=9)
2 => string 'array z' (length=7)
Variables on the same line
<?php include_once "src/DocReader/DocReader.php"; class MyClass { /** * @get @post * @ajax * @postParam x @postParam y * @postParam z */ private function MyMethod() { } }; $reader = new DocReader\Reader("MyClass", "MyMethod"); var_dump($reader->getParams());
will print
array (size=4)
'get' => boolean true
'post' => boolean true
'ajax' => boolean true
'postParam' =>
array (size=3)
0 => string 'x' (length=1)
1 => string 'y' (length=1)
2 => string 'z' (length=1)
Variable declarations functionality example
I found below functionality useful for filtering $_GET/$_POST data in CodeIgniter. Hopefully I will soon release my CodeIgniter's modification.
<?php include_once "src/DocReader/DocReader.php"; class MyClass { /** * @param string var1 * @param integer var2 */ private function MyMethod() { } }; $reader = new DocReader\Reader("MyClass", "MyMethod"); var_dump($reader->getVarDeclarations("param"));
will print
array (size=2)
0 =>
array (size=2)
'type' => string 'string' (length=6)
'name' => string 'var1' (length=4)
1 =>
array (size=2)
'type' => string 'integer' (length=7)
'name' => string 'var2' (length=4)
统计信息
- 总下载量: 1.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-02-07