magento / magento-coding-standard

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

PHP8.1 / PHPCS Empty FUNCTION statement detected with constructor property promotion #412

Closed gmachure closed 2 years ago

gmachure commented 2 years ago

Preconditions

M2.4.4

Steps to reproduce

  1. Create a php class and add constructor using property promotion like this :
    public function __construct(
        private readonly string $test1,
        private readonly int $test2
    )
    { }
  2. Launch phpcs

Expected result

  1. No errors Empty function should be authorized here.

Actual result

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE

14 | WARNING | Empty FUNCTION statement detected

m2-assistant[bot] commented 2 years ago

Hi @gmachure. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


fredden commented 2 years ago

This looks like a duplicate of https://github.com/magento/magento-coding-standard/issues/385. What version of the Magento Coding Standard are you using? This should have been fixed in version 25. See https://github.com/magento/magento-coding-standard/commit/f5b3d0e90510336dc5e511fd55b00b9690d92b0f.

gmachure commented 2 years ago

Yes you're right. I was using version 24.

Thank you.