ouc*_*cil 6 php eclipse code-hinting
Eclipse通过将所有PHP的函数名称和代码提示放入调用的文件中standard.php
并将其作为库(?)与项目相关联来完成PHP函数/方法提示.只是CTRL + Click
任何PHP功能来提出它.
在内部standard.php
,参考后参考所有PHP的功能,如此...
/**
* Find whether the type of a variable is integer
* @link http://www.php.net/manual/en/function.is-int.php
* @param var mixed <p>
* The variable being evaluated.
* </p>
* @return bool true if var is an integer,
* false otherwise.
*/
function is_int ($var) {}
Run Code Online (Sandbox Code Playgroud)
我希望能够提供类似于我的程序员的东西,涵盖我们自己的应用程序,以便我可以限制访问我们的实际软件源代码,但仍然给他们的代码提示支持和文档的好处.
问题: Eclipse中是否有一种方法可以导出或自动生成一个类似的函数引用,它能够提供与PHP相同的功能standard.php
?
编辑:我们正处于创建实用程序的早期阶段,只要它足够远,我们就会将它放到GitHub上.
我们暂时在Github上创建了一个空的回购,所以如果你有兴趣在它上升的时候获得一份副本,那就明星吧.回购可以在这里找到:https://github.com/ecommunities/Code-Hint-Aggregator
更新:找到时间需要一段时间,但上面引用的GitHub项目现在正在运行,我们现在可以解析整个项目并输出它的整个命名空间/类/方法结构的映射.仅供参考,它仍然在阿尔法,但它值得一看.:)
您可以使用 Zend Framework 的反射包,请在此处查看它们http://framework.zend.com/apidoc/2.1/namespaces/Zend.Code.html
\n\n基本上你需要做类似的事情
\n\n<?php\nuse Zend\\Code\\Reflection\\FileReflection;\nuse Zend\\Code\\Generator\\MethodGenerator;\n\n$path =\'test/TestClass.php\';\n\ninclude_once $path;\n\n$reflection = new FileReflection($path);\n\nforeach ($reflection->getClasses() as $class) {\n $namespace = $class->getNamespaceName();\n $className = $class->getShortName();\n foreach ($class->getMethods() as $methodReflection) {\n $output = \'\';\n\n $method = MethodGenerator::fromReflection($methodReflection);\n $docblock = $method->getDocblock();\n if ($docblock) {\n $output .= $docblock->generate();\n }\n $params = implode(\', \', array_map(function($item) {\n return $item->generate();\n }, $method->getParameters()));\n\n $output .= $namespace . \' \' . $className . \'::\' . $method->getName() . \'(\' . $params . \')\';\n echo $output;\n echo PHP_EOL . PHP_EOL;\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n当我在一个测试类上运行它时,如下所示:
\n\n<?php\nclass TestClass\n{\n /**\n * Lorem ipsum dolor sit amet\n *\n * @param string $foo kung-foo\n * @param array $bar array of mars bars\n *\n * @return void\n */\n public function foo($foo, array $bar)\n {\n }\n\n public function bar($foo, $bar)\n {\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n我得到这个输出:
\n\n\xe2\x9e\x9c reflection php bin/parser.php\n/**\n * Lorem ipsum dolor sit amet\n *\n * @param string $foo kung-foo\n * @param array $bar array of mars bars\n *\n * @return void\n *\n */\n TestClass::foo($foo, array $bar)\n\n TestClass::bar($foo, $bar)\n
Run Code Online (Sandbox Code Playgroud)\n\n我认为这就是你想要的。
\n 归档时间: |
|
查看次数: |
330 次 |
最近记录: |