Phpdocumentor: Inherit docblock from parent abstract method.

Created on 25 Sep 2014  路  4Comments  路  Source: phpDocumentor/phpDocumentor

As for now, a method won't inherit the parent method docblock if it is an abstract method.

For example:

Parent method:

/**
 * Perform the validation.
 * @param  mixed     $input
 * @param  InputBag  $parentInput
 * @param  Validator $validator
 * @return boolean
 */
abstract public function validate($input, InputBag $parentInput, Validator $validator);

Child method:

/**
 * {@inheritDoc}
 */
public function validate($input, \Asgard\Validation\InputBag $parentInput, \Asgard\Validation\Validator $validator) {
    return preg_match($this->pattern, $input) === 1;
}

phpdoc gives the errors:

Argument $input is missing from the Docblock of validate()
Argument $parentInput is missing from the Docblock of validate()
Argument $validator is missing from the Docblock of validate()

bug

Most helpful comment

Hello @mvriel why not just disable validation if an {@inheritDoc} is found in the method docBlock ? It is about clean because if the method signature is not the same as the inherited one, PHP would crash and it assumes that the inherited doc is correct (if it is not errors will just be printed on the parsing step for the inherited method).

All 4 comments

This is a known issue that is not easily solved. The problem is that when a function is interpreted (with its DocBlock) there is no inheritance information yet because the inheritance tree is not yet built. The validation functions still trigger nonetheless.

This is something that needs to be addressed but I need to think of a smart solution for this ..

You probably know that already, but just in case, I only mentionned abstract methods in my original post but it's actually the same with interfaces.

Hello @mvriel did you found a solution for the current issue?

Hello @mvriel why not just disable validation if an {@inheritDoc} is found in the method docBlock ? It is about clean because if the method signature is not the same as the inherited one, PHP would crash and it assumes that the inherited doc is correct (if it is not errors will just be printed on the parsing step for the inherited method).

Was this page helpful?
0 / 5 - 0 ratings