DEV Community

Discussion on: Improve Laravel code readability using PHPDoc

Collapse
 
patricnox profile image
PatricNox

I find PHPDoc to be too aggressive when it comes to prop comments.

In my opinion it would be against the DRY principle to have both propdoc and docblock. Specially, specially, when also typehinting the method.

I mean that something like this is a no-no for me.

/**
 * Method title.
 *
 * Method description.
 * 
 * @param  type  $var
 * @return type
 */
protected function method_title(type $arg): type
{
    /** @var type $arg */
    $type = type::create($arg);

    /** @var type $arg */
    return $type;
}
Collapse
 
meathanjay profile image
Meathanjay Baidya • Edited

I would not use PHPDoc for this method here. when you declared the $arg type and return type, it's self-explanatory and any modern IDE can catch that, PHPDoc here just makes unnecessarily noisy.

If you add a return type to create method via either PHPDoc or method itself, $type = type::create($arg); prop comments is unnecessary.

Collapse
 
patricnox profile image
PatricNox

Exactly my point.

And mixing use cases when and when not to include phpdoc syntax is even worse: It removes the whole concept of code style when it's not even followed.