创建 PHP 类大纲
我正在寻找一个可以有效地概述类的函数或类:
class MyClass{
/*
* Perhaps include the function comments
* in the function.
*/
function mainFunction(){
//Does Something
}
function functionWithArgs($arg1,$arg2=false){
//Does Something
//The function I want will give e the arguments w/default values
}
}
是否存在可以让我以某种方式访问有关此类甚至文件的信息的函数或库。
前任。
get_file_outline('fileWithAboveClass.php');
或
get_class_outline('MyClass');
有人知道其中之一,或者知道一种轻松编写此代码的方法吗?
I am looking for a function or class that can effectively outline a class:
class MyClass{
/*
* Perhaps include the function comments
* in the function.
*/
function mainFunction(){
//Does Something
}
function functionWithArgs($arg1,$arg2=false){
//Does Something
//The function I want will give e the arguments w/default values
}
}
Is there a function or library in existence that can give me some kind of access to the information about this class, or even the file.
ex.
get_file_outline('fileWithAboveClass.php');
or
get_class_outline('MyClass');
Does anybody know of either, or know a way of easily writing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 PHP Reflection API
请注意,要使评论提取正常工作,它们的格式必须像 PHPDoc / Doxygen 注释一样,并以开头
/**
开头Take a look at the PHP Reflection API
Note that for the comment extraction to work, they have to be formatted like PHPDoc / Doxygen comments, and begin with an opening
/**
还有一个命令行选项可用于检查函数和类。
将为您提供有关 DateTime 类的所有详细信息,同时
将为您提供“in_array”函数的参数。
如果您在编码时使用终端,那么使用它会非常方便,而不是一直在 PHP 手册中查找;)
There's also a command line option available for inspecting functions and classes.
will give you all the details about the DateTime-class, while
will give you the arguments of the "in_array" function.
If you're using the Terminal when coding it can be quite handy to use instead of looking it up in the PHP Manual all the time ;)