phpdoc Questions

2

Solved

I have a public method for a class and I would like to document the available string values that the method can accept. Would this be acceptable: /** * Set size of photos * * @param string $size ...
Unexceptional asked 25/6, 2011 at 9:9

3

How should I document an anonymous function when it's passed as an argument? For example: // Call my_function(), passing 2 arguments. my_function( 'foo', function() { // Body of the anon function...
Flywheel asked 30/12, 2015 at 19:12

3

Solved

I'm running PHPStan on a Symfony project where I have the following relation in a Doctrine entity: /** * @ORM\OneToMany(targetEntity="App\Entity\Course\Slide", mappedBy="chapter", cascade={"persi...
Ermine asked 24/4, 2020 at 22:15

5

Solved

Say I have a function like this: function theFunction() { $arr = array(); for ($i=0;$i<10;$i++) { $arr[] = new theObject($i); } return $arr; } I need to document the return type of the f...
Adherence asked 11/6, 2013 at 11:6

3

How can I specify the type of the keys in the documentation of a PHP method that returns an array? For example, I use this for an array of objects @return MyClass[]. But I want to comment an a...
Lifer asked 23/6, 2014 at 21:49

4

What is the best way to document, for phpdocumentor2, a method that is a generator. I don't think @return really works for yield, but I can't seem to find any proper alternative. Is it just a mat...
Gunsmith asked 6/5, 2015 at 17:4

8

Solved

I have: $myarr['DB'] = new DB(); $myarr['config'] = new config(); Can I somehow make PhpStorm to know exactly what is inside those keys? For now I see hinting for variables and class properties on...
Poise asked 16/9, 2015 at 14:31

4

Solved

Is there a proper way to document a constant defined using define()? @var doesn't really make sense. The only thing I can think of is to omit the tag, and just write the description in the PHPdoc c...
Kimberelykimberlee asked 14/2, 2011 at 18:19

2

Solved

Is it possible to link to another method/class/property/etc. inside my project inline inside the @deprecated tag? Like this: /** * Method description * @deprecated 1.0 Reason for deprecation, us...
Santonin asked 23/12, 2016 at 14:34

3

Solved

I cant find any documentation on the Closure type in PHPDoc. So my question is how do I define the parameter of the parameters sent to the closure and its return value ? Example: How do i describ...
Foresheet asked 16/5, 2013 at 14:17

2

Is there a feature or a plugin to create a link to a local project file like this: /** * @see ./views/templates/file.twig */ public function render() { .. } That would very useful for jumping...
Drip asked 24/10, 2016 at 7:23

2

Solved

There are already 2 similar questions of this type here on SO but none of the answers seem to work. PHPDoc doesn't seem to recognize optional parameters in my functions as optional, for example: ...
Cath asked 18/11, 2012 at 15:4

2

Solved

In PHP7, when a method sets a given parameter type and result type, is it necessary to document them again in the PHPDoc ? Since function foo(string $text): bool { return true; } Is equivalen...
Caltanissetta asked 30/4, 2017 at 20:12

15

Solved

So, in PHPDoc one can specify @var above the member variable declaration to hint at its type. Then an IDE, for ex. PHPEd, will know what type of object it's working with and will be able to provide...
Albite asked 22/4, 2009 at 18:29

5

I have a method that accepts a callback as a parameter. I would like to provide a signature in the PHPDoc for the class method that outlines the parameters for the callback function to be passed to...
Pardew asked 30/11, 2012 at 16:30

3

Solved

Given the phpDoc manual, I cannot find explanation about that @property-read @property-write but only of @property. What do they do?
Chun asked 8/11, 2011 at 9:20

1

Is it possible to link to another method/class/property/etc of my project, inline inside the @param tag? Like this: /** * My method's description. * * @param string $myArg Pass here result of {@...
Burgoyne asked 1/2, 2023 at 19:45

12

Solved

I'm using the Reflection API in PHP to pull a DocComment (PHPDoc) string from a method $r = new ReflectionMethod($object); $comment = $r->getDocComment(); This will return a string that looks...
Bein asked 15/1, 2011 at 21:55

4

Solved

I use several associative arrays in my PHP application and I'm using PHP documentor to comment my sources. I never really did specify comments for the arrays in an array, but now I need to do that ...
Exine asked 26/4, 2010 at 13:21

3

Solved

Consider the following code: <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Car extends Model { public static function getTheFirstCar(string $color): ?self { /** @v...
Uncap asked 5/3, 2021 at 5:21

2

Solved

Is there a way to document that a particular function calls exit()? The use case is that we have a function that is responsible for handling redirects (checks for already sent headers, set the res...
Floatstone asked 28/7, 2015 at 9:51

7

Solved

I search for a moment a way to change the name and mail used by PHPDoc in PhpStorm when you use the "autocomplete" by pressing Enter after typing /** just before a class or a function. Example : ...
Evars asked 2/6, 2015 at 13:30

5

I am trying to figure out if it is possible to use PHPdoc to define the object properties being returned by a function or a object method. Say I have the following class: class SomeClass { public ...
Zondra asked 15/9, 2012 at 7:57

4

Solved

Is there a standard way to document the expected class of entities inside a Collection in the docblock comment in a Doctrine project? Something like: /** * @var Collection<User> */ protect...
Stipulate asked 3/9, 2011 at 21:47

3

Solved

I'm using the PHPStorm IDE, and run into trouble when I run the code inspection. I have a method which returns a collection of objects. The Collection itself is an object, which has its own methods...
Remediable asked 22/5, 2012 at 17:14

© 2022 - 2025 — McMap. All rights reserved.