Regarding @PARAM tags in inheritance the guide says in https://docs.phpdoc.org/guide/guides/inheritance.html:
"As with classes, each of the above will only be inherited if the redefined method's DocBlock does not have the element that is to be inherited. So, for example, if the DocBlock of the redefined method has a summary then it will not receive the overridden method's summary."
I suggest a clarification/modification:
typically there is more than one @PARAM tag. So when a extended class has a method with additional parameters one does not want to rewrite all of the @PARAM tags, but only add the tags for the new parameters. So "element" in terms of the guide should be defined as a specific @PARAM tag and not as a kind of section (= any @PARAM tag).
Repeating the documentation from the parent class manually in the child class is not suitable and contradicts the concept of inheritance. (One would need to update all child documentations, if the parent is changed).
In other words: The following should work and should inherit the @PARAM string $param.
class DemoParent
{
/**
* Some Documentation
*
* @PARAM string $param
* @return int
*/
public function myDemo(string $param): int
{
return intval($param);
}
}
class DemoChild extends DemoParent
{
/**
* @inheritdoc
* @PARAM bool $optional This is an additional param.
*/
public function myDemo(string $param, bool $optional = false):int
{
return 2;
}
}
Regarding @PARAM tags in inheritance the guide says in https://docs.phpdoc.org/guide/guides/inheritance.html:
"As with classes, each of the above will only be inherited if the redefined method's DocBlock does not have the element that is to be inherited. So, for example, if the DocBlock of the redefined method has a summary then it will not receive the overridden method's summary."
I suggest a clarification/modification:
typically there is more than one @PARAM tag. So when a extended class has a method with additional parameters one does not want to rewrite all of the @PARAM tags, but only add the tags for the new parameters. So "element" in terms of the guide should be defined as a specific @PARAM tag and not as a kind of section (= any @PARAM tag).
Repeating the documentation from the parent class manually in the child class is not suitable and contradicts the concept of inheritance. (One would need to update all child documentations, if the parent is changed).
In other words: The following should work and should inherit the @PARAM string $param.
class DemoParent
{
/**
* Some Documentation
*
* @PARAM string $param
* @return int
*/
public function myDemo(string $param): int
{
return intval($param);
}
}
class DemoChild extends DemoParent
{
/**
* @inheritdoc
* @PARAM bool $optional This is an additional param.
*/
public function myDemo(string $param, bool $optional = false):int
{
return 2;
}
}