A DocBlock is a specially formatted PHP comment which allows external document generators to generate documentation of APIs and helps some IDEs to interpret variable types, provide improved code completion, type hinting and debugging.
Questions tagged [docblocks]
104 questions
5
votes
1 answer
PHP Docblocks - Explaining an array
Possible Duplicate:
Is there a way for phpDoc to document an array of objects as a parameter?
I've been searching, and looked at the phpDocumentor documentation but cannot find if there is a way to properly document @param array (as in, declare…
user1262516
4
votes
1 answer
How can I declare that a constant is defined in PhpDoc (for intelephense)?
TL;DR
How can I document a constant that is defined in external code using PhpDoc/DocBlocks so that it will not show up as an undefined variable in static code analysis?
Details:
I'm trying to write a small WordPress plugin. I have some PHP code…

drwatsoncode
- 4,721
- 1
- 31
- 45
4
votes
0 answers
PhpStorm not to generate docblock for function/method arguments that are typehinted
At the moment on my PhpStorm I have the following options enabled:
File | Settings | Editor | Inspections | Missing @return tag` -> Marked both options there (Ignore PHPDoc without @param + Ignore PHPDoc with return type hint).
File | Settings |…

gmponos
- 2,157
- 4
- 22
- 33
4
votes
2 answers
How to make PhpStorm show exceptions thrown by a methods declared with @method (or inherit them from magic method docblock)?
Assuming the following example code:
/**
* @method bool someMethod()
*/
class MyClass
{
/**
* @throws MyClassException
*/
public function __call($method, $args)
{
if ($this->someCheck()) {
throw new…

Jack'lul
- 383
- 1
- 8
4
votes
1 answer
symbols "#@+" in PHP comments
I have found some special symbols "#@+" and "#@-" in the comments/documentation in ZF1. Example:
/**#@+
* @access protected
*/
(https://github.com/zendframework/zf1/blob/master/library/Zend/Mail.php#L54)
I have seen before in another different…

Lakremon
- 787
- 1
- 8
- 26
4
votes
2 answers
Using @package instead of namespace in PhpDocumentor 2
I have a large code library for which I am trying to generate hierarchical documentation. The project does not use namespaces but uses @package instead.
I just tried generating docs as a test from the following file with phpDocumentor2:

Aron
- 3,419
- 3
- 30
- 42
4
votes
1 answer
PHP Docblock #@+ meaning
What is the meaning of the following in a php docblock:
#@+
An example in the zend framework code:
/**#@+
* @const string Version constant numbers
*/
const VERSION_10 = '1.0';
const VERSION_11 = '1.1';
/**#@-*/
Im assuming its used to group…

Marty Wallace
- 34,046
- 53
- 137
- 200
4
votes
2 answers
DocBlock class type inheritance
Although this question is about DocBlocks in general, my use-case is about PHP.
Consider the following PHP code:

Christian
- 27,509
- 17
- 111
- 155
3
votes
1 answer
Automatic version numbers with PHPDocblocks and Git
I write my code in Netbeans and use Git as my versioning control system.
I've seen that if I were to use SVN, I could add $Id$ to my docblocks, so that a version is automatically inserted for each change committed, like:

Lewis Bassett
- 1,299
- 1
- 11
- 17
2
votes
1 answer
Match PHPDoc comments with Regex
I use the Javascript Syntax Highlighter built by Alex Gorbatchev
https://github.com/alexgorbatchev/SyntaxHighlighter/
I am trying to add support for PHPDoc comments, the PHP brush currenty matches singline and multiline comments but inside of…

JasonDavis
- 48,204
- 100
- 318
- 537
2
votes
1 answer
PHP Docblock for Trait to understand parent class
Is there a valid Docblock tag which lets a trait know which class/interface it will be used with? e.g. (below is purely made up code).
interface Authenticatable {
public function getId();
}
class User implements Authenticatable {
use…

owenmelbz
- 6,180
- 16
- 63
- 113
2
votes
1 answer
Is it possible to annotate a generic container class in a docblock
Say I have a class Book which has a property on it called $chapters. In the implementation I'm working with, this property is represented by a generic helper class called Collection, which in turn contains an array of Chapter…

HelloPablo
- 615
- 1
- 7
- 22
2
votes
1 answer
How to make PHP getter/setter inherit DocBlock from their field?
How can I make getter/setter methods to automatically use DocBlock description from their respective fields? Or maybe there are any other ways to solve this: see DocBlocks on getters/setters without manually copy-pasting every single one.
Consider…

mindaugasw
- 1,116
- 13
- 18
2
votes
1 answer
What is the difference between curly braces and angle brackets for type hinting in PHP docblock?
I see both angle brackets and curly braces used in PHP docblocks used when typehinting arrays.
/**
* @return array>
*/
Or
/**
*@return array{name:string,active:bool}
*/
I've tried to…

AndrewRMillar
- 608
- 1
- 7
- 17
2
votes
1 answer
How to use DocBlocks in PHP 7.4?
Generaly, using DocBlock in PHP is one of the best practices.
It was very usefull for previous versions of PHP (lesser then PHP 7.3 or especially 7.4).
It informs developers about class properties types, arguments types expected and values returned…

mtwegrzycki
- 103
- 1
- 9