Skip to content

PHP 8.1 - Constructor Multi-line function declaration not indented correctly #3786

Closed
@ricklambrechts

Description

@ricklambrechts

Describe the bug
Line indenting should be correct but is not correct for PHPCS. PHPCS says that PHPCBF can fix it:

23 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
24 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
25 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12

But after fixing the indentating is 8 spaces and PHPCS says:

23 | ERROR | [x] Multi-line function call not indented correctly; expected 12 spaces but found 8
24 | ERROR | [x] Multi-line function call not indented correctly; expected 12 spaces but found 8
25 | ERROR | [x] Multi-line function call not indented correctly; expected 12 spaces but found 8

Code sample

class A implements B
{
    public function __construct(
        protected JWK $decryptionKey,
        protected JWESerializerManager $serializerManager = new JWESerializerManager([new CompactSerializer()]),
        protected JWEDecrypter $jweDecrypter = new JWEDecrypter(
            new AlgorithmManager([new RSAOAEP()]),
            new AlgorithmManager([new A128CBCHS256()]),
            new CompressionMethodManager([new Deflate()])
        ),
    ) {
    }
}

Custom ruleset

<?xml version="1.0"?>
<ruleset name="My Custom Standard">
  <description>If you are using a custom ruleset, please enter it here.</description>
  <rule ref="PSR12" />
</ruleset>

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
 7 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
 8 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12
 9 | ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 12

Expected behavior
The expected behaviour would be that the indentation of 12 spaces is correct.

Versions (please complete the following information):

  • OS: Windows 11 (WSL2 Ubuntu)
  • PHP: 8.1
  • PHPCS: 8.9.1
  • Standard: PSR12

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions