magento/magento-coding-standard

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

gmachure opened this issue · 3 comments

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
)
{ }
  1. 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

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


This looks like a duplicate of #385. What version of the Magento Coding Standard are you using? This should have been fixed in version 25. See f5b3d0e.

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

Thank you.