phpdoc

PHPDoc for fluent interface in subclass?

回眸只為那壹抹淺笑 提交于 2019-12-06 13:21:07
Is there any why to make my IDE (actually PHPStorm) understand that: $student->setName('Marco'); Will return an instance of Student , without redefining setName() in the subclass (only for adding PHPDoc comments)? class Person { private $name; /** * @param string $name * @return Person */ public function setName($name) { $this->name = $name; return $this; } } class Student extends Person { } You can return $this instead of person in your docblock you have to overwrite your method tag as comment like this /** * @method Student setName($name) */ class Student extends Person { } In my experience,

phpdoc suggesting type for $this->someField

前提是你 提交于 2019-12-06 12:56:36
In Netbeans and phpStorm, this works as expected: public function someMethod() { $objectA = uberEnterprisyFactory('someclassA'); /* @var $objectA TheClassA */ // $objectA-> (autocomplete for TheClassA is displayed, good) This does not: public function someMethod() { $this->objectA = uberEnterprisyFactory('somemodelA'); /* @var $this->objectA TheClassA */ // $this->objectA-> (no autocomplete here, not good, $this->objectA is inferred to be null) How can I sugest type of $this->someThing to Netbeans and/or phpStorm? Use the following PHPDoc annotation: class MyClass { /** * @var MyPropertyClass

phpDocumentor page-level docBlock in html included file

孤街浪徒 提交于 2019-12-06 08:54:00
I'm using the tool from phpdoc.org and i'm stuck when I have a PHP file such as header.inc.php with only HTML inside. <?php /** * Header content * * @author My name * * @since 1.0.0 */ ?> <!DOCTYPE html> <html lang="fr" class="no-js"> <head> ... I get an error in my phpdoc "No page-level DocBlock was found in file...". I googled it but I didnt find any user with my case. How to fix that error? Any tips are welcome. Thank's! Regards I just ran across this posting and though it's older, I thought I would add my two cents. While sylouuu is correct about placing a namespace directly after the your

What is the purpose of these PHPDOC properties?

て烟熏妆下的殇ゞ 提交于 2019-12-06 06:54:48
问题 In general, the PHPDOC properties are self-explanatory, but I'm having hard time understanding these: @category - what is this exactly? @package - could some one provide me examples about the usage of this property? 回答1: The package tag is the key organizing tag that you use in your code. When phpDocumentor generates the docs, it collects elements into the packages that you set. In some cases, you might choose to only use one package name (@package MyPackage) for your entire codebase, such

PHPDoc preconditions

北城以北 提交于 2019-12-06 05:57:09
How to tag preconditions with PHPDoc? I have an object, and before calling a function another function must have been called: $myObject = new MyClass(); $myObject->mustDoThis(); $myObject->beforeThis(); So the documentation for beforeThis() would look like: /** * @precondition mustDoThis() must be called before this function is */ Or is there another way around this? Perhaps a @throw clause would be enough. As far as I know, there's no standard @precondition or @postcondition tags for PhpDoc but I use them anyway as it is a nice way to hint the developer implementing the class/interface/trait.

phpDoc notation to specify return type identical to parameter type

戏子无情 提交于 2019-12-06 03:18:03
问题 Imagine the following hypothetical class structure, not an all too uncommon scenario with all PHPdoc hinting set up correctly: class BaseFilter { /** ...base methods... */ } class TextFilter extends BaseFilter { public function setMinLength($len) { /** ...irrelevant */ } } class SomethingWithFilters { /** * @param BaseFilter $filter A valid filter to be added. * @return BaseFilter The filter that was added for easy chaining */ public function addFilter(BaseFilter $filter) { $this->filters[] =

Installing phpDocumentor using PEAR

穿精又带淫゛_ 提交于 2019-12-05 20:52:20
On the home page of http://www.phpdoc.org/ , on http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.quickstart.pkg.html , and on https://github.com/phpDocumentor/phpDocumentor2 , instructions to install phpDocumentor are: pear channel-discover pear.phpdoc.org pear install phpdoc/phpDocumentor When I do so, I see that it is deprecated: [root@desktop ~]# pear channel-discover pear.phpdoc.org Adding Channel "pear.phpdoc.org" succeeded Discovery of channel "pear.phpdoc.org" succeeded [root@desktop ~]# pear install PhpDocumentor WARNING: "pear/PhpDocumentor" is

PHPStorm type hinting subclasses of baseclass

心不动则不痛 提交于 2019-12-05 20:21:49
问题 With respect to this post: In PHPStorm, how can I make type hinting work when I have a superclass method that returns a different type from each subclass, this one is about an edge case in PHPStorm type hinting. Please try to follow along - I'll do my best to be as clear as possible: So, I've got this base abstract class: abstract class myBaseController { protected $_model; ... } which another class inherits from: class myController extends myBaseController { $hello = 'hello'; ... } and which

PHPDoc and late (static or dynamic) binding

走远了吗. 提交于 2019-12-05 13:56:59
问题 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

PHPDoc inline {@link} (and Netbeans)

流过昼夜 提交于 2019-12-05 08:30:14
Perhaps I'm not understanding completely, but I'm trying to get the {@link} inline PHPDoc tag to link to another method in the class ( the docblock in question is for a "shorthand alias" method ) I haven't actually generated anything to documentation, but the {@link} is showing as plain-text in the NetBeans method descriptor. Am I doing something wrong syntactically ( if I compile the documentation will this work? ) or just that NetBeans is unable to support the inline {@link} ? For example: class MyClass { /** * Shorthand alias for {@link MyClass::method()} * * @param mixed $foo * @param