Is it possible to create a link to the code hint for my application, for example PHP standard.php

Eclipse does a hint of the PHP function / method, putting all the PHP function names and code hints into a file called standard.php and associates it with the project as a library (?). Just CTRL + Click any php function to raise it.

Inside standard.php there is a link after the link for all PHP functions, such as ...

 /** * 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) {} 

I would like to provide something similar to my programmers spanning our own application so that I can restrict access to our source code for the software, but still give them the advantage of supporting hints and documentation.

Question: Is there a way in Eclipse to export or automatically generate a similar link to a function that can serve the same purpose as PHP in standard.php ?


EDIT: We are in the early stages of creating a utility to do just that, which we will bring to GitHub when it is far enough away.

Right now we have created an empty repo on Github, so show it there if you are interested in getting a copy when it goes up. The repo can be found here: https://github.com/ecommunities/Code-Hint-Aggregator


UPDATE:. It took some time to find the time, but the GitHub project mentioned above is now running and now we can parse the entire project and display a map of its entire namespace / class / method. FYI, It's still in Alpha, but it's worth a look. :)

+6
source share
1 answer

You can use Zend Framework reflection packages, look at them here http://framework.zend.com/apidoc/2.1/namespaces/Zend.Code.html

Basically you need to do something like

 <?php use Zend\Code\Reflection\FileReflection; use Zend\Code\Generator\MethodGenerator; $path ='test/TestClass.php'; include_once $path; $reflection = new FileReflection($path); foreach ($reflection->getClasses() as $class) { $namespace = $class->getNamespaceName(); $className = $class->getShortName(); foreach ($class->getMethods() as $methodReflection) { $output = ''; $method = MethodGenerator::fromReflection($methodReflection); $docblock = $method->getDocblock(); if ($docblock) { $output .= $docblock->generate(); } $params = implode(', ', array_map(function($item) { return $item->generate(); }, $method->getParameters())); $output .= $namespace . ' ' . $className . '::' . $method->getName() . '(' . $params . ')'; echo $output; echo PHP_EOL . PHP_EOL; } } 

When I run this in a test class that looks like this:

 <?php class TestClass { /** * Lorem ipsum dolor sit amet * * @param string $foo kung-foo * @param array $bar array of mars bars * * @return void */ public function foo($foo, array $bar) { } public function bar($foo, $bar) { } } 

I get this output:

 ➜ reflection php bin/parser.php /** * Lorem ipsum dolor sit amet * * @param string $foo kung-foo * @param array $bar array of mars bars * * @return void * */ TestClass::foo($foo, array $bar) TestClass::bar($foo, $bar) 

Which I think you want.

+2
source

Source: https://habr.com/ru/post/973124/


All Articles