I want to use doxygen for document my PHP-Project (it's a Wordpress Plugin).
To be save, that I do not overwrite a existing class from any other Wordpress Plugin, I use the "class_exist"-Method.
But now, doxygen is only generate a documentation for my class, if i do any php call before my class definition.
An example:
/**
* #author schmitt
*
* #file my_util_class.php
*
* #class my_util_class
*
* #brief small message
*
* big message
*/
if ( ! class_exists( 'my_util_class' ) ) :
//echo "hallo";
class my_util_class
{
/**
* #brief smalltest
* bigtestmessage
*/
public function test() {
return "hallo";
}
//definition of other methods.
}
endif;
if i comment out the line echo "hallo" doxygen will generate a fully documentation of my class with all Methods.
But if the line is commented, only the header (defined with #file etc.) will documented well. None of the methods is going to be documented.
I have set the "Extract All" Parameter in the doxygen-Config to YES.
But this doesn't help.
Hope someone can help me. Thanks.
Related
How do I enable code completion for clases and methods I create in code for in netbeans 8.
Thanks,
Dion
You really should google this kinda thing, but I'm in the mood to answer a question :-)
Anyway, most IDE's read your code in pretty much the same way. I can't attest to NetBeans specifically (I use PHPStorm), but the general idea is to make sure you add docblocks to your classes, methods etc. The IDE reads these and can then provide decent code-completion.
<?php
namespace App;
/**
* Class MyClass
* Does some stuff
* #package App
*/
class MyClass extends SomeOtherClass
{
/**
* This is my var
* #var string
*/
public $myVar = 'some val';
/**
* This is my method
* #param string $yourString
* #return SomethingElse
*/
public function myMethod ($yourString)
{
$this->myVar = $yourString;
return new SomethingElse($this->myVar);
}
}
Have a look at the PHPdoc site for the tag syntax. Most IDE's will also have a way of generating this for you as well.
I'm trying to create a #link from one method to another method in a different class. Example:
class Bar extends Foo
{
/**
* This link works: {#link barFunction()}
* This link also works: {#link fooFunction()}
* This link doesn't work: {#link Foo::fooFunction()}
*/
public function fooFunction()
{
}
/**
* Bar function is another function
*/
public function barFunction()
{
}
}
The inline #link within the same class works OK. But the inline link to another class does not generate a link to the documentation. Instead, it generates:
Foo::fooFunction()
Am I doing something wrong or am I simply trying to achieve what is not possible? I looked over Apigen documentation and their forums (both at GitHub and Google Groups) but without any success. Thanks for your help.
What I want is that when I declare a magic method with #method PHPDoc, can i use #see so that the magic method has the same PHPDoc as the method pointed via #see
Here is the code of what I have tried. But IDE did not recognize it. I am using Netbeans 7.3.1.
/**
* #method string my_method() #see _my_method()
*/
class Foo {
public __call($name, $args) {
$name = "_".$name;
$this->$name($args);
}
/**
* #return String
*/
protected _my_method() {
return "bar";
}
}
The exact parsing will depend on which IDE you're using, but the PHPDocumentor documentation for #see shows a couple of differences from your usage:
The #see tag is on its own line, not appended to the line before. #link has a separate "inline" syntax if you want to include a cross-reference inside a description ({#link http://example.com/my/bar}).
The "target" should be a fully qualified element name, not just the local method name, e.g. #see Foo::_my_method()
There is also a draft PSR to standardise the behaviour, with similar requirements.
I would like to create links to "other" methods to, and I tried #see, #link and lots of other stuff, without any helpfull results.
In phpstorm everything is yust displayed as text.
BUT:
I discovered, that you can write own html-code, so
e.g.
/**
* #method string my_method() see _my_method()
*/
class Foo {
}
would work to create links on external pages.
Unfortunally it only works for external links, and not for links to methods in your editor.
Is there any way to suppress particular types of errors in PHPDoc, or direct it not to check for some elements?
I don't need a DocBlock for both the file and the class. My typical layout is as follows:
<?php
/**
* Registration service
*
* Coordinates the registration actions for users. These are ...
*
* #version a.4.2
* #author My Name <me at example.com>
*/
namespace MyProject\Service;
use Other\Namespace;
class Registration extends AbstractService
{
// ...
In this case, PHPDoc complains that I have no class summary. I can remedy the problem by copying the DocBlock and pasting it immediately above the class declaration, but I'm hoping for a better solution.
If I'm not mistaken, and I didn't test this, you could do something like this:
<?php
namespace MyProject\Service;
use Other\Namespace;
/**
* Registration service
*
* Coordinates the registration actions for users. These are ...
*
* #version a.4.2
* #author My Name <me at example.com>
*/
class Registration extends AbstractService
{
// ...
At least the docblock should now be recognised as a class doc instead of a file doc, which is more accurate in this particular example.
To try and answer your original question, actually suppressing the error, you could try this answer (it describes using the command line --packageoutput argument).
I'm looking for a way to make PHPStorm hide some methods from code completion. I've tried to annotate the DocBlocks with #access private but that does not hide them from view.
Is there any way to hide private API, short of writing/generating a stub file with a limited interface and referencing that in my project?
for example:
Lets say the library has this in it:
<?php
interface IDoABunchOfStuff
{
/**
* My library users use this
*/
public function doFoo();
/**
* My Library needs this but requires that my users don't see it.
*
* #access private
* #visibility none
* #package mylib
* #internal
*/
public function doBar();
}
class Foo extends Something implements IDoABunchOfStuff
{
/**
* does foo
*/
public function doFoo()
{
// ...
}
/**
* does bar. for internal use only
*
* #access private
* #visibility none
* #package mylib
* #internal
*/
public function _doBar()
{
// ...
}
}
And my library user is typing:
<?php
myAwesomeFunction(IDoABunchOfStuff $aFoo)
{
if($->$oFoo->[CTRL+SPACE] // invoking code completion...
Is it possible to (and if it is how do I) make it so that my user never sees _doBar?
Neither of the different annotations i've tried seem to have the desired effect.
P.S. I'm using PHPStorm 4.0.3
additional:
In this case I am implementing ArrayAccess and I don't want offsetGet, offsetSet, offsetExists and offsetUnset cluttering up my code completion window but I've had similar problems elsewhere enough to warrant asking a more generalized question.
Nope -- you cannot do such thing in current version of PhpStorm.
There is a ticket on Issue Tracker that suggests using #access tag for this purpose, but currently it is not scheduled to be implemented for any particular version: http://youtrack.jetbrains.com/issue/WI-5788
Feel free to vote/comment/etc and maybe it will be implemented sooner.