我正在用JOOMLA学习OOPS ......有时我发现在某些课程中找到使用的方法有困难...... 有没有办法找到这个函数在这个类上声明或有关该函数的有用信息?
为exmaple
class testModeltest extends JModel
{
function modifyCategory($data = array())
{ $ image = $ this-> imageResize($ value); ....... } }
现在我想知道第一次声明/定义的imageResize()
函数在哪里...表示此函数出生的类和文件名
我在类中使用了魔法constact __METHOD__
这个反向有用的信息。我需要这种类型的功能,我只需要输入方法名称&我得到了该功能的完整信息
我想要一种以下类型的设施(我确定php中有一些功能可以获取有关课程的信息,但不知道)
functionInfo($methodname) // here i just put the function name
which return
Function Name:imageResize
Main class : imageclass
File name where it has been declared : /foldername/filename.php
currenty using(called) in : thisclass::this function
答案 0 :(得分:1)
如果您正在寻找方法首次定义的地方,那么应该可以使用get_parent_class()
- 这是一个snippet,它遍历每个类定义 - 并且在每个类上执行method_exists()
找到了这种方式。
然而,这将不显示该方法随后被覆盖的位置,因此它可能对您有用 - 在这种情况下,像Reflection这样的东西可能确实是唯一的方法。