magento-coding-standard icon indicating copy to clipboard operation
magento-coding-standard copied to clipboard

Allow no comment for a constructor where needed

Open fredden opened this issue 1 year ago • 0 comments

While working on https://github.com/magento/magento2/pull/37020, I noticed that the Magento coding standard was requiring a docblock comment for the following constructor:

https://github.com/magento/magento2/blob/322047d01d98b584892c6058ed93c5bf6715add8/lib/internal/Magento/Framework/Data/Tree.php#L28-L33

    public function __construct()
    {
        $this->_nodes = new NodeCollection($this);
    }

Typically there is no 'short description' required for constructors, but a docblock listing each @param is required (even if it's purely a duplicate of what PHP says, but that's a separate issue/gripe). However, as this particular constructor does not have any parameters, I consider the requirement for a docblock an error.

This pull request adds a special case for the __construct() method to avoid a useless (or empty) comment being added.

fredden avatar Mar 20 '23 22:03 fredden