Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
barbazul opened this issue Sep 22, 2021 · 4 comments
Labels
bug Something isn't working Progress: done

Comments

@barbazul
Copy link

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):

  • OS: Linux Mint 20.2 Cinnamon
  • PHP: 7.4.23
  • PHPCS: 3.6.0
  • Standard: Magento2

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

@barbazul barbazul added the bug Something isn't working label Sep 22, 2021
@m2-assistant
Copy link

m2-assistant bot commented Sep 22, 2021

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
Copy link
Contributor

svera commented Sep 28, 2021

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

@svera
Copy link
Contributor

svera commented Sep 28, 2021

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

@barbazul
Copy link
Author

barbazul commented Oct 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Progress: done
Projects
None yet
Development

No branches or pull requests

2 participants