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 ...
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...
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...
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...
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...
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...
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...
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...
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...
15
Solved
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...
3
Solved
Given the phpDoc manual, I cannot find explanation about that
@property-read
@property-write
but only of @property.
What do they do?
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...
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...
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...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.