Skip to content

Fixer breaks the file when code violates both PEAR.Functions.FunctionDeclaration and Squiz.WhiteSpace.ScopeClosingBrace #3736

@ODAEL

Description

@ODAEL

Describe the bug
If there is a code that violates both PEAR.Functions.FunctionDeclaration and Squiz.WhiteSpace.ScopeClosingBrace sniffs, the fixer (CBF) will break the file because of deleting the extra brace.

Code sample

<?php

class Test
{
    public function __construct(
        protected int $id
    )
    {}
}

Custom ruleset

<?xml version="1.0"?>
<ruleset name="My Custom Standard">
    <rule ref="PEAR.Functions.FunctionDeclaration"/>
    <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
</ruleset>

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcbf test.php ...
  3. See test.php
<?php

class Test
{
    public function __construct(
        protected int $id
    ) {
    
    }

Expected behavior
Fixer should not "eat" the closing brace of the class.

Versions (please complete the following information):

  • OS: MacOS 12.6
  • PHP: 8.1
  • PHPCS: 3.7.1
  • Standard: PEAR.Functions.FunctionDeclaration, Squiz.WhiteSpace.ScopeClosingBrace

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions