magento / magento-coding-standard

Magento Coding Standard
Open Software License 3.0
342 stars 153 forks source link

Magento2.Commenting.ClassPropertyPHPDocFormatting fails to detect comment for typed class properties #280

Closed barbazul closed 2 years ago

barbazul commented 3 years ago

Describe the bug

When using typed class properties the "Missing PHP DocBlock for class property." warning is triggered

Code sample

<?php

namespace Vendor\Extension\Controller\Adminhtml\Stuff;

use Magento\Backend\App\Action;
use Magento\Sales\Api\Data\OrderInterface;

class DoStuff extends Action {
    /**
     * @var OrderRepositoryInterface
     */
    private OrderRepositoryInterface $orderRepository;

    // More controller code
}

To reproduce Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
    12 | WARNING | Missing PHP DocBlock for class property.

Expected behavior No warning should be raised as the property has a corresponding docblock.

Versions (please complete the following information):

Additional context If we remove the type definition, the warning dissapears.

m2-assistant[bot] commented 3 years ago

Hi @barbazul. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


svera commented 2 years ago

Hi @barbazul, Thank you for your bug report, it has been confirmed and resolved, fix will be published in next release.

svera commented 2 years ago

Hi @barbazul , this issue has been fixed in release v12, can you confirm?

barbazul commented 2 years ago

Upgraded to 12.0 and the issue was fixed.

There is a new ERROR in the report though which I will have to look into. might be a violation that was previously not checked

module-shipping-cost-calculator master ✚1 …3 ✔ 
09:09:40 barbazul@lyracons ▶ ./vendor/bin/phpcs 
.....W 6 / 6 (100%)

FILE: src/Model/ShippingCostCalculator.php
---------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 24 | WARNING | Missing PHP DocBlock for class property.
    |         | (Magento2.Commenting.ClassPropertyPHPDocFormatting.Missing)
---------------------------------------------------------------------------------------------------------------------

Time: 128ms; Memory: 12MB

module-shipping-cost-calculator master ✚1 …3 ✘-1
09:09:43 barbazul@lyracons ▶ composer require --dev magento/magento-coding-standard ^12.0
./composer.json has been updated
Running composer update magento/magento-coding-standard
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading magento/magento-coding-standard (10 => 12)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Upgrading magento/magento-coding-standard (10 => 12): Extracting archive
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Generating autoload files
65 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
module-shipping-cost-calculator master ✚2 …3 ✔ 
09:10:05 barbazul@lyracons ▶ ./vendor/bin/phpcs 
....E. 6 / 6 (100%)

FILE: src/Model/ShippingMethodManagement.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 90 | ERROR | Class Magento\Framework\Reflection\DataObjectProcessor needs to be requested in constructor, otherwise compiler will not be able to find and generate these classes
    |       | (Magento2.PHP.AutogeneratedClassNotInConstructor.AUTOGENERATED_CLASS_NOT_IN_CONSTRUCTOR)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 139ms; Memory: 12MB