Skip to content

Squiz.WhiteSpace.ScopeClosingBrace fixer removes HTML content when fixing closing brace alignment #3422

@GlennBags

Description

@GlennBags

Describe the bug
Div end tag removed when reformatting using phpcbf to reformat code to PSR-12 standard

Code sample

// before reformatter
    </div> <?php endif; ?>

// after reformatter
    <?php endif; ?>

Custom ruleset

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

  <description>Besides the below, have some exclude patterns that shouldn't affect the outcode.</description>

    <rule ref="PSR12"/>
    <arg name="extensions" value="php" />

</ruleset>

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run php phpcbf.phar --standard=ruleset.xml test.php -v
  3. See code reformatted with the end div removed

Expected behavior
Should not remove HTML

Versions (please complete the following information):

  • OS: MacOS 11.5.2
  • PHP: 8.0.2
  • $ php phpcbf.phar --version
    PHP_CodeSniffer version 3.6.0 (stable) by Squiz (http://www.squiz.net)
  • Standard: PSR12

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions