Skip to content

Throws Missing PHP DocBlock for class property warning if readonly used in class property | PHP 8.1 #446

Closed
@sandipklevu

Description

@sandipklevu

Preconditions

  1. Magento 2.4.6 EE/CE
  2. Magento Coding Standard v31 i.e magento/magento-coding-standard: 31
  3. PHP 8.1|8.2

Steps to reproduce

  1. Create a class
<?php
declare(strict_types=1);

namespace Vendor\Module\Handler;

use Vendor\Module\Service\IsLoggingServiceInterface;
use Magento\Framework\Filesystem\DriverInterface;
use Magento\Framework\Logger\Handler\Base as BaseHandler;
use Monolog\Logger;


class IfConfigured extends BaseHandler
{
    /**
     * @var IsLoggingServiceInterface
     */
    private readonly IsLoggingServiceInterface $loggingEnabledService;
    
}
  1. vendor/bin/phpcs --standard=Magento2 . -s

Expected result

  1. It should not throw a warning

Actual result

  1. Throws warning
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 17 | WARNING | Missing PHP DocBlock for class property.
    |         | (Magento2.Commenting.ClassPropertyPHPDocFormatting.Missing)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions