<p>When most people think of "Don't repeat yourself" or DRY, they probably think about not duplicating logic in code.</p>
<p>If you've written some functionality once, you should avoid writing it again.</p>
<p>I was recently browsing the code for an open source package and saw this:</p>
<pre><code class="php">/**
*Flush everything.
*/
public function flush():void;
/**
*Sets the formatter.
*/
public function setFormatter(FormatterInterface $formatter):void;
/**
*Gets the formatter.
*/
public function getFormatter():FormatterInterface;
</code></pre>
<p>This is another instance of repetition.</p>
<p>The docblocks are just repeating what the code already tells me.</p>
<p>I can understand from the method names what each function does, and I can see what parameters they have and their types.</p>
<p>I can see if each method returns anything and, if so, what type it returns - e.g. <code>getFormatter</code> returns a <code>FormatterInterface</code>.</p>
<p>I think these docblocks aren't needed and in my projects, would suggest they be removed.</p>
<p>Unless they're adding more information, such as <a href="/daily/2025/03/21/phpdoc">PHPStan PHPDoc types</a>, there's no need to repeat what the code already says.</p>
format:full_html
processed:|
<p>When most people think of "Don't repeat yourself" or DRY, they probably think about not duplicating logic in code.</p>
<p>If you've written some functionality once, you should avoid writing it again.</p>
<p>I was recently browsing the code for an open source package and saw this:</p>
<pre><code class="php">/**
*Flush everything.
*/
public function flush():void;
/**
*Sets the formatter.
*/
public function setFormatter(FormatterInterface $formatter):void;
/**
*Gets the formatter.
*/
public function getFormatter():FormatterInterface;
</code></pre>
<p>This is another instance of repetition.</p>
<p>The docblocks are just repeating what the code already tells me.</p>
<p>I can understand from the method names what each function does, and I can see what parameters they have and their types.</p>
<p>I can see if each method returns anything and, if so, what type it returns - e.g. <code>getFormatter</code> returns a <code>FormatterInterface</code>.</p>
<p>I think these docblocks aren't needed and in my projects, would suggest they be removed.</p>
<p>Unless they're adding more information, such as <a href="/daily/2025/03/21/phpdoc">PHPStan PHPDoc types</a>, there's no need to repeat what the code already says.</p>