How to add #since when using PhpStorm - php

I am using PhpStorm and for functions I want to add #since 1.0.0 in the comment section. Like this:
/**
* some function name details
* #since 1.0.0
*/
function hard_choice(){
return $blue_pill;
}
There is no indication of how to get this in PhpStorm documentation.
Has anyone used PhpStorm and got the #since to show up when doing automatic comment?
Can this be automated?
Where do I specify a version number in PhpStorm that tracks this?

You can edit the File and Code Templates for PHP Function Doc Comment:
This will insert the #since tag the moment you start a PHP-doc block before a written function (e.g., by typing /**[enter])
/**
* #return int
* #since 0.1.0
*/
public function test() {
return 1;
}

Related

doxygen doesnt seem to work well with class_exists-Method

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.

How to link to official PHP documentation in phpDocumentor 2?

I use the phpDocumentor 2 to describe few methods. I want to link to the official PHP documentation of a native function. I can write something like this:
/**
* #see http://php.net/manual/en/function.ucfirst.php ucfirst
*/
These don’t work:
/**
* #see ucfirst
* #see \ucfirst
*/
Is there a better way? I am looking for something like this:
/**
* #the-official-documentation-for ucfirst
*/
You have some issue with your syntax in the documentation. You should use #link instead of #see.
/**
* #see http://php.net/manual/en/function.ucfirst.php ucfirst
*/
Change your documentation code to
/**
* #link http://php.net/manual/en/function.ucfirst.php ucfirst
*/
I have tested it and is working on my editor i.e. phpStorm
Note: It only works in the functions and class names. You cannot use it on comments.

phpdoc not documenting anything but the starting docblock

I'm trying to document a sample file:
/**
* ElasticSearch Library
*
* Intended to do some cool stuff
*
*
* #author cmvr
* #subpackage elasticSearch
* #copyright free to use
* #license http://www.gnu.org/copyleft/gpl.html Freely available under GPL
*/
namespace Libs;
/**
* This is the main class of elastic search
*/
class elasticSearch {
protected $dataConnection;
/**
* elastic search setup data connection
* #return boolean
*/
public function setupDataConnection($dataString) {
return true;
}
}
I'm running in the CLI:
phpdoc -f ../../app/libraries/elasticSearch.php -t ../../newDocs
And it's working fine, but when i'm viewing my html ouput here:
newDocs/files/elasticSearch.html
The class and the method setupDataConnection aren't documented at all.
This is the screens i see:
Can anyone explain what am i doing wrong?

What Do the # mean inside these comments ?

I am reading some PHP code from someone else and the file is filled comments preceeding each meathod. What does the comment #access and #var mean ?
/**
* EE Superobject
*
* #access private
* #var object
*/
private $EE;
Many Thanks !
It's an annotation used by some documentation generating tools to generate said documentation.
Specifically used by phpDocuemntor to compile documentation.
phpDocumentor tags are very similar to tags for the JavaDoc tool for Sun's Java Programming Language. Tags are only parsed if they are the first thing on a new line of a DocBlock. You may use the # character freely throughout documents as long as it does not begin a new line. An example:
/**
* tags demonstration
* #author this tag is parsed, but this #version tag is ignored
* #version 1.0 this version tag is parsed
*/
Here is a list of the standard tags:
#access
#author
#copyright
#deprecated
#example
#ignore
#internal
#link
#see
#since
#tutorial
#version
inline {#internal}}
inline {#inheritdoc}
inline {#link}
These are PHPDoc tags: http://en.wikipedia.org/wiki/PHPDoc they are used to describe certain properties of a class or function; the documentation is automatically generated from the comments above class/functions.

Is there a way to tell PHPStorm to hide a method/function/variable/etc

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.

Categories