Skip to content
Advertisement

Tag: phpdoc

How To Declare Traversable Type?

There are multiple typehints in PHP, more now in PHP 8, and even more with Psalm. But what about declaring the type, rather than hinting the expected type? I have a interface Collection extends Traversable, and I need to declare that it is a traversable of type Abc. How can I do that, so that PHPDoc or Psalm know that

PHPDoc – typehint a variable to see static methods

I have this code: Is there any way how to typehint in PHPDoc, that variable “$sSomeClass” is a class name, so IDE can see a reference to that class? Answer Well… But I assume $sSomeClass is not a straight assignment like shown? In that case… possibly? IDE wouldn’t be able to determine it, might be able to scope the hints

PhpDocs: Possible to link method in parameter description?

Is it possible to link to another method/class/property/etc. inside my project inline inside the @deprecated tag? Like this: ? Answer According to PHPdoc.org, you could use the @see tag for that. Also, PHPdoc.org recommends to use @see in case of a @deprecated method: It is RECOMMENDED (but not required) to provide an additional description stating why the associated element is

Resolve PhpStorm magic method and property warning using PHPDoc @property and @method for $this->stdout->styles

I’m trying to resolve “Field ‘stdout’ not found in …” and “Method … not found in array” warning using PHPDocumentor notations @property and @method on PhpStorm I was able to resolve the warning for stdout using: But now how do you resolve the Method ‘styles’ not found in array warning? (See screenshot above) I made up this code to demonstrate

Netbeans PHPDoc local variable not working

I am trying to document my code more often and now I’m writing a class and want it to be fully documented. However, for some strange reason, local variable documentation (with PHPDoc of course) doesn’t work.. I got this: So when I type ‘the’ and press space, and go to my function in Netbeans, it shows the function documentation. But,

PHPDoc – Function exits

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 response code, etc…) and then crucially calls exit(). Unfortunately, PHPStorm has no idea that this particular function terminates execution and thus suggests further warnings as if

Advertisement