Don't print trailing spaces on empty DocBlock lines

Author: kohenkatzCreated Feb 4, 2025Updated Mar 4, 2026
Labelsenhancement

Summary

The ide-helper:models command modifies the DocBlock of the models in the application.

It looks like this happens by reading the entire comment and rebuilding it, which makes sense.

The problem is that this process adds extra space to blank lines in the comment.

Example:

php
/**
 * This model does something interesting.
 *
 * It is an example of a model with lots of documentation
 */
class MyModel extends Model
{}

After the ide-helper:models command is run (here using -M to simplify the output), the following is produced:

php
/**
 * This model does something interesting.
 * <-- THIS LINE HAS EXTRA TRAILING SPACE
 * It is an example of a model with lots of documentation
 *
 * @mixin IdeHelperMyModel
 */
class MyModel extends Model
{}

This requires a second step (manual or automated) of removing all these trailing spaces again.

Would it be possible for this tool to not write those spaces in the first place?

Source: barryvdh/laravel-ide-helper