phpdoc

Narrowing return type on inheritance for abstract method through PHPdoc causes PHP error

巧了我就是萌 提交于 2019-12-04 05:07:09
问题 Assume we have the following inheritance chain in PHP abstract class Entity {} abstract class RealEntity extends Entity {} abstract class PseudoEntity extends Entity {} and a bunch of other classes that mirror the same inheritance chain abstract class EntitySerializer { /** * @return Entity */ abstract public function getEntity(); } abstract class RealEntitySerializer extends EntitySerializer { /** * @return RealEntity */ abstract public function getEntity(); } abstract class

PhpDoc for interface and class implementing interface - difference [closed]

喜夏-厌秋 提交于 2019-12-04 02:30:50
The question is quite simple - how should I differ phpdoc for interface and for class implementing interface? Should/Can they be the same or maybe interface documentation should be as general as possible and class implementing this interface more specific? I include one method phpDoc from my real code: My interface: interface CacheInterface { /** * Adds data to cache * * @param string $objectId Name of object to store in cache * @param mixed $objectValue Data to store in cache * @param mixed $lifetime Lifetime of cache file * @param string $group Name of cache group. * @param array $params

PHPDoc and late (static or dynamic) binding

孤人 提交于 2019-12-03 23:26:19
Most PHP IDEs rely on phpdoc to get hints about the type of an expression. Yet, I use frequently this pattern, which doesn't seem to be covered: class Control { private $label = ''; /** @return ??? */ public static function Make(){ return new static(); } /** @return ??? */ public function WithLabel($value){ $this->label = $value; return $this; } /** @return void */ public function Render(){ /* ... */ } } class Textbox extends Control { private $text = ''; /** @return ??? */ public function WithText($text){ $this->width = $text; return $this; } } Now I can use the classes like this: Textbox:

phpDocumentor How to document available options for string parameter

三世轮回 提交于 2019-12-03 21:23:48
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 can be one of these options: url_sq, url_t, url_s, url_m, url_o * @return void */ public function setSize($size){ $this->_size = $size; } Yes, it's acceptable, but you can do it smarter: class TheClass { const photo_size_sq = 'url_sq'; const photo_size_tiny = 'url_t'; const photo_size_small = 'url_s'; const photo_size_m = 'url_m'; const photo_size_o = 'url_o'; /** * Set size of photos * * @param string

What is the correct way to write PHPDocs for constants?

流过昼夜 提交于 2019-12-03 19:17:26
问题 I have this code: /** * Days to parse * @var int */ const DAYS_TO_PARSE = 10; ... I don't think that using @var is correct for a constant and I don't see any @constant PHPDoc tag. What is the correct way to do this? 回答1: To get them into phpDoc, use: @const THING Usual construct: @const[ant] label [description] 回答2: The PHP-FIG suggests using @var for constants. 7.22. @var You may use the @var tag to document the "Type" of the following "Structural Elements": Constants, both class and global

php / phpDoc - @return instance of $this class?

柔情痞子 提交于 2019-12-03 16:21:21
问题 How do I mark a method as "returns an instance of the current class" in my phpDoc? In the following example my IDE (Netbeans) will see that setSomething always returns a foo object. But that's not true if I extent the object - it'll return $this , which in the second example is a bar object not a foo object. class foo { protected $_value = null; /** * Set something * * @param string $value the value * @return foo */ public function setSomething($value) { $this->_value = $value; return $this;

PHPDoc documentation generator in or out of Eclipse? [closed]

余生颓废 提交于 2019-12-03 13:29:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am developing with Eclipse + PDT. I've been adding phpdoc comments into my code, but actually never generated a resulting documentation in Eclipse. How should I do it - is there some functionality in Eclipse, or doc generation should be done externally? 回答1: To generate the documentation, you should use

phpDocumentor - Could not open input file: phpdoc.php

不羁岁月 提交于 2019-12-03 11:29:30
问题 I'm trying to use phpDocumentor (for the first time, I have no idea what I'm doing). Actually, I want to use it only with SublimeText 2 and this plugin. Can you guide me step by step what should I do to make it working? Here's what I've done now: (I'm using Windows 7) Downloaded phpDocumentor from here and placed it somewhere. I've created system PATH's for phpdoc/bin (so phpdoc.bat can be executed by sublime plugin) and then also added system path to php (from WAMPserver installation) When I

Eclipse PDT and custom PHPDoc annotations

孤街醉人 提交于 2019-12-03 08:20:02
Is there any way to add custom phpdoc annotation for Eclipse PDT? For example, I want to see @depends (for PHPUnit) in autocomplete list for comments, but now I can see there only standard annotations (for example, @deprecated ) . Thanks in advance. I assumed there would be a configuration file somewhere, but looking through the various folders in my Zend Studio installation didnt give me the results I was hoping for. Searching Eclipse.org for Content Assist yielded http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/guide/editors_contentassist.htm So I guess the "real" way to

php / phpDoc - @return instance of $this class?

拜拜、爱过 提交于 2019-12-03 05:46:48
How do I mark a method as "returns an instance of the current class" in my phpDoc? In the following example my IDE (Netbeans) will see that setSomething always returns a foo object. But that's not true if I extent the object - it'll return $this , which in the second example is a bar object not a foo object. class foo { protected $_value = null; /** * Set something * * @param string $value the value * @return foo */ public function setSomething($value) { $this->_value = $value; return $this; } } $foo = new foo(); $out = $foo->setSomething(); So fine - setSomething returns a foo - but in the