Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documenting inherited functions/variables in subclasses with phpdoc

Lets say I have parent class with some variable, which has phpdoc:

class Parent
{
    /**
     * This variable stores some important value that
     * is going to be changed in child classes
     * @var integer
     */
    public $variable = 0;
}

Now I am writing child class, which has this variable overriden:

class Child extends Parent
{
    public $variable = 10;
}

So my question is: what phpdoc should I write for $variable in Child class, so I do not have to copy and paste variable description? Same question goes for methods. Help is much appreciated.

Update: I've asked this question after I've seen errors after creating phpdoc, like "No summary for property $variable" in Child class. If I add this summary - error disappears, but phpdoc shows description from Parent class anyway, no matter what I write in Child class. What am I doing wrong?

like image 260
mr. Pavlikov Avatar asked Mar 15 '26 13:03

mr. Pavlikov


1 Answers

That behavior sounds like a bug to me. A complete lack of docblock on the child class property should result in the parent property docblock being inherited completely. Please report it as an issue at the github repo.

like image 83
ashnazg Avatar answered Mar 17 '26 02:03

ashnazg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!